PDA

View Full Version : FBO viewport issues



pinsky
01-05-2009, 01:29 AM
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.

Hampel
01-05-2009, 02:24 AM
When do you set the viewport for the FBO? Before or after activating it?

pinsky
01-05-2009, 02:58 AM
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

Don't Disturb
01-05-2009, 08:11 AM
Shouldn't there be a glViewport call in there somewhere?

dletozeun
01-05-2009, 02:22 PM
Please, post the full source code in a readable and executable version.

pinsky
01-06-2009, 12:54 AM
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.

dletozeun
01-06-2009, 05:20 AM
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 (http://www.opengl.org/sdk/docs/man/xhtml/glViewport.xml).

pinsky
01-06-2009, 08:39 AM
Great, thanks dletozeun and Don't Disturb that solved my problem!