Sign in to follow this  
inbgche

[OpenGL] Render using buffer.

Recommended Posts

inbgche    122
Is there any method that I save current frame buffer and render the buffer instead of full 3D scene in OpenGL. Because my scene do not change and it do not need any update, so I think if I can save my current frame buffer, and render using the buffer by just 2D rendering, performance will rise up dramatically. But, I didn't find the way. I read some function's decriptions, glCopyPixels(), glDrawPixels(). Unfortunately I didn't catch how can I make it using that functions. Any comments please...

Share this post


Link to post
Share on other sites
IvanMilles    142
GLint index;
glGenTextures (1, &index);
glBindTexture (GL_TEXTURE_2D, index);
glCopyTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 0, 0, winW, winH, 0);

Now index is a texture that contains your scene (provided that the scene is a power-of-two thing, otherwise you'll have to mess around a bit to do it).

But, if your scene isn't changing, why re-display it? Only re-render when something has changed in your scene. :)

Share this post


Link to post
Share on other sites
taby    1265
glGenRenderbuffersEXT can be used to create a specialized offscreen render buffer. I use this for the same purpose you do.

Here is a list of the related functions:
glBindFramebufferEXT;
glDeleteFramebuffersEXT;
glGenFramebuffersEXT;
glFramebufferTexture2DEXT;
glBindRenderbufferEXT;
glDeleteRenderbuffersEXT;
glGenRenderbuffersEXT;
glRenderbufferStorageEXT;
glFramebufferRenderbufferEXT;

The reason to redisplay the 2D buffer is so that any areas of the screen which may have been drawn over by the OS can be refreshed in a non-OS-specific way.

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