Advertisement

Colors Chaning material colors...?

Started by February 01, 2005 11:37 AM
1 comment, last by iddqd42 19 years, 10 months ago
Hi. I have drawn a quad and applied a 256x256 (32bit) bmp texture to it. This worked fine and all the colors turned out just as on the bmp... now, a few lines under i wanted to add some text with a color (ex.red, doesnt really matter... ;)) However, what ever color i choose for the text makes the material on my quad change to that color (the texture is still there, just odd color...) How can i fix this? Oh, my code for drawing text is just a modified lesson 14 atm... (and im using glOrtho, not perspective) <code> glLoadIdentity(); glTranslatef(14.0f, 8.0f, 0.0f); glBindTexture(GL_TEXTURE_2D, uTextures[MENU]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(10.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(10.0f, 18.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, 18.0f, 0.0f); glEnd(); // ... glDisable(GL_TEXTURE_2D); // Just experementing ;) glLoadIdentity(); glTranslatef(5.0f,5.0f,20.0); glRotatef(180.0f,1.0f,0.0f,0.0f); glColor3f(255.0f, 0.0f, 0.0f); glPrint("Testing..."); glEnable(GL_TEXTURE_2D); // Just experementing ;) </code> btw, if this attemt to add code to a forum doesnt work... how do i do it? =) Thanks for reading // iddqd. ------
The more you know, the more you know that you dont know.
Color is a state. You set color to red so it stays red until you change it : in your case, never, so you always have red color applied. You need something like:
...glColor3f( 1.0f, 1.0f, 1.0f ); // white...draw textued quad...glColor3f( 1.0f, 0.0f, 0.0f ); // red...draw text...


One more thing about your code. Colors in float format have ranges form 0.0 to 1.0. They are in 0 to 255 range only if you use unsigned bytes. glColor3ub();

Check out Forum FAQ on how to post code.
You should never let your fears become the boundaries of your dreams.
Advertisement
Ah, thanks a lot darkwing =)
The more you know, the more you know that you dont know.

This topic is closed to new replies.

Advertisement