Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i'm on JOGL 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

share|improve this question
how do you set up material? Add it to your post please. – Notabene Jan 8 '11 at 14:40
sorry i'm not able to log-in with that account and with few post i can't comment. i don't use material.. – nkint Jan 8 '11 at 17:01
I merged your two accounts you should be able to edit it now – Tetrad Jan 8 '11 at 17:41
@Tetrad thanks for account merging – nkint Jan 9 '11 at 11:36
up vote 1 down vote accepted

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:

share|improve this answer
did this answer help? – Notabene Jan 9 '11 at 2:36
houch. thanks to your answer i understand that is not specular light that does not work but diffuse! – nkint Jan 9 '11 at 11:33
i added some screenshot to explain better! – nkint Jan 9 '11 at 11:39
Do you specify normal? – Notabene Jan 9 '11 at 12:04
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 :)) – Notabene Jan 9 '11 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.

share|improve this answer
This is solved in comments under mine answer. But of course you are right ;) – Notabene Jan 12 '11 at 17:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.