PDA

View Full Version : LWJGL Spotlight only drawing half the light



blizzblang
06-05-2015, 02:08 PM
Trying to get a spotlight to work in OpenGL, no matter what I do it only draws the light within a 180 degree semi-circle, the picture shows the light on the border.
Lighting Inilization code:


glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glLightModel(GL_LIGHT_MODEL_AMBIENT,asFlippedFloat Buffer(new float[]{0.5f, 0.5f, 0.5f, 1f}));
glLight(GL_LIGHT0,GL_DIFFUSE,asFlippedFloatBuffer( new float[]{1.0f, 1.0f, 1.0f, 1f}));
glLight(GL_LIGHT0, GL_POSITION, asFlippedFloatBuffer(new float[]{0, 0, 5, 1}));
glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,45f);
glLightf(GL_LIGHT0,GL_SPOT_EXPONENT,0.0f);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glShadeModel(GL_SMOOTH);
Code ran every loop:


glLight(GL_LIGHT0,GL_SPOT_DIRECTION,asFlippedFloat Buffer(LightDir));
glLight(GL_LIGHT0,GL_POSITION,asFlippedFloatBuffer (LightPos));
Misc:


float[] LightDir = new float[]{0,-1,0,1};
float[] LightPos = new float[]{0,5,0,1};
Heres what it looks like:
Without per-pixel shader
1862
with per-pixel shader
1861
Has anyone seen this before? What needs to be done to fix. I haven't gotten it to successfully work at all