🔒 Locked
glutBitmapCharacter help
Advertisement
Original Post
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]
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]
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]
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.
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).
[Edited by - Quasius on April 27, 2005 12:38:43 AM]
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]
Do you have anything enabled that affects the color of a fragment? Like fogging, lighting, texturing, or anything else?
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement