composing layers

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.

Does anyone know how I could get my method to work ?

Thanks in advance.

accumulation buffer is rarely useful on consumer cards anyway.
The ideal way is framebuffer objects (FBO) if it is supported on your hardware.

That way you render to hidden framebuffers, then composite these as textures.