this is my method for lighting:

private void lights(GL gl) {
    float[] LightPos = {0.0f, 0.0f, -1.0f, 1.0f};
    float[] LightAmb = {0.2f, 0.2f, 0.2f, 1.0f};
    float[] LightDif = {0.6f, 0.6f, 0.6f, 1.0f};
    float[] LightSpc = {0.9f, 0.9f, 0.9f, 1.0f};

    gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, LightPos, 0);
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, LightAmb, 0);
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_DIFFUSE, LightDif, 0);
    gl.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, LightSpc, 0);

    gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, LightSpc, 0);


and i see my objects flat, no specular light.. any ideas?

ps. to render my objects:

for(Triangle t : tubeModel.getTriangles()) {
    gl.glVertex3f(t.v1.x, t.v1.y, t.v1.z);
    gl.glVertex3f(t.v2.x, t.v2.y, t.v2.z);
    gl.glVertex3f(t.v3.x, t.v3.y, t.v3.z);

this is what i'm looking for:alt text

this is what i get:alt text

well it's not all black but if i rotate it becomes grey-white

  • \$\begingroup\$ how do you set up material? Add it to your post please. \$\endgroup\$
    – Notabene
    Commented Jan 8, 2011 at 14:40
  • \$\begingroup\$ sorry i'm not able to log-in with that account and with few post i can't comment. i don't use material.. \$\endgroup\$
    – nkint
    Commented Jan 8, 2011 at 17:01
  • \$\begingroup\$ I merged your two accounts you should be able to edit it now \$\endgroup\$
    – Tetrad
    Commented Jan 8, 2011 at 17:41

2 Answers 2


You have to set up material.
Enable material:


Set ambient and diffuse to read from what you set in glColor:


Setup specular. For complete specular you have to have defined specular reflective color and shinines.

float specReflection[] = { 0.8f, 0.8f, 0.8f, 1.0f };
glMaterialfv(GL_FRONT, GL_SPECULAR, specReflection)
glMateriali(GL_FRONT, GL_SHININESS, 56);

Shinines is between 1 - 128. Bigger value = more bright.

You can find more help on these links:

  • \$\begingroup\$ did this answer help? \$\endgroup\$
    – Notabene
    Commented Jan 9, 2011 at 2:36
  • \$\begingroup\$ houch. thanks to your answer i understand that is not specular light that does not work but diffuse! \$\endgroup\$
    – nkint
    Commented Jan 9, 2011 at 11:33
  • \$\begingroup\$ i added some screenshot to explain better! \$\endgroup\$
    – nkint
    Commented Jan 9, 2011 at 11:39
  • 1
    \$\begingroup\$ Do you specify normal? \$\endgroup\$
    – Notabene
    Commented Jan 9, 2011 at 12:04
  • \$\begingroup\$ Do you have enabled depth buffer and correctly set up gl_cullface? I will post some code to help you, after i return from work (yeah workoholics works at sunday too :)) \$\endgroup\$
    – Notabene
    Commented Jan 9, 2011 at 13:13

Agree with notabene's answer, material needs to be specified.

But for correct lighting (diffuse and specular) you will also need to specify a normals for each vertex. Although the default normal may create (incorrect) specular reflections.

  • \$\begingroup\$ This is solved in comments under mine answer. But of course you are right ;) \$\endgroup\$
    – Notabene
    Commented Jan 12, 2011 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .