Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
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  
  2D Overlay on 3D Rendering  (Read 1387 times)
0 Members and 1 Guest are viewing this topic.
Offline kernelpanic

Junior Newbie





« Posted 2006-01-24 23:15:05 »

I am attempting to render some textured Quads in the front of the canvas. I was able to do this using plain JOGL with the following:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
      gl.glMatrixMode(GL.GL_PROJECTION);
      gl.glPushMatrix();
      glu.gluOrtho2D(0,Constants.WINDOW_WIDTH,0,Constants.WINDOW_HEIGHT);
                 //Render

      gl.glBindTexture(GL.GL_TEXTURE_2D,TextureTools.getHudRadar());
      gl.glBegin(GL.GL_QUADS);
      gl.glTexCoord2f(0,1);
                gl.glVertex2f(Constants.HUD_POS_RADAR_REAR_X,Constants.HUD_POS_RADAR_REAR_Y);
      gl.glTexCoord2f(0,0);
                gl.glVertex2f(Constants.HUD_POS_RADAR_REAR_X,Constants.HUD_POS_RADAR_REAR_Y-Constants.HUD_SIZE_RADAR);      
                gl.glTexCoord2f(1,0);
               gl.glVertex2f(Constants.HUD_POS_RADAR_REAR_X+Constants.HUD_SIZE_RADAR,Constants.HUD_POS_RADAR_REAR_Y-Constants.HUD_SIZE_RADAR);
      gl.glTexCoord2f(1,1);
                gl.glVertex2f(Constants.HUD_POS_RADAR_REAR_X+Constants.HUD_SIZE_RADAR,Constants.HUD_POS_RADAR_REAR_Y);
      gl.glEnd();      


                gl.glPopMatrix();
      gl.glMatrixMode(GL.GL_MODELVIEW);


How would I go about doing this with Xith? I've been trying variations of the following:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
      BranchGroup hud = new BranchGroup();
      Transform3D t = new Transform3D();
      t.ortho(0,1024,0,768,0,1);
      hud.setTransformGroup(new TransformGroup(t));

      Point3f [] coords = new Point3f[] {
            new Point3f(0,0,-1f),
            new Point3f(0,128,-1f),
            new Point3f(128,128,-1f),
            new Point3f(128,0,-1f)
      };

      QuadArray qA = new QuadArray(coords.length,GeometryArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
      qA.setCoordinates(0,coords);
      Appearance a = new Appearance();
      a.setColoringAttributes(new ColoringAttributes(new Color3f(1,1,1),ColoringAttributes.SHADE_FLAT));
      Shape3D s = new Shape3D(qA,a);
      hud.addChild(s);


The quad renders at a clearly incorrect size. I have a feeling that it has something to do with the distance of the quad from the camera (-1f, in this case) as the original used Vertex2f, and had no Z component. Any suggestions?
Offline jaakko777

Senior Newbie





« Reply #1 - Posted 2006-01-24 23:56:10 »

There is this quite recent thread that you might find useful: http://www.java-gaming.org/forums/index.php?topic=10611.0
Offline kernelpanic

Junior Newbie





« Reply #2 - Posted 2006-01-25 00:07:14 »

The foreground node is working fine, I just need to sync the coordinates up with the screen. Setting a Transform3D ortho is giving me bad results. If i have a 1024x768 screen, doing a trans.ortho(0,1024,0,768,0,1) stretches the y-axis (to make up for the difference, I guess). Other than this problem, it doesn't seem necessary to do the double-rendering job that the thread you suggested is proposing.
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.

xsi3rr4x (50 views)
2014-04-15 18:08:23

BurntPizza (46 views)
2014-04-15 03:46:01

UprightPath (62 views)
2014-04-14 17:39:50

UprightPath (44 views)
2014-04-14 17:35:47

Porlus (61 views)
2014-04-14 15:48:38

tom_mai78101 (84 views)
2014-04-10 04:04:31

BurntPizza (142 views)
2014-04-08 23:06:04

tom_mai78101 (242 views)
2014-04-05 13:34:39

trollwarrior1 (201 views)
2014-04-04 12:06:45

CJLetsGame (208 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!