Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 1 of 1

Thread: LWJGL Spotlight only drawing half the light

  1. #1
    Newbie Newbie
    Join Date
    Jun 2015
    Posts
    1

    LWJGL Spotlight only drawing half the light

    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:

    Code :
     glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_NORMALIZE);
        glLightModel(GL_LIGHT_MODEL_AMBIENT,asFlippedFloatBuffer(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:

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

    Code :
     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
    Click image for larger version. 

Name:	6V5nE.png 
Views:	150 
Size:	10.2 KB 
ID:	1862
    with per-pixel shader
    Click image for larger version. 

Name:	xlk1D.jpg 
Views:	183 
Size:	3.6 KB 
ID:	1861
    Has anyone seen this before? What needs to be done to fix. I haven't gotten it to successfully work at all
    Last edited by blizzblang; 06-05-2015 at 10:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •