glPushAttrib problem


There seems to be some weirdness with glPushAttrib. When I do glPushAttrib(GL_ALL_ATTRIB_BITS) I don’t get what I expect on the screen. But if I only mask out the values that I know I need with glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT) I get what I’m supposed to.

I get no errors from glGetError and glGet(GL_ATTRIB_STACK_DEPTH) returns a 0 (in case I was overflowing the stack).

I’ll be using the less expensive GL_CURRENT_BIT | GL_ENABLE_BIT, but was wondering if pushing all of the attributes was a known problem.



AFAIK glPushAttrib() in itself doesn’t modify the way things get rendered.
Only after a glPopAttrib() can things start behaving unexpectedly, if the preceding glPushAttrib() didn’t properly cover all subsequent state changes.

Verify that you have exactly the same number of Pushes and Pops and that you are not exceeding the MAX_ATTRIB_STACK_DEPTH nor underflowing the stack (i.e. popping before pushing).