1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
glEnable(GL_LIGHT0);
// Create light components
GLfloat ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f };
GLfloat diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f };
GLfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat position[] = { 10.0f, 0.0f, 0.5f };
// Assign created components to GL_LIGHT0
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glEnable(GL_LIGHTING);
GLfloat mcolor[] = { 1.0f, 0.0f, 0.0f, 0.9f };
glMaterialfv(GL_FRONT, GL_AMBIENT, mcolor);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mcolor); |
Partager