Public Group

# glutBitmapCharacter help

This topic is 4927 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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]

##### Share on other sites
Nevermind. I founf the answere here: http://www.lighthouse3d.com/opengl/glut/index.php?bmpfontortho

edit: actually, that just answers 1 of my question. I would still like to know how to set the color it outputs in. Thanks.

[Edited by - Quasius on April 25, 2005 11:57:42 PM]

##### Share on other sites
glColor3f, or glColor3ub, or any of those should change the color of the text. That is how I change the color.

##### Share on other sites
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.

##### Share on other sites
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]

##### Share on other sites
so try calling glColor before glRasterPos :)

##### Share on other sites
Quote:
 Original post by nprzso 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.

##### Share on other sites
Do you have anything enabled that affects the color of a fragment? Like fogging, lighting, texturing, or anything else?

##### Share on other sites
Quote:
 Original post by Brother BobDo 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?

##### Share on other sites
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.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
18

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632998
• Total Posts
3009805
• ### Who's Online (See full list)

There are no registered users currently online

×