Archived

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

Jaw959

Trouble with glColor3f

Recommended Posts

The following code draws a cube (with a texture) in the upper left, a square (with a texture) in the upper right, and 3D text on the bottom. (I got 3D text code from lesson 14. Everything else is standard basecode.) Here is my problem, the text is supposed to be the only thing that cycles through the colors, but the cube and the squares have the same color shading. Please tell me how to fix this. This is my drawglscene code. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glTranslatef(2.0f,1.0f,-10.0f); glBindTexture(GL_TEXTURE_2D, texture[1]); glBegin(GL_QUADS); These lines ommitted to save space. glEnd(); glDisable(GL_TEXTURE_2D); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glTranslatef(-2.0f,1.0f,-10.0f); glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(yrot,0.0f,1.0f,0.0f); glRotatef(zrot,0.0f,0.0f,1.0f); glBindTexture(GL_TEXTURE_2D, texture[0]); glBegin(GL_QUADS); These lines ommited to save space. glEnd(); glDisable(GL_TEXTURE_2D); glLoadIdentity(); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glColor3f(1.0f*float(cos(xrot/20.0f)),1.0f*float(sin(xrot/25.0f)),1.0f-0.5f*float(cos(xrot/17.0f))); glTranslatef(0.0f,-3.0f,-10.0f); glPrint("Loading, please wait..."); glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); glLoadIdentity(); xrot+=0.3f; yrot+=0.2f; zrot+=0.4f; return true;

Share this post


Link to post
Share on other sites
since i have no way of knowing what "glPrint" is, i''ll assume it drawing text through the fragment pipeline.
disable lighting and color material before calling "glPrint".

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites
I think this is what is wrong, you have a multi-colored text thing that makes the cubes the same color?

If so, it is probably happening since you have that glColor3f in that last part of the code, and it is not changed when you go to the cubes, so the cubes use the color that is set.

You should either specify a color, or (this is probably the better one) make this call:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

I had this problem once where my textures were tinted the color that was last used. This fixes it by telling OpenGL to replace (GL_REPLACE) the color with just the texture.

Hope this helps.

Share this post


Link to post
Share on other sites