Re: How to enable quad-buffered stereo rendering
Posted by Justin on Jul 08, 2010; 3:26am
URL: https://forum.jogamp.org/How-to-enable-quad-buffered-stereo-rendering-tp938684p950730.html
I work with a similar setup, except we have a Quadro FX 1800 which is not supported by Linux yet. I'm stuck with Windows for now, but I'm familiar with quad-buffered stereo in JOGL applications. Maybe I missed it or doing it a way I haven't tried, but when you say you set GLCapabilities.setStereo(true), you're adding that GLCapabilities object to the GLCanvas' constructor right? Also, I believe in Linux you must set a "stereo" flag in the xorg.conf file. Anyway, I can provide some code that works under Windows to help narrow down your problem:
--------------------------------------------------
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.*;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;
import com.jogamp.opengl.util.FPSAnimator;
import com.jogamp.opengl.util.gl2.GLUT;
public class StereoTest implements GLEventListener {
private GLU glu = new GLU();
private GLUT glut = new GLUT();
public static void main(String[] args) {
StereoTest stereoTest = new StereoTest();
GLCapabilities glCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2));
glCaps.setStereo(true);
GLCanvas canvas = new GLCanvas(glCaps);
canvas.addGLEventListener(stereoTest);
final Frame frame = new Frame("Stereo Test");
frame.add(canvas);
frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
final FPSAnimator animator = new FPSAnimator(canvas, 60);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
animator.stop();
frame.dispose();
System.exit(0);
}
});
frame.setVisible(true);
animator.start();
canvas.requestFocusInWindow();
}
public void init(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(45.0f, 800/600.0f, 1, 100);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(0, 0, 4, 0, 0, 0, 0, 1, 0);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glEnable(GL2.GL_LIGHTING);
gl.glEnable(GL2.GL_LIGHT0);
}
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
gl.glDrawBuffer(GL2GL3.GL_BACK_LEFT);
gl.glClear(GL.GL_COLOR_BUFFER_BIT |GL.GL_DEPTH_BUFFER_BIT);
gl.glPushMatrix();
gl.glTranslated(-0.2, 0, 0);
drawScene(gl);
gl.glPopMatrix();
gl.glDrawBuffer(GL2GL3.GL_BACK_RIGHT);
gl.glClear(GL.GL_COLOR_BUFFER_BIT |GL.GL_DEPTH_BUFFER_BIT);
gl.glPushMatrix();
gl.glTranslated(0.2, 0, 0);
drawScene(gl);
gl.glPopMatrix();
}
private void drawScene(GL2 gl) {
glut.glutSolidTeapot(1);
}
public void dispose(GLAutoDrawable drawable) {}
public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {}
}