OpenGL Labeling problem

This is a discussion on OpenGL Labeling problem within the Game Programming forums, part of the General Programming Boards category; hi there! in my little game I have some Objects obviously. they all look very similar so I want to ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    9

    OpenGL Labeling problem

    hi there!

    in my little game I have some Objects obviously.
    they all look very similar so I want to implement a method to label them with their name. so i did this:

    Code:
    void MyObject::printName()
    {
        const char *string = "test";
    
        glPushMatrix();
    
        glLoadIdentity();
        double i;
        glLineWidth(0.1);
        glBegin(GL_LINE_STRIP);
        for(i=0;i<2*PI;i+=PI/16)
         	glVertex3d(*fXPos+(radius+0.1)*sin(i),*fYPos+(radius+0.1)*-cos(i),0.0);
       	glVertex3d(*fXPos+(radius+0.1)*sin(0),*fYPos+(radius+0.1)*-cos(0),0.0);
        glEnd();
        glBegin(GL_LINE_STRIP);
       	glVertex3d(*fXPos+(radius+0.1)*sin(12*PI/16),*fYPos+(radius+0.1)*-cos(12*PI/16),0.0);
       	glVertex3d(*fXPos+(radius+0.2),*fYPos+(radius+0.2),0.0);
        glEnd();
        glRasterPos3f(*fXPos+radius+0.2,*fYPos+radius+0.2,0.0);
    
        glColor3f(1.0,1.0,1.0);
        while(*string) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, *string++);
        glPopMatrix();
    }
    this worked pretty well until I added a lightsource.
    now the letters have the same color and shading of the object they are attached to. how can i prevent that???

    thx+regards
    /christian

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    are the objects textured? if so try disabling textures before drawing your text.

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    9
    no I did not use any textures yet but disabling the lighning was a great help!
    would not have thought of it of my own, thnks a lot!



    regards
    /christian

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multithread pthread with OpenGL
    By parad0x13 in forum C++ Programming
    Replies: 8
    Last Post: 07-24-2008, 03:04 PM
  2. SDL_ttf and OpenGL
    By sand_man in forum Game Programming
    Replies: 2
    Last Post: 12-01-2004, 05:06 PM
  3. Problem with OpenGL tutorial
    By 2Biaz in forum Windows Programming
    Replies: 18
    Last Post: 09-16-2004, 11:02 AM
  4. OpenGL lighting
    By BabyG in forum Game Programming
    Replies: 3
    Last Post: 08-29-2004, 09:58 AM
  5. So.. what's the difference between DirectX and OpenGL?
    By QuestionC in forum Game Programming
    Replies: 6
    Last Post: 01-19-2002, 05:18 PM

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