PDA

View Full Version : Multiple glPushAttrib/glPopAttrib



dimensionX
10-31-2005, 01:22 PM
I am having problem using glPushAttrib()/glPopAttrib(). Here is what I do:

glPushAttrib(GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
glViewport(0, 0, (GLsizei) 2 * 256, (GLsizei) 512);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble) 2 * 256, 0.0, (GLdouble) 512);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTABLE_ARB, texId, 0);

glPushAttrib(GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
glViewport(0, 0, (GLsizei) 2 * 256, (GLsizei) 2 * 512);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble) 2 * 256, 0.0, (GLdouble) 2 * 512);

/* Texture mapping */

glPopAttrib();

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

At this stage I would expect the Attrib stack to be:-

glPushAttrib(GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
glViewport(0, 0, (GLsizei) 2 * 256, (GLsizei) 512);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble) 2 * 256, 0.0, (GLdouble) 512);

but it's not. This is what it returns (Observe the '512 / 2'):-

glPushAttrib(GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
glViewport(0, 0, (GLsizei) 2 * 256, (GLsizei) 512 / 2);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble) 2 * 256, 0.0, (GLdouble) 512 / 2);

glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texId);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_RECTANGLE_ARB);

/* Texture Mapping */

glDisable(GL_TEXTURE_RECTANGLE_ARB);

glPopAttrib();

Seems like the attribute stack restoration has not been properly implemented in the drivers. If this is true, it's a shame since it is OpenGL 1.1 feature.

Graphics card: NVIDIA QuadroFX 3400
Driver version: 77.56