Color problem cause by texture loading
Hello,
I wrotte an application that :
1) Draw an animated background that is a quad using a texture in 3D,
2) Draw foreground information that are text and rectangle in 2D.
My problem is that without image loaded in the background, colors of the foreground are correct (texts and rectangles). When I load an image, the text colors are correct, but rectangles colors changes (colors depend on the image loaded).
- To load images I use the library glBMG,
- To draw text I apply code of lesson #13 that use list (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=13)
- To draw rectangle, I use instruction GL_BEGIN (GL_LINE_LOOP) ...
- To set the colors of texts and rectangles I use instruction glColor4f(...
I am working with RGBA color mode, but it seems that colors are indexed because of the binded image. I've tried with 8 bits,16 bits and 24 bits color images but it gives the same result. I am also surprise that it works with text, but not for rectangle. (Can it be because text print use base list ?)
I am really in the haze, can somebody help me ?
Loic
Complement of information :
When I disable texturing before the 2D instructions that draw rectangles - glDisable(GL_TEXTURE_2D) - I have the good colors, but transparency (blending) is done using black color and not with the background image (this draw a black rectangle over the image when alpha is 0).
When I disable texturing before the 2D instructions that draw rectangles - glDisable(GL_TEXTURE_2D) - I have the good colors, but transparency (blending) is done using black color and not with the background image (this draw a black rectangle over the image when alpha is 0).
OpenGL is a state machine. When you enable or set a state it remains enabled or set until to disable, unset to change it. So when you render a textured quad and then continue rendering without disabling texturing every subsequent vertex is rendered textured and with the last set texture coordinate. So all of your objects are rendered and textured with a single texel from your last bound texture map, which will be whichever texel was indexed by the last glTexCoord call. I'm afraid I didn't quite get what you meant with the blending problem, so I can't help there. Could you try explaining again please (maybe with pictures if you're able to host them somewhere)?
Enigma
Enigma
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement