Lighting problems

Hi,

I’v load a object from an object file,
I used to work on wire frame mode and now I want it to have smooth shading.
But, I can’t manage to do it.My object now still looks like its having flat shading.Do not know where the problem lies.
Heres a portion the code.

 
// Set smooth shading mode for drawing the object
      gl.glPolygonMode (gl.GL_FRONT, gl.GL_SMOOTH);
      
      // lighting settings
      float mat_specular[]={1.0f, 1.0f, 1.0f, 1.0f};
      float mat_shininess[]={50.0f};
      float light_position[]={-2.0f, -3.0f, 4.0f, 0.0f};
      float white_light[]={1.0f, 1.0f, 1.0f, 1.0f};
      float lmodel_ambient[]={0.1f, 0.1f, 0.1f, 1.0f};
      gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      gl.glShadeModel(gl.GL_SMOOTH);
      gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR, mat_specular,0);
      gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS,mat_shininess,0);

      gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, light_position, 0);
      gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, white_light, 1);
      gl.glLightfv(gl.GL_LIGHT0, gl.GL_SPECULAR, white_light, 1);
      gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, lmodel_ambient,2);
      
      gl.glEnable(gl.GL_LIGHTING);
      gl.glEnable(gl.GL_LIGHT0);
      gl.glEnable(gl.GL_DEPTH_TEST);
      gl.glEnable(gl.GL_COLOR_MATERIAL);

      //import the model
      model=new OBJModel(modelname,2.0f,gl,true);


I then draw the model is the display() method.


//draw the model 
drawModel(gl,drawable,gl.GL_RENDER);

Thanks for the help.

I think light_position vector last value( w) should be 1.0, otherwise your light is positional and that could make shading look flat

I think you just misspoke, but POSITION.w == 0.0 implies directional light. Otherwise it is positional, though typically you’d just use POSITION.w == 1.0 for positional lights.