Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Shadow Mint

Glut colors and text: Help pls.

This topic is 6609 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

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!

Share this post

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

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!