PDA

View Full Version : Color of bitmap text being ignored



DalTXColtsFan
04-15-2003, 05:57 PM
I have a sample of combining ortho mode with projection mode (for example, to do the border around the screen a la Quake or Doom) here:
http://home.att.net/~tennisman2/TryingToCombine.zip

But I have a problem: It's ignoring my call to glColor3f when I draw the bitmap text. No matter what I set the text comes out the same color. Here's a code snippet:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); glLoadIdentity();
glOrtho(0.0f, width - 1.0, 0.0, height - 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW); glLoadIdentity();
glRasterPos2i(20,20);
glTranslatef(0.0f, 0.0f, 1.0f);
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, textures[1]);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glTexCoord2f(1.0, 0.0);
[snip]
glVertex3f(200, 200 + bitmapData->sizeY, 0);
glEnd();
glColor3f(1.0f, 0.0f, 1.0f);
PrintString(listBase, "OpenGL Bitmap Fonts!");
glEnable(GL_DEPTH_TEST);

Any ideas? I'd appreciate them!

Old GLman
04-15-2003, 08:41 PM
You have to tell OpenGL to use the primitives color rather than the textures.
So make sure the texture mode is set to GL_MODULATE and then use blending. Set the destination blend function to GL_ZERO and the source to GL_ONE. This is actually what OpenGL defaults so you should just be able to enable blending.

Old GLman

Brian Jones
04-15-2003, 08:42 PM
Bitmap font? If you're using glRasterPos to place the font, you need to set the color before calling glRasterPos.

DalTXColtsFan
04-15-2003, 08:57 PM
Brian - your suggestion did it. Thanks!