Jump to content
  • Advertisement
Sign in to follow this  
dimensionX

EXT_framebuffer_object + glViewport

This topic is 4817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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); ?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
> 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 */

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!