Skip to main content
update code
Source Link
acer
  • 151
  • 1
  • 8

I have rendered a spinning model in LWJGL. I have calculated normals and enabled lighting. Now I make a light:

float lightpos[] = {0, 0, 0, 0}; 
FloatBuffer lightposb = BufferUtils.createFloatBuffer(8);
lightposb.put(lightpos);
glLight(GL_LIGHT0, GL_POSITION, lightposb);
float light[] = {10, 10, 10, 1}; 
FloatBuffer lightb = BufferUtils.createFloatBuffer(8);
lightb.put(light);
glLight(GL_LIGHT0, GL_SPECULAR, lightb);
glLight(GL_LIGHT0, GL_DIFFUSE, lightb);
glLight(GL_LIGHT0, GL_AMBIENT, lightb);

The model, instead of being lit up, is a dark gray. Also, no color appears on the model, even though I set its color to cyan:

    float color[] = {0,1,1,1};
    FloatBuffer colorb = BufferUtils.createFloatBuffer(8);
    colorb.put(color);
    glMaterial(GL_FRONT, GL_AMBIENT, colorb);

UPDATE: Even though I have calculated normals and set them with glNormal3f, the model still appears to be shaded flat.

UPDATE: I HAVE done glEnable(GL_LIGHTING) and glEnable(GL_LIGHT0); that is NOT the problem.

UPDATE: I reversed the order of the light code and the model code and now the model flashes white, then goes dark grey and stays there.

I have rendered a spinning model in LWJGL. I have calculated normals and enabled lighting. Now I make a light:

float lightpos[] = {0, 0, 0, 0}; 
FloatBuffer lightposb = BufferUtils.createFloatBuffer(8);
lightposb.put(lightpos);
glLight(GL_LIGHT0, GL_POSITION, lightposb);
float light[] = {10, 10, 10, 1}; 
FloatBuffer lightb = BufferUtils.createFloatBuffer(8);
lightb.put(light);
glLight(GL_LIGHT0, GL_SPECULAR, lightb);
glLight(GL_LIGHT0, GL_DIFFUSE, lightb);
glLight(GL_LIGHT0, GL_AMBIENT, lightb);

The model, instead of being lit up, is a dark gray. Also, no color appears on the model, even though I set its color to cyan:

    float color[] = {0,1,1,1};
    FloatBuffer colorb = BufferUtils.createFloatBuffer(8);
    colorb.put(color);
    glMaterial(GL_FRONT, GL_AMBIENT, colorb);

UPDATE: Even though I have calculated normals and set them with glNormal3f, the model still appears to be shaded flat.

UPDATE: I HAVE done glEnable(GL_LIGHTING) and glEnable(GL_LIGHT0); that is NOT the problem.

I have rendered a spinning model in LWJGL. I have calculated normals and enabled lighting. Now I make a light:

float lightpos[] = {0, 0, 0, 0}; 
FloatBuffer lightposb = BufferUtils.createFloatBuffer(8);
lightposb.put(lightpos);
glLight(GL_LIGHT0, GL_POSITION, lightposb);
float light[] = {10, 10, 10, 1}; 
FloatBuffer lightb = BufferUtils.createFloatBuffer(8);
lightb.put(light);
glLight(GL_LIGHT0, GL_SPECULAR, lightb);
glLight(GL_LIGHT0, GL_DIFFUSE, lightb);
glLight(GL_LIGHT0, GL_AMBIENT, lightb);

The model, instead of being lit up, is a dark gray. Also, no color appears on the model, even though I set its color to cyan:

    float color[] = {0,1,1,1};
    FloatBuffer colorb = BufferUtils.createFloatBuffer(8);
    colorb.put(color);
    glMaterial(GL_FRONT, GL_AMBIENT, colorb);

UPDATE: Even though I have calculated normals and set them with glNormal3f, the model still appears to be shaded flat.

UPDATE: I HAVE done glEnable(GL_LIGHTING) and glEnable(GL_LIGHT0); that is NOT the problem.

UPDATE: I reversed the order of the light code and the model code and now the model flashes white, then goes dark grey and stays there.

settle misunderstanding
Source Link
acer
  • 151
  • 1
  • 8

I have rendered a spinning model in LWJGL. I have calculated normals and enabled lighting. Now I make a light:

float lightpos[] = {0, 0, 0, 0}; 
FloatBuffer lightposb = BufferUtils.createFloatBuffer(8);
lightposb.put(lightpos);
glLight(GL_LIGHT0, GL_POSITION, lightposb);
float light[] = {10, 10, 10, 1}; 
FloatBuffer lightb = BufferUtils.createFloatBuffer(8);
lightb.put(light);
glLight(GL_LIGHT0, GL_SPECULAR, lightb);
glLight(GL_LIGHT0, GL_DIFFUSE, lightb);
glLight(GL_LIGHT0, GL_AMBIENT, lightb);

The model, instead of being lit up, is a dark gray. Also, no color appears on the model, even though I set its color to cyan:

    float color[] = {0,1,1,1};
    FloatBuffer colorb = BufferUtils.createFloatBuffer(8);
    colorb.put(color);
    glMaterial(GL_FRONT, GL_AMBIENT, colorb);

UPDATE: Even though I have calculated normals and set them with glNormal3f, the model still appears to be shaded flat.

UPDATE: I HAVE done glEnable(GL_LIGHTING) and glEnable(GL_LIGHT0); that is NOT the problem.

I have rendered a spinning model in LWJGL. I have calculated normals and enabled lighting. Now I make a light:

float lightpos[] = {0, 0, 0, 0}; 
FloatBuffer lightposb = BufferUtils.createFloatBuffer(8);
lightposb.put(lightpos);
glLight(GL_LIGHT0, GL_POSITION, lightposb);
float light[] = {10, 10, 10, 1}; 
FloatBuffer lightb = BufferUtils.createFloatBuffer(8);
lightb.put(light);
glLight(GL_LIGHT0, GL_SPECULAR, lightb);
glLight(GL_LIGHT0, GL_DIFFUSE, lightb);
glLight(GL_LIGHT0, GL_AMBIENT, lightb);

The model, instead of being lit up, is a dark gray. Also, no color appears on the model, even though I set its color to cyan:

    float color[] = {0,1,1,1};
    FloatBuffer colorb = BufferUtils.createFloatBuffer(8);
    colorb.put(color);
    glMaterial(GL_FRONT, GL_AMBIENT, colorb);

UPDATE: Even though I have calculated normals and set them with glNormal3f, the model still appears to be shaded flat.

I have rendered a spinning model in LWJGL. I have calculated normals and enabled lighting. Now I make a light:

float lightpos[] = {0, 0, 0, 0}; 
FloatBuffer lightposb = BufferUtils.createFloatBuffer(8);
lightposb.put(lightpos);
glLight(GL_LIGHT0, GL_POSITION, lightposb);
float light[] = {10, 10, 10, 1}; 
FloatBuffer lightb = BufferUtils.createFloatBuffer(8);
lightb.put(light);
glLight(GL_LIGHT0, GL_SPECULAR, lightb);
glLight(GL_LIGHT0, GL_DIFFUSE, lightb);
glLight(GL_LIGHT0, GL_AMBIENT, lightb);

The model, instead of being lit up, is a dark gray. Also, no color appears on the model, even though I set its color to cyan:

    float color[] = {0,1,1,1};
    FloatBuffer colorb = BufferUtils.createFloatBuffer(8);
    colorb.put(color);
    glMaterial(GL_FRONT, GL_AMBIENT, colorb);

UPDATE: Even though I have calculated normals and set them with glNormal3f, the model still appears to be shaded flat.

UPDATE: I HAVE done glEnable(GL_LIGHTING) and glEnable(GL_LIGHT0); that is NOT the problem.

update explanation
Source Link
acer
  • 151
  • 1
  • 8

I have rendered a spinning model in LWJGL. I have calculated normals and enabled lighting. Now I make a light:

float lightpos[] = {0, 0, 0, 0}; 
FloatBuffer lightposb = BufferUtils.createFloatBuffer(8);
lightposb.put(lightpos);
glLight(GL_LIGHT0, GL_POSITION, lightposb);
float light[] = {10, 10, 10, 1}; 
FloatBuffer lightb = BufferUtils.createFloatBuffer(8);
lightb.put(light);
glLight(GL_LIGHT0, GL_SPECULAR, lightb);
glLight(GL_LIGHT0, GL_DIFFUSE, lightb);
glLight(GL_LIGHT0, GL_AMBIENT, lightb);

The model, instead of being lit up, is a dark gray. Also, no color appears on the model, even though I set its color to cyan:

    float color[] = {0,1,1,1};
    FloatBuffer colorb = BufferUtils.createFloatBuffer(8);
    colorb.put(color);
    glMaterial(GL_FRONT, GL_AMBIENT, colorb);

UPDATE: Even though I have calculated normals and set them with glNormal3f, the model still appears to be shaded flat.

I have rendered a spinning model in LWJGL. I have calculated normals and enabled lighting. Now I make a light:

float lightpos[] = {0, 0, 0, 0}; 
FloatBuffer lightposb = BufferUtils.createFloatBuffer(8);
lightposb.put(lightpos);
glLight(GL_LIGHT0, GL_POSITION, lightposb);
float light[] = {10, 10, 10, 1}; 
FloatBuffer lightb = BufferUtils.createFloatBuffer(8);
lightb.put(light);
glLight(GL_LIGHT0, GL_SPECULAR, lightb);
glLight(GL_LIGHT0, GL_DIFFUSE, lightb);
glLight(GL_LIGHT0, GL_AMBIENT, lightb);

The model, instead of being lit up, is a dark gray. Also, no color appears on the model, even though I set its color to cyan:

    float color[] = {0,1,1,1};
    FloatBuffer colorb = BufferUtils.createFloatBuffer(8);
    colorb.put(color);
    glMaterial(GL_FRONT, GL_AMBIENT, colorb);

I have rendered a spinning model in LWJGL. I have calculated normals and enabled lighting. Now I make a light:

float lightpos[] = {0, 0, 0, 0}; 
FloatBuffer lightposb = BufferUtils.createFloatBuffer(8);
lightposb.put(lightpos);
glLight(GL_LIGHT0, GL_POSITION, lightposb);
float light[] = {10, 10, 10, 1}; 
FloatBuffer lightb = BufferUtils.createFloatBuffer(8);
lightb.put(light);
glLight(GL_LIGHT0, GL_SPECULAR, lightb);
glLight(GL_LIGHT0, GL_DIFFUSE, lightb);
glLight(GL_LIGHT0, GL_AMBIENT, lightb);

The model, instead of being lit up, is a dark gray. Also, no color appears on the model, even though I set its color to cyan:

    float color[] = {0,1,1,1};
    FloatBuffer colorb = BufferUtils.createFloatBuffer(8);
    colorb.put(color);
    glMaterial(GL_FRONT, GL_AMBIENT, colorb);

UPDATE: Even though I have calculated normals and set them with glNormal3f, the model still appears to be shaded flat.

Source Link
acer
  • 151
  • 1
  • 8
Loading