Newbie cube rendering

Hiall,
I have an obj. file for a simple cube exported from Blender,
where is the vertex data and faces data in which order vertexes are in a single face:

Blender3D v248 OBJ File:

http://www.blender3d.org

v 3.935551 -1.000000 -1.000000
v 3.932597 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 3.709118 -0.797889 -0.851264
v 3.728637 -0.725917 0.637501
v -0.749396 -0.730253 0.654301
v -0.776180 -0.718190 -0.887628
usemtl Material
s off
f 1 2 3 4
f 5 8 7 6
f 1 5 6 2
f 2 6 7 3
f 3 7 8 4
f 5 1 4 8

After parsing these values to an array or vertexes, how to draw it with OpenGL ES correctly using:

glVertexPointer( 3, GL_FLOAT, 0, vertices );
glDrawElements(GL_TRIANGLES, sizeof(triangels)/sizeof(GLubyte),GL_UNSIGNED_BYTE, triangels);

Does the vertex array writing data order matter?
How do i get the correct triangles, (not hardcoding them)? Do i need to calculate the triangles using face data or something?
Do some 3d file formats have triangle data ready if exported?

f 1 2 3 4 can easily be split into 2 triangles keeping the same winding :
f 1 2 3
f 1 3 4

this can be generalized to more triangles
f 1 2 3 4 5 6 … n
to :
f 1 2 3
f 1 3 4
f 1 4 5
f 1 5 6

f 1 n-1 n

This may look bad if the polygon is not convex, but should be enough.
Internally Blender only uses triangle and quads, so you are safe.

Ok, thanks for the quick answer. I made a quick
TInt i=0;
for(TInt k=0;k<36;){
iTriangles[k] = iFaces[i];
iTriangles[k+1] = iFaces[i+1];
iTriangles[k+2] = iFaces[i+2];
iTriangles[k+3] = iFaces[i];
iTriangles[k+4] = iFaces[i+2];
iTriangles[k+5] = iFaces[i+3];
i=i+4;
k=k+6;
}

But still i am missing a triangle or two:

http://img140.imageshack.us/my.php?image=cubegr7.jpg

What am i missing?

You could draw wireframe and/or at least a different color for each triangles ? It would be easier to visually debug.
Within Blender, be sure your cube is still correct even when disabling the double sided mode.

EDIT: try different ordering, I could not find a definite response about the order of vertices within a .obj face.

Hi,

Found the problem(Took a while…).Looks like in face data exported by Blender does not include index “0” at all. (As can be seen from the .obj file i included.)

Other examples like SimpleCube had this “0”, so i just:
(TInt is Symbian type for int)
TInt i=0;
for(TInt k=0;k<36;){
iTriangles[k] = iFaces[i] - 1 ;
iTriangles[k+1] = iFaces[i+1] -1 ;
iTriangles[k+2] = iFaces[i+2] -1;
iTriangles[k+3] = iFaces[i] -1;
iTriangles[k+4] = iFaces[i+2] -1;
iTriangles[k+5] = iFaces[i+3] -1;
i=i+4;
k=k+6;