LWJGL Forum

Programming => OpenGL => Topic started by: ParticleSwarm on March 02, 2011, 03:10:24

Title: rendering to back buffer
Post by: ParticleSwarm on March 02, 2011, 03:10:24
I'm working on color picking in my project. I have everything working correctly. The primitives each get their own color and a mouse event correctly identifies one. The problem is, I can only seem to read from the front buffer, when the primitives are rendered on screen in the usual render function. I need this to happen 'behind the scenes', on a second rendering the user doesn't see. I thought I could use something like:


mouseClick()
{
glDrawBuffer(GL_BACK)

//Second rendering the user never sees
renderUniqueColors()

glReadBuffer(GL_BACK)

glReadPixels(...)
}

This doesn't appear to work. If I set it to read GL_FRONT, it will read the original, first rendering correctly. I can never get it to read the second rendering. Should it? Alternatives? I don't think I quite understand how rendering works in lwjgl.

In advance, thanks for your time!