set?

I was just wondering, is there any equivalent in OF for Processing’s set method? If you’re not familiar with it, in Processing you can do set(x, y, mycolor). I know OF doesn’t have a color type like Processing… but what is the best way to set a pixel at a particular x,y to a particular colour?

There isn’t a set() method but you can always just draw a very small rect at a point using ofRect(). There are several other ways to do that (take a look at oFTexture http://www.openframeworks.cc/documentation?detail=ofTexture#ofTexture), but that’s the easiest I can think of.

Yes, the ofRect was the only thing I could think of… well, I’ll just use that then, if it works, thanks.

It might be faster (haven’t tested) to alter the values in an array and then write that to a texture and then draw the texture:

  
unsigned char pixels[imageWidth*imageHeight*3];  
pixels[yPixel*imageWidth*3+xPixel*3] = redAmt;  
pixels[yPixel*imageWidth*3+xPixel*3+1] = greenAmt;  
pixels[yPixel*imageWidth*3+xPixel*3+2] = blueAmt;  
myTexture.loadData(pixels, imageWidth, imageHeight, GL_RGB);  

Hi,

you can also draw points using opengl
something like this:

  
  
glBegin(GL_POINTS);  
  
//one point  
ofSetColor( 255, 255, 255);  
glVertex2f(x, y);  
  
//another point  
ofSetColor(0, 0, 255);  
glVertex2f(x, y);  
  
//and so on...  
  
glEnd();  
  

best

Rui