OpenGL Problems(again)

This is a discussion on OpenGL Problems(again) within the Game Programming forums, part of the General Programming Boards category; I'm yet again having opengl problems...but this one is really simple Say I'm zooming in and out a polygon and ...

  1. #1
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035

    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
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    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
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    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!)
    TextOut() flickering

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    1,199
    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, 05:46 PM
  4. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 06:57 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21