Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Text color problem

  1. #1
    Intern Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    78

    Text color problem

    i'm puting a bitmap text into my project and I'm unable to correctly change the color of it
    code:
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glDisable(GL_DEPTH_TEST);
    glOrtho(-1.0f,1.0f,-1.0f,1.0f,1.0f,-1.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glColor3f(1.0f,1.0f,1.0f);
    glRasterPos3f(-0.8f,0.8f,0.0f);
    while(*p!='\0') glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,*p++) ;
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glEnable(GL_DEPTH_TEST);
    gluPerspective(60,ratio,0,200);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glColor3f doesn=t work correctly -i've got only dark green and black color

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: Text color problem

    Make sure your rasterpos is called after your color in your actual code.

  3. #3
    Intern Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    78

    Re: Text color problem

    rasterpos is called after glcolor as you can see in code(just copy and paste) and it's working but only those 2 colors

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,652

    Re: Text color problem

    But dorbie is right

    The raster position attributes, just like vertex attributes (color, fog coord, tex coords) 'latch' into place when the glRasterPos call is issued. Calling glColor after glRasterPos has no effect (except, of course, for subsequent glRasterPos/glVertex calls).

  5. #5
    Intern Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    78

    Re: Text color problem

    It's working now but i've got a problem with white color i think it should be 1,1,1 but i always get green-my last texture before i do bitmap operations is green could that be somehow connected to that?

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,652

    Re: Text color problem

    Pixel transfers (glDrawPixels/glBitmap) are affected by the complete fragment processing stuff, ie textures, fog, blending, alpha test. Texturing and fog probably have little utility in most cases, but that's how it is.

    So you need to (temporarily) disable what you don't need.

  7. #7
    Intern Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    78

    Re: Text color problem

    Thanks a lot with disabled texture_2d it's working fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •