Archived

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

KappaMic

Colors change!! WHY?????

Recommended Posts

THE PROBLEM IS SIMPLE... 1) I DRAW A CUBE WITH SOME BITMAPS ***2) I SET A COLOR FOR A TEXT TO BE DISPLAYED 3) I DRAW THE TEXT BUT THE COLOR OF MY BITMAPS CHANGE!!! HOW CAN I DO THE SAME THING WITHOUT CHANGING THE COLOR OF MY BITMAPS??? (SORRY FOR MY ENGLISH...)

Share this post


Link to post
Share on other sites
look for the gameloop, there is happening this:

bitmap with normal color
color changed
text in color
loopback
bitmap with -- changed color!!

means
before drawing bitmap, you have to set color back to standart

glColor4f(1,1,1,1);

so

color to white
bitmap with normal color
color changed
text in changed color
loopback
color to white
bitmap with normal color

and so on

we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites
Doesn''t seem to work...

Here''s the code

my loop is this:

start of loop:

glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity()
glDisable(GL_DEPTH_TEST);

draw my bitmaps

glColor3f(0,1,0); // here i set the color of the font
glPrint(''ahahahaha'');
glColor4f(1,1,1,1);

goto start of loop
end of loop



Now it''s the text font to change!!!! I what a green text!!!!

mmmm.... What''s wrong ????

Share this post


Link to post
Share on other sites
ah ok
when the text is a texture, what he normaly is, you have to enable colored material. and that could you do with
glEnable(GL_COLOR_MATERIAL);
in the glInit();, or so

we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites
before drawing the text, do
glDisable(GL_TEXTURE_2D);
then set your color
glColor(0,1,0); //wrong, i know
and then draw your text
Print("Green Text");

we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites
don''t ask me why....
but this code works!!!

glLoadIdentity();
glTranslatef(-3,3.5,-10);
glRotatef(rtextx,1.0,0.0,0.0);
rtextx:=rtextx-1;

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glDisable(GL_TEXTURE_2D);
glColor3f(0.5,0,0);
glPrint(''Il gioco della vita'');
glColor4f(1,1,1,1);
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
glDisable(GL_COLOR_MATERIAL);


mmm.... i don''t know why... but it works!!!

Many Thanks



Share this post


Link to post
Share on other sites
when you have enabled GL_TEXTURE_2D, it always draw a texture, and, when you dont give texcoords, it uses for all the same ([0,0], i think), and so your model gets the color of this pixel at [0,0](when its this one), and not the one of glColor.. so you have to disable the texture bevor drawing without

we wanna play, not watch the pictures

Share this post


Link to post
Share on other sites