# lighting question

## Recommended Posts

teslaa66    120
Basically I have made a game and loaded in md2 models (with normals) that i can move about in the scene however ive noticed the lighting effect on them does not change all the shading stays the same regardless to the direction i turn the models to. Could this be to do with the fact all my lighting is contained in the init function and is only called once so is sets up all the shading on the model once? how would i do it so that the lighting updates when i move my model? is it common to call the init from the display to update the lighting?

##### Share on other sites
ncsu121978    1344
post the code of your lighting setup and rendering code

##### Share on other sites
teslaa66    120
void init(){  glEnable(GL_DEPTH_TEST);  glEnable(GL_LIGHTING);  glEnable(GL_NORMALIZE);  glEnable(GL_BLEND);  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	  //Light 0 Properties/Position  GLfloat ambientLight[]={0.9,0.9,0.9,1.0};  GLfloat diffuseLight[]={0.3,0.3,0.3,1.0};  GLfloat specularLight[]={0.2,0.2,0.2,1.0};  glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);  glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);  glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);  glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);  glEnable(GL_LIGHT0);		  loadTexture();}void display (void){   glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);   glLoadMatrixf(cameraMatrix);   glEnable(GL_TEXTURE_2D);   //Draw everything   glEnd();   glFlush();   glutSwapBuffers();}

thats my code. If i call the init in the display it updates the lighting on all the stuff drawn in the display but this isnt common?

##### Share on other sites
mmakrzem    1036
try adding glMatrixMode(GL_MODELVIEW); after glClear to make sure that you are updating the correct matrix.