FBO viewport issues

Hello everyone,

I want to render into a texture, which is larger than my current viewport. I use the fboClass and create an FBO for that purpose. What I would like to do is setting the viewport to according to the texture dimensions (512x512). However, I only get correct results, when setting the viewport according to my current canvas resolution (640x480). As a consequence I cannot render to the whole y-extend of the texture…
Any ideas, how to solve this issue?

Any help is ver Welcome!

Thanks, pinksy.

When do you set the viewport for the FBO? Before or after activating it?

I use the following order:

fbo_->Bind
fbo_->AttachTexture
glDrawBuffer

glPushAttrib(GL_TRANSFORM_BIT);
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D

Shouldn’t there be a glViewport call in there somewhere?

Please, post the full source code in a readable and executable version.

Thanks for the replies! Unfortunately I cannot post the whole code, since it is part of a bigger software project. But after the gluOrtho2D call, there happens only very basic rendering.

What is about the glViewport call, do I need to set it?

Best wishes.

Don’t Disturb was pointing out the lack of glViewport call in the above code, you should do:

glPushAttrib(GL_TRANSFORM_BIT);
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
// after saving the current viewport attributes do
glViewport(0, 0, 512, 512);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D

More information about glViewport, here.

Great, thanks dletozeun and Don’t Disturb that solved my problem!