I’m drawing text to the screen as follows:
(a) I have a 2D array of chars, initially containing all periods (so I can see what’s going on).
(b) I’ve made a set of display lists for a stroke font using wglUseFontBitmaps.
© I also have an array of color values (structs of 3 GLfloats) of the same size as the character array (i.e. each character has its own color). I originally initialize this array to all white.
I throw each row into the following code to draw it (modified NeHe code), shift down, repeat, and so on to draw the entire array:
glPushAttrib(GL_LIST_BIT);
glListBase(font_base - 32);
for (int i = 0; i < width; ++i)
{
glColor3f(color[i].r, color[i].g, color[i].b); // sets the color
glCallLists(1, GL_UNSIGNED_BYTE, (text+i)); // Draws The Display List Text
}
glPopAttrib();
The correct characters are showing up in the right positions. The problem is that the colors aren’t showing up accurately: whatever color I set all the characters to in the beginning persists - changing the color of a particular character doesn’t make a difference. Note that I don’t call glColor3f or any other OpenGL color-changing function anywhere outside this snippet of code - all other “color changes” are merely changes to the aforementioned 2D array. I’ve used a debugger to make sure that glColor3f does, in fact, get called with the correct RGB values right before glCallLists is called with the corresponding character.
Any suggestions would be quite helpful.