Advertisement

Bitmapped text issues fun fun fun

Started by June 12, 2003 07:37 PM
4 comments, last by IdahoEv 21 years, 8 months ago
My app is alternating short simulations with instructions to the user, rendered as bitmapped text on a black screen. Sometimes, I want to display text on top of the rendered world, messages to the user during the simulations like ("Congratulations, you found the target!"). I''m using the glPrint() function from tutorial 11. Here are my two issues: 1) Text displays fine the first time I do it on a black screen. But once I''ve switched from that to a world-simulation, the second time I display text on a black screen it ignores the color I specify and draws the text in a dark gray. 2) If I draw any kind of text on top of the rendered world frame after i''ve drawn it, the text draws in the wrong color, and the colors of the world frame suddenly go all funny... all light colors in the entire frame get tinted by the color I''m specifying for the text. I suspect these may be related issues. Before rendering any text, I''m running the following code: glLoadIdentity(); glTranslatef(0.0f,0.0f,-1.0f); glColor3f(red,grn,blu); Also, if I''m just drawing on a black screen I run glClear() first. Is there something else I should be doing to isolate my text drawing, or close down parameters so it quits messing up the colors in the background? Other info: for whatever reason, if I run glPushAttrib() before and glPopAttrib after drawing text, my application crashes at the end of the sim when it tries to release the rendering context, I think it''s an issue with the graphics drivers on this laptop. So for the moment, those lines are commented out of glPrint(). Uncommenting them seems to fix the color of the text on the black screen, but doesn''t help with the tinting of the rendered scene when I draw text on top of it. Any thoughts about other things I could try? Thanks so much for any help. Evan
business: www.lrdesign.compersonal: www.idahoev.com
1) Make sure you have disabled lighting...
2) Make sure you don''t have glEnable(GL_COLOR_MATERIAL) enabled, or reset the color to glColor3f(1.0f, 1.0f, 1.0f) at the beggining of the frame...
Advertisement
Thanks for the tip, James.

That got me much closer. When I reset the color to (1.0,1.0,1.0) at the beginning of each frame where I render the world, the screen no longer tinted funny colors when I drew the text.

However, I still have the problem of all text rendered after I first draw the world gets drawn in a dark gray regardless of what color I specify.

I''ve checked and there are no loose calls to glEnable(). I''m not using lighting.

The only enables I run all the time are GL_TEXTURE_2D and GL_DEPTH_TEST. I have two transparent polygons that I render in the world frame. I enable blending before I draw them, then turn it back off afterwards; that''s my only call to glEnable.

Just for the heck of it I''ll try turning that off, though and see what happens.

Again, thanks... you''ve gotten me much closer.

-Evan
business: www.lrdesign.compersonal: www.idahoev.com
Just a little update: I''ve tried removing all blending from the app now, and making all colors calls to glColor4f(red,green,blue,1.0f) in case blending was the problem, but it didn''t affect the problem that text draws in the wrong color.

Still trying to track it down, any help appreciated.

Cheers,
Evan
business: www.lrdesign.compersonal: www.idahoev.com
Are you using bitmap fonts or fonts loaded from a texture?

If they are bitmap fonts, make sure you disable GL_TEXTURE_2D before rendering them...
I GOT IT!

I had to unbind the last texture I''d bound with glBindTexture(GL_TEXTURE_2D,0).

The bound texture was preventing the text from drawing in the color i was specifying.

Everything works great now.... I just hit alpha-test level of my first contracted programming project! HEE-HAW!

-Evan

business: www.lrdesign.compersonal: www.idahoev.com

This topic is closed to new replies.

Advertisement