• Advertisement
Sign in to follow this  

glutBitmapCharacter help

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

If you intended to correct an error in the post then please contact us.

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 this post


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

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
so try calling glColor before glRasterPos :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Thanks. I just disabled the lighting right before the function call than immediatly renabled it. Now the timer is red. Thanks for the help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement