Jump to content
  • Advertisement
Sign in to follow this  
a5sk4s

OpenGL Lighting, vertex normals and rotation question.

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

This is hopefully a simple question, but neither online research, nor looking through the red book has given me an answer. I have a primitive (triangle mesh w. vertex normals) that I would like to arrange in a ring: for (int a=0; a<18; a++ ) { glPushMatrix(); glRotatef(20.0f * a, 0.0, 0.0, 1.0); glVertexPointer(3 , GL_FLOAT, 0, SegmentVerts); glNormalPointer(GL_FLOAT, 0, SegmentVertNorms); glDrawElements(GL_TRIANGLES, numSegmentFaces * 3, GL_UNSIGNED_SHORT, SegmentFaces); glPopMatrix(); } When I do it as above, lighting seems to not take the rotation into account, i.e. all segments seem to get the same lighting, regardless of the rotation. My ligting is as following: - (void)configureLighting; { const GLfloat lightAmbient[] = {0.0f, 0.0f, 0.0f, 0.0f}; const GLfloat lightDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; const GLfloat matAmbient[] = {1.0f, 1.0f, 1.0f, 1.0f}; const GLfloat matDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; const GLfloat matSpecular[] = {0.6f, 0.6f, 0.6f, 1.0f}; const GLfloat lightPosition[] = {0.0f, 0.0f, 10.0f, 0.0f}; const GLfloat lightShininess = 20.0f; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, matAmbient); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, matDiffuse); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, matSpecular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, lightShininess); glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient); glLightfv(GL_LIGHT0, GL_DIFFUSE, lightDiffuse); glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); glShadeModel(GL_SMOOTH); } What could I be doing wrong? My impression was that OpenGL ES takes care of adjusting normals to the rotation, or do I have to handle the normals myself? Or am I reusing the SegmentVertNorms memory to early? Any clue or link is much appreciated.

Share this post


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