Glut colors and text: Help pls.

Started by
0 comments, last by Shadow Mint 23 years, 10 months ago
Simple question really: how do I change the color of the text I''m drawing using glutBitmapCharacter and how do I set the position for the text in the window? The glut spec donts seem to have anything useful on these; except possibly glutSetColor, which gives me: GLUT: Warning in flower: glutSetColor: current window is RGBA When I run it. Useful: Text is still plain white. =( Anyone know how to do this? Thanks!
Advertisement
Hi Shadow Mint,
Since the glut bitmap characters are only 2D-Pixels you have to set their position with glRasterPos3f(GLFLOAT x,GLFLOAT y,GLFLOAT z); You need the z Value because OpenGL will render it also into the z-Buffer. So the z-Value should be negative. So the position of the font depends on the view frustum. You should try it with x and y set to zero! Then try 0.05 or 0.025 , maybe they are already offscreen then.

After every character of the glut font the glut will move the current raster position one step in the positive x-direction. So you only have to watch for

To set the color you just call glColor..();. And here is the problem: When you also use textures, OpenGL will combine the color and the color of the current texture coordinate to draw the pixels. So either create a bright white small texture, and set the coordinate to the middle of the texture, or you disable the textures before you draw.

Hint: You should think about texture based fonts.

This topic is closed to new replies.

Advertisement