multilayered structure

I have asked the following question on some other forum and multitexture has been shown as a way to do so. I am just curious whether there are any other ways to acheive that multilayered structure?

Thanks alot;

Hi there;
I am somewhat new to opengl (I have used in my courses for my homeworks long ago, after that I had used OpenSceneGraph, now need to turn back to opengl, and cannot remember much about it).

I would like to make an animation with different layers on it. I will try to explain my situation with a simpler example;
Assume there are layers that has different geometric figures on it. Assume one has squares another has rectangles another has circles on it. And each layer is updated seperately from each other in seperate times. But when I need to update the scene lets say because of a change in squares I need to draw all the layers in order from the beginning even though the circles layer hasnt been changed yet.

Is there a way to hold the layers in a thing something like buffer, that has the drawing of the layer? So when I need to update one of the layers, I just need to refresh the buffer of the corressponding layer and just tell opengl to use the already drawn buffers for the other unchanged ones. Something similar to display list concept??

I have talked much, I wasnt much able to tell the situation but hope you understand.

Thanks in advance


First, depending on the scene complexity, and the hardware used, you may get away with simply redrawing everything when an update is needed.

Otherwise, using only simple opengl concepts, you can do something like this :

  • clear
  • draw all circles, on the back buffer, without swapping to the front buffer
  • copy this to a texture with glCopyTexImage2D
    Repeat this for each layer, each copied to a different texture.
    Then when one layer needs to be updated, you can do it separately.

To composite the final result :

  • clear
    then for each layer :
  • draw a fullscreen quad with its texture

Now you can swapbuffers to display the result on screen.

You may use multitexture with 1 quad instead of mutiple quads, it may be faster, but you can do it later as an improvement. Even better, a fragment shader will allow you to composite more layers efficiently.

An improvement for the first phase, will be to use FBO (framebuffer objects) to allow for more robust rendering to texture (the above method will not work well if the GL window is partially covered by another window).

for reference :