PDA

View Full Version : Saving areas of the framebuffer and blending them



05-17-2005, 02:33 AM
I need to be able to render something of an arbitary size (not power of 2 and possibly bigger than the max texture size) and then save it to the vid card mem. I want to be able to load it up later and blend it with whatever is in the framebuffer at that time. I've looked at the ARB Buffer Region extension but it just replaces what was in the framebuffer when you restore a region.

Is there any way to do what I want to do? The best I could think of was to divide the image into smaller sections and save everything as textures. I don't really want to do that tho if I don't have to. I've only been using OpenGL for a few days so I'm not sure where to look, anyone got any pointers?

Any help would be greatly appreciated.

Thanks

Relic
05-17-2005, 03:16 AM
If it should be bigger than the maximum texture size it is probably also bigger than the maximum viewport size.
You need to render it in tiles and store it in individual textures.
Check this out:
http://www.mesa3d.org/brianp/TR.html

05-17-2005, 11:40 PM
Thank's for your advise, I'm going to use textures.

I've written a simple program that draws some squares and attempts to save a texture.

Here is my saving code:

glGenTextures(1, @Texture);
glBindTexture(GL_TEXTURE_2D, Texture);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, Width, Height, 0);Width and height are POT.

I then do the following to test drawing:

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Texture);
glBegin(GL_QUADS);
glTexCoord2f(0, 1); glVertex2i(0, Height);
glTexCoord2f(0, 0); glVertex2i(0, 0);
glTexCoord2f(1, 0); glVertex2i(Width, 0);
glTexCoord2f(1, 1); glVertex2i(Width, Height);
glEnd;
glDisable(GL_TEXTURE_2D);The problem is that the drawn quad does not have the texture on it. It is the color of glColor. Can anybody tell me what I did wrong? Thanks