0
v 0.0 1.0 0.0
v -1.0 -1.0 -1 0
v 1.0 -1.0 -1.0
v 0 -1.0 1.0
f 2 4 3
f 4 2 1
f 3 1 2
f 1 3 4

I have an obj file that describes a tetrahedron polygon.

I've finished coding to parse those data and save them into arrays.

To use the vertex values, I simply had to use glVertex3f(x, y, z)

But I don't know what I should do to use the face values.

I tried to follow some tutorials, but all of them seem very different from each other and it's really confusing.

1
  • The ones that use vertex buffer objects are the ones you should be paying attention to. The ones that use glVertex3f and similar functions are using old+deprecated OpenGL. In particular, it's easy to render this face format with indexed rendering. Commented Apr 16, 2016 at 15:32

1 Answer 1

1

The face values tell you how use your vertices to create faces, for example, to create the first triangle (or face), from value f 2 4 3

 glBegin(GL_TRIANGLES);
  glVertex3f(-1.0f, -1.0f, -1 0f);    // vertex 2
  glVertex3f( 0.0f, -1.0f,  1.0f);    // vertex 4
  glVertex3f( 1.0f, -1.0f, -1.0f);    // vertex 3
glEnd();

You can find a complete example here, about create faces from vertices : http://math.hws.edu/graphicsbook/c3/s1.html#gl1geom.1.1

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.