Jump to content
  • Advertisement
Sign in to follow this  
teslaa66

lighting question

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

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 this post


Link to post
Share on other sites
Advertisement


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 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!