Writing directly to screen pixels / per-pixel operations?

Hi,

Can anyone suggest why the following code, inside the draw() function, does nothing? The program compiles fine (under Linux), it just doesn’t write anything to the screen.

  
  
  
ofImage theScreen;   
unsigned char* myPixels;  
int i;  
  
theScreen.grabScreen(0,0,1024,768);  
  
myPixels = theScreen.getPixels();  
   
i = (400*(theScreen.width*3)) + 500*3;  
   
   
  myPixels[i]   = (unsigned char)255;  
  myPixels[i+1] = (unsigned char)0;  
  myPixels[i+2] = (unsigned char)0;  
     
theScreen.draw(0,0);  
  
  

As I understand it (from reading wiki examples, though none state explicity how to write tp pixels) this should write a red pixel to somewhere near the center of the screen, but it just shows a blank gray screen. Note that thescren.bpp == 3 in this example, and the gfx setup line is just ofSetupOpenGL(&window, 1024,768, OF_WINDOW);

Thanks for any help.

you need

  
  
theScreen.update();  
  

before

  
  
theScreen.draw(0,0);