Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Stereo images with jogl 2  (Read 1429 times)
0 Members and 1 Guest are viewing this topic.
Offline sk8tzor

Innocent Bystander





« Posted 2011-01-31 12:32:47 »

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):

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
@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
Offline gouessej
« Reply #1 - Posted 2011-01-31 23:42:45 »

Hi

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

Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #2 - Posted 2011-02-01 08:12:35 »

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  Undecided (Quatro card was not need for fullscreen S3D).
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (75 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (46 views)
2014-11-29 21:32:03

toopeicgaming1999 (113 views)
2014-11-26 15:22:04

toopeicgaming1999 (100 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!