PDA

View Full Version : Two spot lights



Srcee
06-09-2011, 08:17 AM
How to make two spot lights in the same scene? One's source will be in the left side and it will light on the right side of the scene and the other will be the opposite. They will cross each other.
I tried doing this, but they unite as one spotlight:



GLfloat light1_ambient[] = { 0.0, 0.0, 1.0, 0 };
GLfloat light1_diffuse[] = { 1.9, 0, 0, 0 };
GLfloat light1_specular[] = {3,3,3, 1};
GLfloat spot_direction[] = { 0.0, -1.0, 0.0 };

glLightfv(GL_LIGHT2, GL_AMBIENT, light1_ambient);
glLightfv(GL_LIGHT2, GL_DIFFUSE, light1_diffuse);
glLightfv(GL_LIGHT2, GL_SPECULAR, light1_specular);

glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 15.0);
glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, spot_direction);
glEnable(GL_LIGHT2);



GLfloat light2_ambient[] = { 0.0, 0.0, 1.0, 0 };
GLfloat light2_diffuse[] = { 1.9, 0, 0, 0 };
GLfloat light2_specular[] = {3,3,3, 1};
GLfloat spot2_direction[] = { 0.0, -1.0, 0.0 };

glLightfv(GL_LIGHT2, GL_AMBIENT, light2_ambient);
glLightfv(GL_LIGHT2, GL_DIFFUSE, light2_diffuse);
glLightfv(GL_LIGHT2, GL_SPECULAR, light2_specular);

glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, -15.0);
glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, spot2_direction);
glEnable(GL_LIGHT2);

Alfonse Reinheart
06-09-2011, 11:13 AM
They have to use different lights. You set both of them to GL_LIGHT2. Set one to GL_LIGHT2 and the other to GL_LIGHT3 (or which ever lights aren't being used).