Hi,
I'm having trouble getting around what everything means in the lighting and section of OpenGL. I have managed to get lighting working, but whatever i try for shading doesn't work. I've been working of tutorials but can't make much sense of it. If anybody could help me understand whats going on and how to get shading working would be great. Ive got comments on my code which is as far as i understand.
Code:
void glutInit(int argc, char ** argv)
{
// Setup the basic GLUT stuff
glutInit(&argc, argv); // initialises environment
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); // uses a double buffer - colour mode -
// Create the window
glutInitWindowSize(200, 200); // creates the window size
glutInitWindowPosition(100, 150); // position of the window on the screen
glutCreateWindow("3D Draughts");
// Register the event callback functions
glutDisplayFunc(Display); // called everytime it needs to refresh the display
glutIdleFunc(idle); // called when it isnt doing anything
glutKeyboardFunc(KeyboardHandler); // picks up keyboard strokes
glutSpecialFunc(SpecKeyHandler);
glutMouseFunc(processMouse); // mouse movement and clicks
glutMotionFunc(processMouseActiveMotion);
glutReshapeFunc(Reshape); // called everytime it needs to reshape something
orientMe();
glClearDepth(1.0f);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST); // Enabling depth test
glEnable(GL_COLOR_MATERIAL); // Allows colored materials to be affected by the light
glEnable(GL_LIGHTING); // Enable lighting
glEnable(GL_LIGHT0); // Enable 1st light, possible 8 - max
glLightfv(GL_LIGHT0, GL_POSITION, LightPos); // set light position
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightColor); // setting diffuse colour
glLightfv(GL_LIGHT0, GL_SPECULAR, LightColor); // setting specular colour
// At this point, control is relinquished to the GLUT event handler.
glutMainLoop(); // Control is returned as events occur, via the callback functions.
}
thanks