Rendering 3D object with light and shaders

I am trying to render a 3D object based on:
vertexList (list of vertex)
FaceList (number of vertice on each faces)

However, I’m wondering why is the lighting and shadow not working?

I’m really new to OpenGL and had tried this for 2 days but couldn’t find any solutions online…

Below is the code I use to render the vertex

for (all face):
glBegin (GL_POLYGON);
// glVertex3dv() <-- loading all vertex in that face)
glEnd

Please see my example below:

  • top left : my 3d object doesn’t seem to have the shadow and lighting properties
  • top right : I used GL_LINE_LOOP instead. this could show that the vertex is indeed a 3d object?
  • bottom : basic teapot using glutSolidTeapot that is able to render with the shadow and lighting property
    Screen Shot 2020-10-13 at 2.27.07 PM

Lighting requires surface normals. See this link for an introduction.

1 Like