   problems writing values to the stencil buffer using glDrawPixels
  I'm having some problems writing a pattern to the stencil bufferusing glDrawPixels. The problem seems to be that the value I'mcomputing does'nt get written, and I'm verifying this by readingback the value - its set to zero, the value of the cleared stencil buffer.I'm tried instrumenting the code, but no errors seem to be occurring inany of the gl calls.ThanksglClear(GL_STENCIL_BUFFER_BIT);glDisable(GL_DEPTH_TEST);glEnable(GL_STENCIL_TEST);glStencilFunc(GL_ALWAYS,0xFF,0xFF);glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluOrtho2D(0, width, 0, height);for ( x = 0; x < width; x++ ){for ( y = 0 ; y < height; y++ ){GLubytestencilvalue;GLuintreadstencil;stencilvalue = rand2(255);glRasterPos2i(x,y);glDrawPixels(1,1,GL_STENCIL_INDEX,GL_UNSIGNED_BYTE,&stencilvalue);glReadPixels(x,y,1,1,GL_STENCIL_INDEX,GL_UNSIGNED_INT,&readstencil);}}glPopMatrix();   
  The stencil operation is GL_KEEP for all possible outcomes of the stencil test, so no wonder the stencil buffer doesn't change.   