View Full Version : Mapping from rednerbuffer size to texture size for glow effect

04-25-2013, 02:26 PM

I am trying to get a texture for glow effects working, and am struggling with window sizes that are not the same size as the texture when I am drawing into the texture.

I have working code that goes (pseudocode);

createRenderBuffer(); // create colour & depth buffers, bind to GL_DRAW_FRAMEBUFFER. Note: scene is not a power of 2 so can't be draw directly to texture
createTexture(); // create a texture renderbuffer, bind to GL_DRAW_FRAMEBUFFER
// set the previous renderbuffer to GL_READ_FRAMEBUFFER
glBlitFramebuffer (); // fill the texture with a downsampled image of the scene

... carry on.

This all works fine ... but seems to involve a redundant copy - I create the first renderBuffer & draw to it only to copy data back out of it.

My question: is this in fact the right way to create a texture with an image from my scene, or should I set up transforms so that I draw the scene straight into the texture?

If so ... I have tried lots of ways to do this (as it seems to be a straight linear transform from my scene to the texture coordinate system), but without anything that works. Should I persevere ? Any good references as to where in the matrix sequence I should put a transform so that the scene fits the texture correctly? Or is it in fact OK to use the extra buffer per pseudocode above?

Thanks for any help.

05-11-2013, 03:16 PM
Answering my won question in case anyone else comes across it.

The answer is to getting the scene rendered into a texture in one go is:
- set glViewPort (0, 0, textureWidth, textureHeight);
- render scene normally
- set the viewport back