Jump to content
  • Advertisement

Archived

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

MARS_999

OpenGL Text with OpenGL

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

I was wondering is it possible to use Windows TextOut() with OpenGL rendering or is that for Windows GUI ()''s only? If not how can I use it with OpenGL. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Ok I got the text working now, but how do I change colors? If I use glColor3f() my textures all become red or green depends on what color I send. I disable the texturing and re-enable it when I am done printing the text. Would using Push() Pop() make a diffence? I don''t think it would, something else seems to be not correct to cause my textures to be the same color. Thanks.

Share this post


Link to post
Share on other sites
I based my text writing code on the font tutorial from gametutorials.com, which lets me change text color with glColor3f(). I doubt glColor3f() will affect TextOut(). If you use TextOut(), there is a way to use the GDI to choose a color, but I''m not quite up to snuff on GDI, so I''d have to refer you to the MSDN.

I''d recommend going over a font tutorial from nehe.gamedev.net or www.gametutorials.com, though. Then you could just glColor3f() to your text color, and if you had more rendering to do, glColor3f() back to white, or whatever color you need.

yckx

Share this post


Link to post
Share on other sites
quote:
Original post by yckx
I based my text writing code on the font tutorial from gametutorials.com, which lets me change text color with glColor3f(). I doubt glColor3f() will affect TextOut(). If you use TextOut(), there is a way to use the GDI to choose a color, but I''m not quite up to snuff on GDI, so I''d have to refer you to the MSDN.

I''d recommend going over a font tutorial from nehe.gamedev.net or www.gametutorials.com, though. Then you could just glColor3f() to your text color, and if you had more rendering to do, glColor3f() back to white, or whatever color you need.

yckx


Thanks for the reply, I am using NeHe''s tutorial but modified it a bit. It displays text fine but when I use glColor3f() my textures also turn that color? Odd must have a () or setting not set correctly? Thanks

Share this post


Link to post
Share on other sites
quote:
Original post by MARS_999
It displays text fine but when I use glColor3f() my textures also turn that color?

When you set the color, all vertices are rendered with that color (until you change the color). By default, textured primitives are affected by the current color too. Setting the color to white (all 1.0) is an easy way to make things appear unmodified.

Share this post


Link to post
Share on other sites
try using wglUseFont.... um not too sure about the name though, but there is a function like wglUseFont which does exactly wot u are looking for.... good luck !

Share this post


Link to post
Share on other sites
quote:
Original post by Null and Void
[quote]Original post by MARS_999
It displays text fine but when I use glColor3f() my textures also turn that color?

When you set the color, all vertices are rendered with that color (until you change the color). By default, textured primitives are affected by the current color too. Setting the color to white (all 1.0) is an easy way to make things appear unmodified.



Which color are you talking about? I set the glClearColor(0.0f, 0.0f, 0.0f, 0.0f); to white and that did nothing? When I use glColor3f( and set it to red) my whole screen is red. I even have glDisable(texturing) after I render the scene and before I do the text? Is it not possible to use glColor3f() when your using textures?

Share this post


Link to post
Share on other sites
That shouldnt have been your problem...your problem seemed to be lack of understanding that opengl is a state machine. if you change the color, it will apply to everything until you change it to something else...clear color is the background, but your textures will be affected by color calls, which is how it works to change color in the first place.

Brian

Share this post


Link to post
Share on other sites
quote:
Original post by Null and Void
When you set the color, all vertices are rendered with that color (until you change the color). By default, textured primitives are affected by the current color too. Setting the color to white (all 1.0) is an easy way to make things appear unmodified.



Yeah, and watch out for this one. When working with raster drawing functions like glBitmap() and calllists generated by wglUseFontBitmaps(), calls to glColor*() don''t take effect for raster functions until after a call to glRasterPos*(). So if you set the raster position then set the color and try drawing text, you''ll end up with text the wrong color.

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!