PDA

View Full Version : FBO and viewport



Swoop
07-15-2013, 06:39 PM
I have an FBO with an attached 16bit RGBA color texture target. I bind the fbo, set the draw buffers, clear, and set the viewport equal to the dimensions of the render texture, activate the shader, draw the objects, all works.

Using the same setup, I wanted to render into only the bottom left corner of the FBOs attached target. So I set the viewport to 0, 0, w/2, h/2.
Now I either get nothing, or some sort of partial image only If I dont move the camera after startup.

To do what Im asking, should it be as straight forward as simply changing the viewport, or is there something extra that Im missing when rendering to texture with FBO?

thokra
07-16-2013, 04:10 AM
Viewports and framebuffer objects aren't directly associated. Viewport mapping is the final step of the transformation pipeline and maps values in normalized device coordinates to window- or screen-coordinates. This happens regardless of FBO usage. So there is no special catch in this case. However, if you change the viewport size, you should still see what you render - just mapped to a smaller area. Can you post some code?

Swoop
07-17-2013, 11:34 AM
Thanks for the confirmation. I was a having a 'losing my mind' moment trying to figure out why something so simple didnt just work. Ive got it now, turns out the depth test was set to equal, which caused the image to only show for a moment at the start when the depths aligned perfectly.