OpenGL triangles invisible .obj loader

Hello,
I am trying to make a 3D game with opengl, but I can't get the obj_loader to work.

I found a obj loader, and edited it, this is the result:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
struct Triangle {

       int v1;
       int v2;
       int v3;

};

struct Vertex {

      GLfloat x;
      GLfloat y;
      GLfloat z;

};

void DrawOBJ(char *fName)
{

    Vertex v[50000];
    Triangle t[50000];

    int vertexCount = 0;
    int triangleCount = 0;

    char line[100];

	FILE *fp = fopen(fName,"r");

    if (fp != NULL)
    {
        while (fgets(line, 99, fp))
        {
              if (line[0] == 'v')
              {
                  sscanf(line, "%*c %f %f %f", &v[vertexCount].x, &v[vertexCount].y, &v[vertexCount].z);
                  vertexCount++;
              }
              else if (line[0] == 'f')
              {
                  sscanf(line, "%*c %d %d %d", &t[triangleCount].v1, &t[triangleCount].v2, &t[triangleCount].v3);
                  triangleCount++;
              }
        }
    }

    fclose(fp);
    car=glGenLists(1);
    glPointSize(2.0);
   glNewList(car, GL_COMPILE);
   {
    glPushMatrix();
    glBegin(GL_TRIANGLES);
    for (int i=0; i<triangleCount; i++)
    {
        glColor3f(1.0f,0.0f,0.0f);
        glVertex3f(v[t[i].v1-1].x, v[t[i].v1-1].y, v[t[i].v1-1].z);
        glVertex3f(v[t[i].v2-1].x, v[t[i].v2-1].y, v[t[i].v2-1].z);
        glVertex3f(v[t[i].v3-1].x, v[t[i].v3-1].y, v[t[i].v3-1].z);
    }
   glEnd();
   }
   glPopMatrix();
   glEndList();
}

I load the gl-list with:
glCallList(1); // I also tried glCallList(car);


The problem is that the model is invisible, but when I change glBegin(GL_TRIANGLES) to glBegin(GL_LINES) or glBegin(GL_QUADS) it is visible but it looks strange.

While there are 3 vertexes it's still invisible and when I remove one it is visible but it looks strange.
Other triangles do work.

Does anyone know a way to fix this?

If you need more code just tell me.

Thanks in advance.
Does nobody know how to fix this?
Topic archived. No new replies allowed.