Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  2d over 3d gone missing.  (Read 443 times)
0 Members and 1 Guest are viewing this topic.
Offline deepdiver

JGO n00b
*

Posts: 15



« on: 2008-04-06 12:55:45 »

Hi Guys,

I'm trying to draw a 2D line from a 3D point on a 3D object to a 2D text label that I'm rendering with the textRender package.

below is the code I'm using which draws absolutely nothing visible???

Could somebody explain why.

           textRenderer.beginRendering(drawable.getWidth(), drawable.getHeight());
           textRenderer.setColor(c, c, c, 1.0f);
           textRenderer.draw(it.name, x+ 20, y );
           textRenderer.endRendering();
           gl.glMatrixMode(GL.GL_PROJECTION);
           gl.glPushMatrix();
           gl.glLoadIdentity();
           glu.gluOrtho2D(0, drawable.getHeight(), 0, drawable.getWidth());
           gl.glColor4f(0.5f,1.0f,0.5f, 1.0f);
           gl.glBegin(GL.GL_LINES);
           gl.glVertex2i(x, y);
           gl.glVertex2i(x+20, y);
           gl.glEnd();
           gl.glPopMatrix();

By the way the textRenderer works a treat - just to let you know that all the hard work is much appreciated!
It's just my little line that's missing.
Thanks

Chris

Oh well... got up this morning and saw my obvious mistakes. What I should have done was:

           gl.glMatrixMode(GL.GL_PROJECTION);
           gl.glPushMatrix();
           gl.glLoadIdentity();
           gl.glMatrixMode(GL.GL_MODELVIEW);
           gl.glPushMatrix();
           gl.glLoadIdentity();
           glu.gluOrtho2D(0, drawable.getWidth(), 0, drawable.getHeight() );
           gl.glColor4f(0.5f,1.0f,0.5f, 1.0f);
           gl.glBegin(GL.GL_LINES);
           gl.glVertex2i(x, y);
           gl.glVertex2i(x+20, y);
           gl.glEnd();
           gl.glPopMatrix();
           gl.glMatrixMode(GL.GL_PROJECTION);
           gl.glPopMatrix();
           gl.glMatrixMode(GL.GL_MODELVIEW);

Sorry for wasting everyones time.
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.096 seconds with 21 queries.