Advertisement

Displaying a bitmap and outline fonts don't work

Started by November 17, 2004 12:58 AM
1 comment, last by rccollins316 20 years ago
I am new to OpenGL programming, so the question I am about to ask may sound dumb to the veterans, but I need to ask it none the less so I can learn. I am trying to show some outline font text just like in NeHe's Lesson 14, and show a bitmap in the background. I used the code from Lesson 6 to load the bitmap, which displays fine, if not a little discolored ( bluish purple colors in the bitmap end up reddish orange when loaded ). But the text, which is supposed to be yellow, is complete black, and the only way I know it is there is because I can see black moving across the bitmap. I figured out that the text turns black when I add the code in the InitGL function to load the bitmap. If I comment it out, the text is fine. What can I do to show both the yellow text and the bitmap?
Most likely your problem is leaving the texture enabled. OpenGL is a state machine. When you enable texturing it remain enabled until you disable it and all objects will be textured. When you supply a texture coordinate it applies to all future vertices until you change it. So if you draw a textured quad and then draw some text your text will be textured using a single pixel from your texture map - the pixel your last glTexCoord call referenced. Disable texturing before you draw the text and reenable it for the quad.

The colour problem with your texture is probably due to the fact that bitmaps are stored in BGR format. Make sure your creating your texture using GL_BGR_EXT as the format, or manually swapping the red and blue channels yourself.

Enigma
Advertisement
Thanks Enigma, you were right. I disabled the texturing before writing the text then enabled it for mapping the quad, and it works. The problem with the colors was that I had to write glColor3f(1.0f, 1.0f, 1.0f); before I drew the texture, then it turned out normal. I guess it was using the yellow color from the text to shade over the texture. Thanks for your help again!

This topic is closed to new replies.

Advertisement