PDA

View Full Version : glClearStencil () question



rgreene
10-09-2002, 02:41 PM
If I have the following code:

glStencilMask (0xFF);
glClearStencil (0xFF);
unsigned char id;
glReadPixels (0, 0, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, &id);

Why is it that I get a value 0 for id? Do I have to wait for the clear to actually happen? Is there a client state that needs to be enabled for the clear to function properly?

chowe6685
10-09-2002, 04:17 PM
if my memory serves me, glClearStencil sets the value to clear the stencil buffer to, you need to call glClear(GL_STENCIL_BUFFER_BIT) to actually clear it

rgreene
10-09-2002, 06:43 PM
Yup, that was it. That was why it was always wrong only on the first frame.

Thanks!