Stereo images with jogl 2

Hi guys, I’m a newbie. This is a really helpful forum, congrats! :wink:

My knowledge of jogl is very poor so I need some advice.
I have a 120 Hz monitor, an Nvidia Quadro FX4800 and the 3dvision stereo kit. I’m writing an application capable of displaying two different images (jpg) at the same time on a single GLCanvas (of course, one to the left eye and the other one to the right eye). Is it hard to do with jogl 2?
I’ve read about quad buffering but have no idea how I could manage it.
Meanwhile the portion of code I’ve written is able to show only one image to both eyes on my GLCanvas (there’s no need to use the 3d glasses indeed):

@Override
	public void display(GLAutoDrawable drawable) {
		GL2 gl = drawable.getGL().getGL2();
		
		gl.glMatrixMode(GL2.GL_PROJECTION); 
		gl.glLoadIdentity();
		gl.glOrtho(0, image.getWidth(), image.getHeight(), 0, 0, 1); 
		
                gl.glMatrixMode(GL2.GL_MODELVIEW); 
		gl.glDisable(GL2.GL_DEPTH_TEST);		
		gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); 
		gl.glClear(GL2.GL_COLOR_BUFFER_BIT); 
		gl.glBlendFunc (GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); 
		
		gl.glEnable (GL2.GL_BLEND); 

		WritableRaster raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, w, h, 4, null);

		ComponentColorModel colorModel=
			new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),
					new int[] {8,8,8,8},
					true,
					false,
					ComponentColorModel.TRANSLUCENT,
					DataBuffer.TYPE_BYTE);

		BufferedImage dukeImg = new BufferedImage (colorModel, raster, false, null);

		Graphics2D g = dukeImg.createGraphics(); 
		g.drawImage(image, null, null); 
		
		DataBufferByte dukeBuf = (DataBufferByte)raster.getDataBuffer(); 
		byte[] dukeRGBA = dukeBuf.getData();
		ByteBuffer bb = ByteBuffer.wrap(dukeRGBA);
		bb.position(0); 
		bb.mark();

		gl.glBindTexture(GL2.GL_TEXTURE_2D, 13); 
		gl.glPixelStorei(GL2.GL_UNPACK_ALIGNMENT, 1);
		gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_CLAMP);
		gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_CLAMP);
		gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
		gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_LINEAR);
		gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE);
		gl.glTexImage2D (GL2.GL_TEXTURE_2D, 0, GL2.GL_RGBA, w, h, 0, GL2.GL_RGBA, 
				GL2.GL_UNSIGNED_BYTE, bb);
		
		int left = 1;
		int top = 1;
		
		gl.glEnable(GL2.GL_TEXTURE_2D);
		gl.glBindTexture (GL2.GL_TEXTURE_2D, 13);
		
		gl.glBegin(GL2.GL_POLYGON);
		gl.glTexCoord2d (0, 0);
		gl.glVertex2d (left,top);
		gl.glTexCoord2d(1,0);
		gl.glVertex2d (left + w, top);
		gl.glTexCoord2d(1,1);
		gl.glVertex2d (left + w, top + h);
		gl.glTexCoord2d(0,1);
		gl.glVertex2d (left, top + h);
		gl.glEnd();	
		gl.glFlush();	
	}

I think I will have to radically modify the code, right?

Attention: I do NOT want to achieve the tridimentional view of the image but I only want to display two images at the same time using 3dvision stereo glasses.

Thanks. :wink:

Hi

Look at glColorMask. There are plenty example of stereo vision in OpenGL on the web, for example in the FAQ of opengl.org.

I have never done it but you just have to fill two back buffer (GL_BACK_LEFT and GL_BACK_RIGHT).
Take a look there.

NVidia driver is really a lame with S3D and OpenGL. It was working far better … 10 year ago :-\ (Quatro card was not need for fullscreen S3D).