Thank you guys! You are heros! Sorry it's taken me so long to get back to you.
Omg I see my error now. I'm just going to try it as you suggest before I post this..
Here's the code I'm trying:
void GLModel::RenderMesh( Colour3 c ) {
glPushMatrix();
glTranslatef(pos.x, pos.y, pos.z);
glColor3f( c.r, c.g, c.b );
glLineWidth(1.0);
glBegin(GL_TRIANGLES);
for ( int i = 0; i < mesh.noTriangles; i++ ) { //for each triangle in the list
Vector3D vpos; Normal3D npos;
for( int j = 0; j < 3; j++ ) {
// this vertex is the said triangle, verts attached
vpos.x = mesh.vertices[ mesh.triangleList[i].Vertex[j] ].x;
vpos.y = mesh.vertices[ mesh.triangleList[i].Vertex[j] ].y;
vpos.z = mesh.vertices[ mesh.triangleList[i].Vertex[j] ].z;
// this vertex is the said triangle, normals attached
npos.x = mesh.normals[ mesh.triangleList[i].Normal[j] ].x;
npos.y = mesh.normals[ mesh.triangleList[i].Normal[j] ].y;
npos.z = mesh.normals[ mesh.triangleList[i].Normal[j] ].z;
glNormal3f(npos.x, npos.y, npos.z);
glVertex3f(vpos.x, vpos.y, vpos.z);
} //j++
} // i++
glEnd();
glPopMatrix();
}
For a model of a car i have it renders nothing? For a box I have it is a bit crazy-looking.
I'm using legacy OGL? What's the latest version these days?
Okay I'll move the normals to be processed before hand - I hadn't been using them ( :/ )
Okay
as soon as you get this rendering correctly, the 1st thing you should do is render with a VBO, or, at a minimum, a vertex array.
I thought I was rendering from a vertex array?
Okay, if you guys are willing to delve deeper, here is the code thats responsible for this, from file load to render. I really appreciate any help as I know I need tris before I can texture, have any use for lighting, worry about mtls, etc etc. I'm stuck on the first hurdle

In winmain, we have a call to this function, with the path to the model:
void GLModel::AllocateMesh( string path ){
// Step 1 - Count the Elements in the Mesh
string line; // our line to read
ifstream rfile(path); // open it up from filepath given
if( rfile.is_open() ) { //while open
while ( rfile.good() ) { //while not EOF or Error
getline (rfile, line); //get content..
// update the count held by the mesh given to us
if( line.substr(0,1) == "#" ) {/* do nothing for comments */ }
else if( line.substr(0,5) == "mtllib") {/* this is the objects material */ }
else if( line.substr(0,2) == "g ") {/* and do nowt for groups */ }
else if( line.substr(0,2) == "vn") { mesh.noNormals++; }
else if( line.substr(0,2) == "vt") { mesh.noTexCoords++; }
else if( line.substr(0,2) == "v ") { mesh.noVerts++; }
else if( line.substr(0,2) == "f ") { mesh.noTriangles++; }
}
}
rfile.close(); //housekeeping
// Step 2 - Allocate the memory according to the count
mesh.vertices = (Vertex3D*) malloc(sizeof(Vertex3D)* mesh.noVerts);
mesh.normals = (Normal3D*) malloc(sizeof(Normal3D)* mesh.noNormals);
mesh.texcoords = (UV*) malloc(sizeof(UV) * mesh.noTexCoords);
mesh.triangleList = (Triangle*) malloc(sizeof(Triangle)* mesh.noTriangles);
}
This is followed directly by a call to this function which reads the file:
void GLModel::LoadMeshData( string path ) {
string line;
ifstream rfile(path);
int ni, vi, ti, fi; //counters: normals, verts, texcoords, faces
ni = 0; vi = 0; ti = 0; fi = 0;
if ( rfile.is_open() ) { //if file is open
while ( !rfile.eof() ) { //til end of file:
getline(rfile, line);
istringstream currentline(line);
string temp, f1, f2, f3;
/* Vertex Normals */
if(line.substr(0,2) == "vn") {
currentline >> temp >>f1 >> f2 >> f3;
mesh.normals[ni].x = atof( f1.c_str() );
mesh.normals[ni].y = atof( f2.c_str() );
mesh.normals[ni].z = atof( f3.c_str() );
ni++; //next normal
}
/* Vertex texture coordinates */
else if(line.substr(0,2) == "vt") {
currentline >> temp >>f1 >> f2;
mesh.texcoords[ti].s = atof( f1.c_str() );
mesh.texcoords[ti].t = atof( f2.c_str() );
ti++; //next texcoords
}
/* Vertex */
else if(line.substr(0,1) == "v") {
currentline >> temp >>f1 >> f2 >> f3;
mesh.vertices[vi].x = atof( f1.c_str() );
mesh.vertices[vi].y = atof( f2.c_str() );
mesh.vertices[vi].z = atof( f3.c_str() );
vi++; //next vertex
}
/* Triangle/Face*/
else if(line.substr(0,1) == "f") {
string temp;
currentline >> temp >>f1 >> f2 >> f3;
int sPos = 0;
int ePos = 0;
ePos = f1.find_first_of("/");
//we have a line with the format of "f %d/%d/%d %d/%d/%d %d/%d/%d"
if(ePos != string::npos) {
temp = f1.substr(sPos, ePos - sPos);
mesh.triangleList[fi].Vertex[0] = atoi( temp.c_str() ) - 1;
sPos = ePos + 1;
ePos = f1.find( "/", sPos );
temp = f1.substr(sPos, ePos - sPos);
mesh.triangleList[fi].Vertex[1] = atoi( temp.c_str() ) - 1;
sPos = ePos + 1;
ePos = f1.length();
temp = f1.substr(sPos, ePos - sPos);
mesh.triangleList[fi].Vertex[2] = atoi( temp.c_str() )- 1;
} //end triangle vertex data
sPos = 0;
ePos = f2.find_first_of("/");
if(ePos != string::npos) {
temp = f2.substr(sPos, ePos - sPos);
mesh.triangleList[fi].TexCoord[0] = atoi( temp.c_str() ) - 1;
sPos = ePos + 1;
ePos = f2.find("/", sPos + 1);
temp = f2.substr(sPos, ePos - sPos);
mesh.triangleList[fi].TexCoord[1] = atoi( temp.c_str() ) - 1;
sPos = ePos + 1;
ePos = f2.length();
temp = f2.substr(sPos, ePos - sPos);
mesh.triangleList[fi].TexCoord[2] = atoi( temp.c_str() ) - 1;
} //end triangle texcoord data
sPos = 0;
ePos = f3.find_first_of("/");
if(ePos != string::npos) {
temp = f3.substr(sPos, ePos - sPos);
mesh.triangleList[fi].Normal[0] = atoi ( temp.c_str() ) - 1;
sPos = ePos + 1;
ePos = f3.find("/", sPos + 1);
temp = f3.substr(sPos, ePos - sPos);
mesh.triangleList[fi].Normal[1] = atoi( temp.c_str() ) - 1;
sPos = ePos + 1;
ePos = f3.length();
temp = f3.substr(sPos, ePos - sPos);
mesh.triangleList[fi].Normal[2] = atoi( temp.c_str() ) - 1;
} //end triangle normal data
fi++; //next face
} //end triangle data
} //end while not end of file
} //end if file is open
rfile.close(); //housekeeping
}//end LoadMeshData
Then the model is ready to draw in Render() with this code:
//draw
//theScene.theModel->RenderVerts( c ); //and render the model mesh vert by vert
theScene.theModel->RenderMesh( b ); //and render the model mesh tri by tri
Which calls (and which you've seen):
void GLModel::RenderMesh( Colour3 c ) {
glPushMatrix();
glTranslatef(pos.x, pos.y, pos.z);
glColor3f( c.r, c.g, c.b );
glLineWidth(1.0);
glBegin(GL_TRIANGLES);
for ( int i = 0; i < mesh.noTriangles; i++ ) { //for each triangle in the list
Vector3D vpos; Normal3D npos;
for( int j = 0; j < 3; j++ ) {
// this vertex is the said triangle, verts attached
vpos.x = mesh.vertices[ mesh.triangleList[i].Vertex[j] ].x;
vpos.y = mesh.vertices[ mesh.triangleList[i].Vertex[j] ].y;
vpos.z = mesh.vertices[ mesh.triangleList[i].Vertex[j] ].z;
// this vertex is the said triangle, normals attached
npos.x = mesh.normals[ mesh.triangleList[i].Normal[j] ].x;
npos.y = mesh.normals[ mesh.triangleList[i].Normal[j] ].y;
npos.z = mesh.normals[ mesh.triangleList[i].Normal[j] ].z;
glNormal3f(npos.x, npos.y, npos.z);
glVertex3f(vpos.x, vpos.y, vpos.z);
} //j++
} // i++
glEnd();
glPopMatrix();
}
Edit: This is what the box looks like: Grey is the clear-colour, white is the triangles: