-1

I have a problem with spotlight in OpenGL library. A scene is black, light is unseen if the GL_SPOT_CUTOFF is less than 125. I supposed that issue concerns direction of the light source but I have tried plenty of options both for position and direction of spotlight. Here is my code:

const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };

glPushMatrix();
glLoadIdentity();
GLfloat spot_direction[] = { 0.0, -1.0, 0.0 ,0.0};
GLfloat spot_position[] = { 1.0,1.0,0.0,1.0 };
glLightfv(GL_LIGHT1, GL_POSITION, spot_position);
glLightfv(GL_LIGHT1, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT1, GL_SPECULAR, light_specular);

glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 60);
glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spot_direction);
glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 100);
glPopMatrix();

glEnable(GL_LIGHT1);
GraphicsMuncher
  • 4,583
  • 4
  • 35
  • 50
james
  • 1
  • 3
  • It sounds like the object is just not close enough to the light to be affected by it. If it works with a cutoff of > 125, but not with less then your object is clearly outside the light cone. – ChrisF Jan 04 '16 at 16:58
  • Note: The OpenGL you're using has been deprecated for nearly a decade. Unless you're working on a history project, learn modern OpenGL - otherwise you're wasting your time. – GraphicsMuncher Jan 04 '16 at 17:09
  • 1
    @GraphicsMuncher This version of openGL is required. – james Jan 05 '16 at 14:05

1 Answers1

0

Solved. Problem was with too high GL_SPOT_EXPONENT factor (light was too much focused) and with direction of the light stream.

james
  • 1
  • 3