Jump to content
  • Advertisement
Sign in to follow this  
Daniel Lee


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

allo, lets take the Cube for example but using vertex Arrays this time. GLfloat corners[] = {8 * 3 vertices}; GLfloat colors[] = {red, green, blue, yellow, cyan, white}; GLubyte indexes[] = { 0,1,2,4, /// Front Face 4,5,1,0, /// Top 3,2,6,7, /// Bottom 5,4,7,6, /// Back 1,5,6,2, /// Right 4,0,3,7 /// Left }; as there are only 6 Faces, I used 6 colors in the colors Array and and used glShadeModel(GL_FLAT); but the cube was rendered with only 4 colors namely red,blue,yellow,cyan and 2 other Faces are black. what was wrong ? your kind assistance please.

Share this post

Link to post
Share on other sites
if you are using vertex arrays etc, the color values needs to be per-vertex, not per face. This would pose a problem for you, as you share verticies amoungst faces.

if you are using immediate mode (glBegin/glEnd) the color attribute, much like the rest of GL, is a state varaible.

glBegin( GL_QUADS );
for( int i=0; i<6; i++ )
glColor3fv( &colors.x );
glVertex3fv( &corners[ indexes[0] ].x );
glVertex3fv( &corners[ indexes[1] ].x );
glVertex3fv( &corners[ indexes[2] ].x );
glVertex3fv( &corners[ indexes[3] ].x );

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!