Problem: The spotlight I've set up with OpenGL won't light up anything behind it, no matter what values I set for GL_SPOT_DIRECTION
float[] LightDir = new float[]{0,0,-1,0};
float[] LightPos = new float[]{0,0,15f,1};
Initialization code for lighting
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightModel(GL_LIGHT_MODEL_AMBIENT,asFlippedFloatBuffer(new float[]{0.1f, 0.1f, 0.1f, 1f}));
glLight(GL_LIGHT0,GL_DIFFUSE,asFlippedFloatBuffer(new float[]{0.5f, 0.5f, 0.5f, 1f}));
glLight(GL_LIGHT0, GL_POSITION, asFlippedFloatBuffer(new float[]{0, 0, 0, 1}));
glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,60.0f);
glLightf(GL_LIGHT0,GL_SPOT_EXPONENT,2.0f);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glShadeModel(GL_SMOOTH);
Lighting code ran every loop
glLight(GL_LIGHT0,GL_SPOT_DIRECTION,asFlippedFloatBuffer(LightDir));
glLight(GL_LIGHT0,GL_POSITION,asFlippedFloatBuffer(LightPos));
The Following shows:
To try and change the direction I hit a key that does
LightDir[1]++;
The angle of the light goes up as expected, but seems to stop turning once it's pointed straight up. Which looks like
Which is the problem, it wont turn around. Iv'e tried every possible value for LightDir in all it's values, but I cannot get it to illuminate the back pf the tube. I've even tried to transform to light around the scene with glRotate and glTranslate. The light is supposed to function as a flashlight. Is this something that would be potentially solved with Shaders? Thanks in advance!
EDIT:
Anytime LightDir[2] goes above 0 the light goes dark.