Jump to content
  • Advertisement
Sign in to follow this  
ScEngMan

OpenGL How to use glColor3ub

This topic is 3626 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

Hello, I'm trying to render a mesh with OpenGL, where each face has a unique color based on it's ID. For this I'm trying to use this macro: #define INDEX_TO_GLCOLOR3(x) glColor3ub( ((x)&0xFF), (((x)>>8)&0xFF), (((x)>>16)&0xFF) ) The problem I'm having is that OpenGL is drawing the mesh with a color defined in an early stage using glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, ambient ); glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse ); Do I have to disable something to get glColor3ub working? Thank you, Diego

Share this post


Link to post
Share on other sites
Advertisement
I found it...

glDisable( GL_LIGHTING );

If GL_LIGHTING is enabled GL uses

glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, ambient );
glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse );

If disabled, it uses

glColor()

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!