我正试图在点击并拖动鼠标时改变灯光位置。我这样做是通过禁用当前灯光,使用新坐标重新定义另一个灯光,并启用新灯光并来回切换。但是,它仅在第一次工作时(值未重新分配)。是不是可以多次定义GL_LIGHT?
void changeLight()
{
if (currentLight == 0){
glDisable(GL_LIGHT0);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, black_color);
glLightfv(GL_LIGHT1, GL_POSITION, initial_light_pos);
glLightfv(GL_LIGHT1, GL_AMBIENT, ambient_light);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_color);
glLightfv(GL_LIGHT1, GL_SPECULAR, light_color);
glEnable(GL_LIGHT1);
currentLight = 1;
}
else{
glDisable(GL_LIGHT1);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, black_color);
glLightfv(GL_LIGHT0, GL_POSITION, initial_light_pos);
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_color);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_color);
glEnable(GL_LIGHT0);
currentLight = 0;
}
}