composing layers is openGL

This is a discussion on composing layers is openGL within the Game Programming forums, part of the General Programming Boards category; I'm writing an application in openGL, and I thought of a method to optimise my drawing. Basically I will have ...

composing layers is openGL

I'm writing an application in openGL, and I thought of a method to optimise my drawing. Basically I will have to compose three layers.
- 1 : this layer will contain only colors with alpha = 1
- 2 : this one will also contain transparant and semitransparent colors.
- 3 : same as two.

Right before calling SwapBuffers, I would then compose these three layers to form the final render. If I do it this way, I can easyly update only (parts of) the first layer, and get the desired output without having to rerender (parts of) the 2nd and 3rd layer. Also when nothing has to be redrawn, I should only compose the layers again and call SwapBuffers.

My question is : Is there a way to do this with openGL ? I've read about the accumulation buffer, but I don't know if I could do it like that.

I'm not sure if you can use the accumlation buffer for your purpose. The first idea that came to my mind was drawing to a texture. Keep 3 textures hanging around, which will be your 3 layers, and blit them to the front buffer each frame.