FBOTexture acting weird

Hey everyone

I’ve been using the ofxFBOTexture the last week and it seems to behave quite strangely most of the time - especially when using ofSetColor. For example, I have this code:

  
  
void testApp::setup()  
{	 	  
	ofEnableSmoothing();  
	  
	theScreen.loadImage("images/runemadsen2.png");  
	theScreen.setImageType(OF_IMAGE_GRAYSCALE);  
	myPixels = theScreen.getPixels();  
	  
	tex.allocate(ofGetWidth(), ofGetHeight());  
	tex.begin();  
	  
	ofSetColor(0x5c84d5);  
	ofRect(0, 0, ofGetWidth(), ofGetHeight());  
	  
	int ran;  
	int index;  
	int color;  
	  
	for (int i = 0; i < theScreen.width; i += ofRandom(6, 12))   
	{  
		for (int j = 0; j < theScreen.height; j += ofRandom(6, 12))   
		{  
			index = (j * theScreen.width + i);  
			  
			if(myPixels[index] > 200)  
			{  
				ran = ofRandom(1, 6);  
				color = 255;  // CHANGE THIS TO 0 AND EVRYTHING IS BLACK  
				  
				ofSetColor(color, color, color);  
				ofFill();  
				ofCircle(i, j, ran);  
				ofNoFill();  
				ofCircle(i, j, ran);  
			}  
		}  
	}  
	  
	tex.end();  
}  
  
  
//--------------------------------------------------------------  
void testApp::update()  
{  
	  
}  
  
//--------------------------------------------------------------  
void testApp::draw()  
{	  
	tex.draw(0, 0);  
}  
  

It takes an image, loops through the pixels and draw circles depending on the color value. Everyting works fine when I’m drawing white circles: I have a blue background and white circles. If I change the circle color to black, everything turns black, including the background.

This is just one example of a number of times I’m getting this weird errors. Am I doing anything wrong or is the FBOTexture buggy?

I’m on a new MacBook Pro… I have attached the picture I’m loading if you want to test it.

  • Rune

I haven’t tried your code, but here:

  
void testApp::draw()  
{     
   tex.draw(0, 0);  
}  
  

you might try:

  
void testApp::draw()  
{    
   ofSetColor(255,255,255);   
   tex.draw(0, 0);  
}  
  

since the draw color “tints” the texture being drawn, and in the case of your code, I think your last draw color in setup() will tint the color of tex as it’s being drawn.

does that help?

take care,
zach

Thanks, that was exactly the case! Awesome…