PDA

View Full Version : Problem with ortho: text not being drawn ontop of quad



Structural
01-13-2003, 04:35 AM
I'm trying to make a very simple menu handler and am trying to draw a button-like thingy. However, the text of the button is ALWAYS drawn behind the button. I disabled depth testing, tried to draw the text before the quad aswell as after it... what am I missing?




for (i=0; i< numButtons; i++)
{
if (buttons[i].visible)
{

glRasterPos2f( buttons[i].x, buttons[i].y);

glColor3f(1,1,0);

glBegin(GL_QUADS);
glVertex3f(buttons[i].x, buttons[i].y + buttons[i].h, -1);
glVertex3f(buttons[i].x + buttons[i].w, buttons[i].y + buttons[i].h, -1);
glVertex3f(buttons[i].x + buttons[i].w, buttons[i].y, -1);
glVertex3f(buttons[i].x, buttons[i].y, -1);
glEnd();

glRasterPos2f( buttons[i].x + (buttons[i].w/2), buttons[i].y + (buttons[i].h/2));
glColor3f( buttons[i].r, buttons[i].g, buttons[i].b); //color for text
glCallLists(strlen(buttons[i].text), GL_UNSIGNED_BYTE, buttons[i].text);

}
}

Bob
01-13-2003, 04:55 AM
glRasterPos2f( buttons[i].x + (buttons[i].w/2), buttons[i].y + (buttons[i].h/2));
glColor3f( buttons[i].r, buttons[i].g, buttons[i].b); //color for text

The raster position has it's own color, which is taken from the current color at the point you call glRasterPos. So changing current color with glColor after glRasterPos will not affect the color used by the raster position. When calling, say, glBitmap, the color used may not the color last set by glColor, but the color that was current when glRasterPos was last called.

So in your case, assuming your text is bitmap text, the color of the button and the text will be the same.

[This message has been edited by Bob (edited 01-13-2003).]

Structural
01-13-2003, 05:08 AM
ah... I see... you were right!
I find it a bit odd though... I didn't expect this.

Thanks!

Structural
01-13-2003, 06:31 AM
I'm probably missing something else too...

If I draw more than one button in that loop, it draws all backgrounds fine, but it ONLY draws the last text, on the FIRST button... I mean... huh?

Structural
01-13-2003, 06:44 AM
Nevermind... I failed to increment a counter...