Jump to content
  • Advertisement
Sign in to follow this  
zerodefect

glColor3ub problem?

This topic is 5408 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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! :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!