Skip to main content
gamedev.net
🔒 Locked

EXT_framebuffer_object + glViewport

Started by dimensionX Sep 8, 2005 at 6:28 PM 5 replies 1.6k views
Original Post
dimensionX
dimensionX
glMatrixMode(GL_VIEWPORT); glLoadIdentity(); glViewport(0, 0, 512, 512); glBindFramebuffersEXT(); /* Bind */ glMatrixMode(GL_VIEWPORT); glLoadIdentity(); glViewport(0, 0, 256, 256); glBindFramebuffersEXT(); /* Unbind */ Shouldn't be the viewport still be glViewport(0, 0, 512, 512); ?
Enigma
Enigma
No. The viewport is not part of the framebuffer state and therefore must be explicitly reset after a framebuffer state change. And there is no such thing as a viewport matrix stack. glMatrixMode can only take the parameters GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE or GL_COLOR.

Enigma
dimensionX
dimensionX
> glMatrixMode can only take the parameters GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE or GL_COLOR.

Try glMatrixMode(GL_VIEWPORT); and tell me if it gives compilation error, atleast it doesn't give me compilation error.
AndyTX
AndyTX
It won't give you a compilation error because it's simply an enumeration, which is a valid parameter to the function. GL enumerations are NOT type-safe! This is a bit of a disadvantage of OpenGL, but if you're religeously checking glGetError() after each GL call then you'll catch the problem immediately at runtime.
silvermace
silvermace
glMatrixMode(GL_VIEWPORT);
glLoadIdentity();
glViewport(0, 0, 512, 512);

glBindFramebuffersEXT(); /* Bind */

glPushAttrib( GL_VIEWPORT_BIT );
glViewport(0, 0, 256, 256);

// do stuff

glPopAttrib();

glBindFramebuffersEXT(); /* Unbind */
dimensionX
dimensionX
what about the effects of gluOrtho2D() on fbo's ?
_the_phantom_
_the_phantom_
OK, to explain;

FBOs use the same context infomation as the context they are created/used in (normally the main context, but it could be a pbuffer) as such they use the same attributes, matrices and pointers as the main context, therefore if you change them when drawing then VBO they remain changed in the host context, therefore you should save them before you change them.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.