Sign in to follow this  
Scarfy

Using rendered scene as background...

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

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