Skip to main content
GameDev.net gamedev.net
🔒 Locked

glutBitmapCharacter help

Started by Quasius Apr 25, 2005 at 10:19 PM 9 replies 14.6k views
Original Post
Quasius
Quasius
Can someone explain to me or tell me where to find exactly what glutBitmapCharacter is doing? The official documentation was not sufficient, as I am still quite confused. First, how do I set the color? It seems to have a mind of its own. Sometime it appears black (useless on a black background) and other times it shows up as other colors. Nether glColor3f nor glClearColor seem to affect it. And when I have the coordinates it's drawn at follow my camera, the text pops in and out of existance depending on how I rotate the camera. All I want is for some text to print and remain in a static position as I move around. This seems like it would be easy, but the (seemingly) erratic behavior of this function is driving me nuts. Thanks for any info. [Edited by - Quasius on April 25, 2005 11:39:10 PM]
nprz
nprz
glColor3f, or glColor3ub, or any of those should change the color of the text. That is how I change the color.
Brother Bob
Brother Bob
nprz is correct that glColor will change the raster color aswell, but you also have to know how glColor interacts with the raster color to not get confused. The raster color is separate from the primary color, and it set at the time glRasterPos is called. When glRasterPos is called, the primary color is copied to the raster color, so changing the primary color AFTER glRasterPos will not change the raster color; you must change the primary color before.
Quasius
Quasius
Then why is this not giving me a red text? The color seems to change depend on where I am looking (which might effect the last color rendered).

void RenderBitmapString(float x, float y, void *font, char *string){    char *c;  glColor3f(1.0, 0.0, 0.0);//print timer in red  glRasterPos2f(x, y);  for (c=string; *c != '\0'; c++)    glutBitmapCharacter(font, *c);}void DisplayTimer(){	int seconds_left;	time_left -= 0.1;	char time_string[5];	seconds_left = ceil(time_left);	itoa(seconds_left, time_string, 10);	RenderBitmapString(5,30,GLUT_BITMAP_TIMES_ROMAN_24, time_string);	if (time_left < 0)//restart level if times up		first_frame = true;}


[Edited by - Quasius on April 27, 2005 12:38:43 AM]
nprz
nprz
so try calling glColor before glRasterPos :)
Quasius
Quasius
Quote:
Original post by nprz
so try calling glColor before glRasterPos :)


Oops. I did actually, and it didn't work. Then just to check, I tried calling it after to see if it worked (it didn't), but I accidently pasted the wrong version. Corrected in above post.
Brother Bob
Brother Bob
Do you have anything enabled that affects the color of a fragment? Like fogging, lighting, texturing, or anything else?
Quasius
Quasius
Quote:
Original post by Brother Bob
Do you have anything enabled that affects the color of a fragment? Like fogging, lighting, texturing, or anything else?


Lighting is enabled. How will that affect it?
Brother Bob
Brother Bob
When lighting is enabled, the primary color is calculated from the lighting equation instead of being taken from glColor and equivalent functions. So instead of setting the raster color with glColor, the last used normal is used in the lighting equation to calculate a new primary color, and that color is used during rasterization.
Quasius
Quasius
Thanks. I just disabled the lighting right before the function call than immediatly renabled it. Now the timer is red. Thanks for the help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.