I'm relatively new to OpenGL and I am trying to draw a 3D model (loaded from a 3ds file using lib3ds) using OpenGL with lighting, but about half of it is drawn in black.


I set up the light as such:


GLfloat ambientColor[] = {0.2f, 0.2f, 0.2f, 1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor);

GLfloat lightColor0[] = {1.0f, 1.0f, 1.0f, 1.0f};
GLfloat lightPos0[] = {4.0f, 0.0f, 8.0f, 0.0f};
glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0);
glLightfv(GL_LIGHT0, GL_POSITION, lightPos0);

The model is in a VBO and drawn using glDrawArrays. The normals are in a separate VBO, and the normals are calculated using lib3ds_mesh_calculate_vertex_normals:

std::vector<std::array<float, 3>> normals;
for (std::size_t i = 0; i < model->nmeshes; ++i) {
  auto& mesh = *model->meshes[i];
  std::vector<float[3]> vertex_normals(mesh.nfaces * 3);
  lib3ds_mesh_calculate_vertex_normals(&mesh, vertex_normals.data());
  for (std::size_t j = 0; j < mesh.nfaces; ++j) {
    auto& face = mesh.faces[j];
glBindBuffer(GL_ARRAY_BUFFER, normal_vbo_);
             normals.size() * sizeof(decltype(normals)::value_type),

The problem isn't the vertices; the model is drawn correctly when drawing it as a wireframe. I also fixed the normals in Blender using controlN. What could be the problem? Should I store the normals in a different order?

  • \$\begingroup\$ could the vertices/indices be in counter clockwise order instead of clockwise, or vice versa? also, could you post the 3ds file? \$\endgroup\$
    – user13213
    Commented May 9, 2012 at 17:11
  • \$\begingroup\$ If you enable backface culling, will half of the triangles disappear? \$\endgroup\$
    – msell
    Commented May 10, 2012 at 5:53
  • 2
    \$\begingroup\$ Quite an odd combination, seeing C++11 with the OpenGL fixed function pipeline. :P \$\endgroup\$
    – knight666
    Commented Jul 10, 2012 at 11:27

1 Answer 1


Since pressing Control-N removed your problem, the normals your model had prior to you pressing Control-N were not correct. So yes, your normals were messed up, but your client code is most likely fine.


You must log in to answer this question.

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