Using rendered scene as background...

Started by
5 comments, last by Scarfy 18 years, 7 months ago
Sorry if this sounds a little wooly... Suppose in my game I have just rendered the current scene and I wish to use that as a background image for a menu, (eg - The player has pressed Escape to bring up an in game menu I wish to preserve the previous rendered frame without having to redraw it as well as the menu), how would I acheive this? I thought you could create a texture from a the previous data, but if the resolution of the game was 1024 x 768 then that would just be silly. What's the best approach? Render to a texture? Or is there something else I can do..? Ta
Parallel RealitiesProject: Starfighter
Advertisement
Quote:I thought you could create a texture from a the previous data, but if the resolution of the game was 1024 x 768 then that would just be silly.

Why would that be silly? The texture would be 3 MB, not weirdly large or anything..
So yeah, render your scene to a texture, and while showing the menu, put this texture on a large screen-filling quad.
I'm fairly new to OpenGL you see, so I figured that generating a 1024 x 768 texture would be a really bad idea and it would be better to generate lots of 256x256 textures instead.
Parallel RealitiesProject: Starfighter
Wouldnt it be easier to just stop clearing the color buffer?
How do you mean? You mean don't clear the screen before each redraw? That won't work as I've got too much stuff animating over and out of the bounds of the menu... Hmmmm... I'll try the render to texture solution and see what I can do.
Parallel RealitiesProject: Starfighter
Quote:Original post by Scarfy
How do you mean? You mean don't clear the screen before each redraw? That won't work as I've got too much stuff animating over and out of the bounds of the menu... Hmmmm... I'll try the render to texture solution and see what I can do.

I would just continue rendering the 3D scene with all animation paused and draw the menu on top (with depth buffer disabled), because it's probably less work to implement.

Anyway, two tips if you're going for the texture solution:
- you'll need the GL_ARB_texture_rectangle extension if you want to use a 1024 by 768 texture (because 768 is not a power of 2)
- Using glCopyTexImage2D is very easy and efficient for copying the framebuffer to the texture. If your hardware supports frame buffer objects (FBO's) that's an even better solution.

Tom
Thanks! Sounds like it might be easier to keep rendering stuff! :)
Parallel RealitiesProject: Starfighter

This topic is closed to new replies.

Advertisement