title: Drawing a model from obj file
body: <p>I'm trying to write an obj viewer with openGl. This program has to draw only lines of model's faces, so i need to load:</p>
  
  <ul>
  <li>vertices: sometimes in 3D and sometimes in 4D;</li>
  <li>faces: index lists, with random lengths;</li>
  </ul>
  
  <p>Now i load only obj file, with 3 element per face, so i can draw the element in GL_TRIANGLE mode, but i'm getting somes trouble with some models:</p>
  
  <p><a href="http://people.sc.fsu.edu/~jburkardt/data/obj/icosahedron.obj" rel="nofollow">http://people.sc.fsu.edu/~jburkardt/data/obj/icosahedron.obj</a></p>
  
  <p>the loading phase seems working good, i think the problem is in the render() function:</p>
  
  <pre><code>static void render(void)
  {
      glClearColor( 0.0f, 0.0f, 0.0, 0.0f);
      glClear(GL_COLOR_BUFFER_BIT);
  
      glBindBuffer(GL_ARRAY_BUFFER, g_resources.vertex_buffer);
      glEnableClientState(GL_VERTEX_ARRAY);
      glVertexPointer(
          3,                                /* size */
          GL_FLOAT,                         /* type */
          3*sizeof(GLfloat),                /* stride */
          (void*)0                          /* array buffer offset */
      );
  
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_resources.element_buffer);
  
      glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
      glEnable(GL_CULL_FACE);
      glCullFace(GL_BACK);
  
      glDrawElements(
          GL_TRIANGLES,           /* mode */
          theModel-&gt;face.size(),  /* count */
          GL_UNSIGNED_INT,        /* type */
          (void*)0                /* element array buffer offset */
      );
  
      glDisableClientState(GL_VERTEX_ARRAY);
  
      glutSwapBuffers();
  }
  </code></pre>
  
  <p>I have also some questions:</p>
  
  <ul>
  <li>The indeces start from 1 or 0?</li>
  <li>what's about the indeces enumeration? Is it in clockwise style?</li>
  <li>Is it a good solution triangulate the faces with more than 3 indeces?</li>
  </ul>