Hey peeps,
I have tried to make my game have simple lighting which i have seen on many tutorials on the web. However, i cant get mine to have the same effect, and i cant work out why. All i want is shininess to be in effect, which i have seen on many screen shots, and also makes the other half of the shape to be darker (shading?), i will show my environment setup:
Code:
const GLfloat shininess [] = { 100.0 };
const GLfloat specular [] = { 1.0, 1.0, 1.0, 1.0 };
const GLfloat LightPos[] = { 1.0, 1.0, 1.0, 0.0 };
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);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST); // Enabling depth test
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, shininess);
glLightfv(GL_LIGHT0, GL_POSITION, LightPos);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glLightfv(GL_LIGHT0, GL_POSITION, LightPos);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0); // Enable lighting
// At this point, control is relinquished to the GLUT event handler.
glutMainLoop(); // Control is returned as events occur, via the callback functions.
}
If anybody could help, it would be a GREAT help, thank you very much.