I need to convert quad data to triangle data!!

hi im loading a mesh from a file and sometimes the mesh could have a couple of quads here and there. how can i convert them to triangles? so i only call GL_TRIANGLES !! thanks!

quad 1 2 3 4
==>
triangle 1 2 3
triangle 3 4 1

Don’t forget that your gfx card can only work with triangles. Your ‘quad’ is certainly an assembly of 2 tris.

um it sounds hard to implement this!
is there any example i could see and learn from?

thanks

i see this in a c++ example (nothing to do with the quad to tri but i dont understand something)

glVertex3fv(&model->vertices[3 * triangle->vindices[0]]);

isnt that function asking for 3 values? X Y Z ?
no commas in c++ ?

you are kidding right ? :stuck_out_tongue:

each time you read a quad (4 vertices), you transform it to 2 triangles using these 4 vertices as I told you…

What seem hard to you exactly ?

For glVertex (and a lot of other calls) the postfix means a lot of useful things.

3fv stands for :
3 : three elements are sent
f : each element is a float (can be i for int, b for byte, d for double, you get it)
v : data is sent as a single vector, a pointer to an array in C terminology, containing the above described information. If this ‘v’ is not there, then each element is in a single parameter : glVertex3f( GLfloat x, GLfloat y, GLfloat z )

You should definitely read some medium level C/C++ generic tutorials on arrays and pointers, it will help you a lot for doing anything useful.

oh yes i didnt see that wasnt glvertex3f!