[OpenGL] Render using buffer.

Started by
2 comments, last by Tatsunami 18 years ago
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...
Advertisement
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. :)
Ramblings: http://ivan.rusted.se
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.
If you have a relatively-recent video card, the shiny new solution these days is to use the EXT_framebuffer_object extenstion.

This extension allows you to render the scene directly to a texture without needing any of the glCopy* functions.

Speed wins.

This topic is closed to new replies.

Advertisement