1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
/*------------------------------------------------------------------
Function : InitLight
Description : Initializes OpenGL Lights. We use two lights, a
directionnal and a local one
------------------------------------------------------------------*/
void BGLManager::InitLight()
{
// Light 0 Settings
// ----------------
// Directionnal Light - direction {-25,-5,-15)
//(coming from behind the camera, top-left)
GLfloat l0Position[4]={25.0f,5.0f,15.0f,0.0f};
GLfloat l0Diffuse [4]={0.6f,0.6f,0.6f,1.0f};
GLfloat l0Specular[4]={1.0f,1.0f,1.0f,1.0f};
glLightfv(GL_LIGHT0,GL_POSITION, l0Position);
glLightfv(GL_LIGHT0,GL_DIFFUSE, l0Diffuse);
glLightfv(GL_LIGHT0,GL_SPECULAR, l0Specular);
// Light 1 Settings
// ----------------
// Positionnal Light - position {0, 0, 50}
// (behind the camera, up)
GLfloat l1Position[4] = {0.0f, 0.0f, 50.0f,1.0f};
GLfloat l1Diffuse [4] = {0.6f,0.6f,0.6f,1.0f};
GLfloat l1Specular[4] = {1.0f,1.0f,1.0f,1.0f};
glLightfv(GL_LIGHT1,GL_POSITION, l1Position);
glLightfv(GL_LIGHT1,GL_DIFFUSE , l1Diffuse );
glLightfv(GL_LIGHT1,GL_SPECULAR, l1Specular);
// Global Lighting parameters
// --------------------------
GLfloat LModelAmbient[4] ={0.1f,0.1f,0.1f,1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, LModelAmbient);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); // Enable dual-side lighting
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); // Enable local viewer for better specular reflections
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); // Separate specular color (to have specular reflections
// on the stamp texture)
// Activate Lights
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);
} |
Partager