Sign in to follow this  
bukiyou

manipulating display sizes with FBO

Recommended Posts

Hi,

This may be a simple question, but I cannot for the life of me figure out the answer.

I have an image that is rendered in perspective mode where there is a teapot 1 unit large. The rendered image is put into one of the colour fbo buffers.

I want to display the image in glortho(0, 1000, 0, 800, -10, 10) on a rectangle that is rect(0,0, 512, 512) large. The larger I try to make glortho, the smaller the teapot becomes relative to the drawn quad. At my desired size, the teapot is no longer visible. Also, glortho(0,1000, 0, 800, -10, 10) only shows the top right quadrant of the fbo texture image. If I use a normal texture instead of the fbo texture, then the texture does what it's supposed to do. What am I doing wrong? Is there something I should do with the renderobjects so that they'll be treated like proper textures?



[code]

glClearColor(1.0f, 0.0f, 0.0f, 1.0f); // Clear the background of our window to red
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear the colour buffer (more buffers later on)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,10, 0, 10, -10, 10); <------------at this size teapot is already two times smaller
glMatrixMode(GL_MODELVIEW);

glLoadIdentity();// Load the Identity Matrix to reset our drawing locations

glTranslatef(0.0f, 0.0f, -2.0f);

glBindTexture(GL_TEXTURE_2D, fbo_texture); // Bind our frame buffer texture

glBegin(GL_QUADS);

glTexCoord2f(0.0f, 0.0f);
glVertex3f(0, 0, 0.0f); // The bottom left corner

glTexCoord2f(0.0f, 1.0f);
glVertex3f(0, 5.0f, 0.0f); // The top left corner

glTexCoord2f(1.0f, 1.0f);
glVertex3f(5.0f, 5.0f, 0.0f); // The top right corner

glTexCoord2f(1.0f, 0.0f);
glVertex3f(5.0f, 0.0f, 0.0f); // The bottom right corner

glEnd();

glBindTexture(GL_TEXTURE_2D, 0); // Unbind any textures
[/code]


any sort of help would be well appreciated. thanks for your time.

Share this post


Link to post
Share on other sites
My gut is that you're missing a glViewport call when you bind your FBO to draw to it, but I'd need to see your full FBO code to be sure. Can you post the section of your code where you draw the teapot into the framebuffer?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this