Using GL_BACK_LEFT and GL_BACK_RIGHT buffers

Hi!



I'm trying to accomplish stereoscopic rendering using the GL_BACK_LEFT and GL_BACK_RIGHT buffers in the render loop:


camNode.setLocalRotation(currentCameraUpdatedEvent.getOrientation());
         camNode.setLocalTranslation(currentCameraUpdatedEvent.getLocation().add(cam.getLeft().mult(distanceBetweenEyes/2)));
         cam.update();
         
         GL11.glDrawBuffer(GL11.GL_BACK_LEFT);
         display.getRenderer().draw(rootNode);
         
         camNode.setLocalTranslation(currentCameraUpdatedEvent.getLocation().add(cam.getLeft().mult(-1*distanceBetweenEyes/2)));
         cam.update();
         GL11.glDrawBuffer(GL11.GL_BACK_RIGHT);
         display.getRenderer().draw(rootNode);



The left display looks ok, except that I have to clear it somehow but the right display renders the stuff from the left display also, only the stuff is totally black.

I don't know enough OPENGL to understand whats going on with the draw() method inside JME. I'm guessing it's happening in LWJGLRenderer.

Could someone point me in the right direction to what I need to change in JME make this work?

After reading about LWJGLRenderer in the excellent wiki I made these changes and it accually works!


camNode.setLocalRotation(currentCameraUpdatedEvent.getOrientation());
         camNode.setLocalTranslation(currentCameraUpdatedEvent.getLocation().add(cam.getLeft().mult(distanceBetweenEyes / 2)));
         cam.update();

         GL11.glDrawBuffer(GL11.GL_BACK_LEFT);
         display.getRenderer().clearBuffers();
         display.getRenderer().draw(rootNode);

         camNode.setLocalTranslation(currentCameraUpdatedEvent.getLocation().add(cam.getLeft().mult(-1 * distanceBetweenEyes / 2)));
         cam.update();
         
         GL11.glDrawBuffer(GL11.GL_BACK_RIGHT);
         display.getRenderer().clearBuffers();
         display.getRenderer().draw(rootNode);
         
         display.getRenderer().displayBackBuffer();



I'm a little concerned about needing to clear the buffers twice. I have read that clearing the buffers is very costly.
Shouldn't it be enough to clear the back buffer once in the beginning of the loop?
This makes me think that the "target buffer" is changed somewhere in the draw() call. Is it so?

The jME context system has a built-in stereo render pass with asymmetric frustum (more accurate stereo image than in your code), plus it can render as anaglyph, split-screen or OGL stereo buffers.


Shouldn't it be enough to clear the back buffer once in the beginning of the loop?

Not really, as two back buffers are used to render stereo, you have to clear both after each frame. That's just the cost associated with stereo rendering.

Thanks Momoko_Fan.



I'm looking forward to you releasing the jME context system.



Do you have a working version for JME1.0?

I have already released it, there's a download link at the bottom of the post, it works with jME1.0 currently but I plan to release a jME2.0 version soon.

Yes, but I couldn't find ResourceHelper. Where is that?

Ah, sorry about that… You can just remove all lines associated with it and it will work.