background question

I have loaded a picture and then it draws the picture with rectangles that sample the pictures color.

Here is the code I used:

			int width = Primative.width;  
			int height = Primative.height;  
			int x=ofRandom(0,width);  
			int y=ofRandom(0,height);  
			int colorIndex = y*(Primative.width*4)+x*4; ofSetColor(pixels[colorIndex],pixels[colorIndex+1],pixels[colorIndex+2],pixels[colorIndex+3]);   
			glTranslatef(40, 750, 0);  

This needs ofSetBackgroundAuto to false. The problem is that I have other graphics that need to be cleared from the screen. Can I run some of the program with ofSetBackgroundAuto changing. Or should I control the above code if a for loop that the maximum slowly increases.

I’m not quite sure I am following, but you can clear the screen yourself using the line of code below:


Or, you can simply draw a quad, perhaps semitransparent if you want, to clear the portion that you want.

It’ll be hard to clear only certain objects off the screen (but I might be misunderstanding you), in that case simply initialize a large array able to keep the maximum amount of objects that you want and re-draw it every frame, taking out the stuff you don’t want, depending on what it is chances are it’ll be fast enough anyways, quads certainly sound like you could do quite a few.


There are three pictures that are drawn with these squares. The colors of the squares are sampled from the picture it is drawing. Think pointillism. At the end the color bits are erased so you never actually see the picture. I can’t turn glClear off because I need other graphics to clear at the end of the draw loop. My best guess is to use a two dimension array so it knows where is has drawn the squares. I am looking for other solutions since I am fairly new to C++.