Thread: OpenGL Problems(again)

  1. #1
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039

    OpenGL Problems(again)

    I'm yet again having opengl problems...but this one is really simple

    Say I'm zooming in and out a polygon and in front of it is static text. like it's x and y positions. As you zoom the polygon in, it is able to get so close that is makes the text in front dissappear. Is there a way to make the front text truly static? like on the very top layer? thanks

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    What about drawing your text after all of your geometry has been drawn? That usually works fine for me.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    I do, I'm using Nehe's 3d bitmap text. I use glprint at the way end of my DrawGLScene(). And the polygons zoom so close that for SOME reason, it still goes straight through the text!
    here a copy and paste of the end of my drawglscene

    Code:
    	glLoadIdentity();
    	glTranslatef(-1.0f,-1.2f,-1.0f);
    		glNormal3f( 0.0f, 0.0f, 1.0f);
    	glBegin(GL_QUADS);						// Draw A Quad
    		glVertex3f(-1.0f, 1.0f, 0.0f);				// Top Left
    		glVertex3f( 1.0f, 1.0f, 0.0f);				// Top Right
    		glVertex3f( 1.0f,-1.0f, 0.0f);				// Bottom Right
    		glVertex3f(-1.0f,-1.0f, 0.0f);	
    	glEnd();
    	
    /*	CXPOS(-2.0f,-0.5f,-2.0f);
    	CXPOS(-2.0f,2.0f,0.5f);
    	CXPOS(2.0f,-0.5f,-2.0f);
    	CXPOS(2.0f,2.0f,0.5f);
    	CZPOS(-2.0f,-0.5f,-2.0f);
    	CZPOS(-2.0f,2.0f,0.5f);
    	CXPOS(-2.0f,2.0f,0.5f);
    */
    
    		
    	glLoadIdentity();
    
    
    		glTranslatef(0.0f,0.0f,-1.0f);
    	glColor3f(255,0,0);
    	glRasterPos2f(-0.55f,-0.4);
     	glPrint("Y-ROT: %f",yrot);
    	glRasterPos2f(-0.55f,-0.3);
    	glPrint("X-POS: %f",xpos);
    	glRasterPos2f(-0.55f,-0.35);
    	glPrint("Z-POS: %f",zpos);
    	
    	return TRUE;
    that polygon alone totally overlaps the text.
    EDIT: and to avoid confusion, that polygon that covers the text can also be overlapped by another polygon zoomed in and drawn before. That's really weird, how come polygons you draw before others can still overlap as if they're the top layer?
    Last edited by Xterria; 06-02-2004 at 09:20 PM.

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Try just turning off depth comparisons. What you are experiencing is z-fighting. So you need to tell opengl to always draw the text and disregard that a part of a polygon is in fact closer.

    glDisable( GL_DEPTH_TEST );

    Just remember to re-enable it when you're done.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  5. #5
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    YES! mr wizard, i'm telling you right now, this is the third time you've helped me really fast. you really are a wizard.

    and my new best friend(again!)
    http://cboard.cprogramming.com/showthread.php?t=49608

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Also the first text tutorial at NeHe (not the 3d font one) makes the text static I think.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  2. OpenGL Problems(again)
    By Xterria in forum Game Programming
    Replies: 8
    Last Post: 06-23-2004, 01:21 PM
  3. OpenGL Problems(again)
    By Xterria in forum Game Programming
    Replies: 2
    Last Post: 03-28-2004, 06:46 PM
  4. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM