Advertisement

glColor3ub problem?

Started by September 27, 2004 05:38 PM
1 comment, last by Steve132 20 years, 2 months ago
the problem im having is that i am drawing my model and then im drawing a 3d grid underneath it to simulate a floor so i can work on tracking the model animations. the grid is colored green but when i run the program everything including my model is green. the textures are still there but they are shaded green. this is my rendering function. can anyone tell me whats wrong with it? void CMain::Draw() { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); theCamera.Look(); glPushMatrix(); glScalef(0.05f, 0.05f, 0.05f); theModel.DrawModel(); glPopMatrix(); glColor3ub(0, 255, 0); for(float i = -50; i <= 50; i += 1) { glBegin(GL_LINES); glVertex3f(-50, 0, i); glVertex3f(50, 0, i); glVertex3f(i, 0, -50); glVertex3f(i, 0, 50); glEnd(); } glFlush (); } thanks alot.
Because the current OpenGL colour is green when it comes to rendering the model ( from the previous frame ), unless theModel.DrawModel(); changes the colour of course. If you don't want the green to propogate onto the model, either put a glColour3ub( 255, 255, 255 ) before you draw the model, or change the texture env function to GL_DECAL.
If at first you don't succeed, redefine success.
Advertisement
This one isn't to bad of a bug.

OpenGL is a state machine, and any states you set (such as Color) persist until you set them to something else.

I am assuming that
you want your models to stay the color they were originally, that is, not tinited green?

I could be wrong, but I dont think that glFlush parses all of the states bacj to their perfect defaults.

therefor, the way you have it now it should work right the first frame, but every time after that the current color as the model is drawn is 0,255,0 (green tint :) ).

I would try adding a glColor3ub(255,255,255); on the line before theModel.DrawModel(). That should make sure that the base color is white before the model is drawn.

good luck! :)

This topic is closed to new replies.

Advertisement