Introduction
I'm using :
OpenGL 3.3
GLSL 330
C++
I'm parsing a .obj file like so :
while (!file.eof() )
{
char modelbuffer[2000000];
file.getline(modelbuffer, 2000000);
switch(modelbuffer[0])
{
cout << " " << endl;
case 'v' :
Point p;
sscanf(modelbuffer, "v %f %f %f", &p.x, &p.y, &p.z);
points.push_back(p);
cout << " p.x = " << p.x << " p.y = " << p.y << " p.z = " << p.x << endl;
break;
cout << " " << endl;
case 'f':
int read_count = sscanf(modelbuffer, "f %i %i %i %i", &face[0], &face[1], &face[2], &face[3]);
cout << "face[0] = " << face[0] << " face[1] = " << face[1] << " face[2] = " << face[2] << " face[3] = " << face[3] << "\n";
if(read_count !=4)
{
cout << "bad/n"; throw std::exception();
}
faces.push_back(face[0] - 1);
faces.push_back(face[1] - 1);
faces.push_back(face[2] - 1);
faces.push_back(face[3] - 1);
cout << face[0] - 1 << face[1] - 1 << face[2] - 1 << face[3] - 1 << endl;
}
And the .obj is being rendered to the screen like so :

This is the .obj file:
# Blender v2.61 (sub 0) OBJ File: '' # www.blender.org mtllib cabnet01.mtl o Cube v 1.000000 -1.000000 -1.000000 v 1.000000 -1.000000 1.000000 v -1.000000 -1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -0.999999 v 0.999999 1.000000 1.000001 v -1.000000 1.000000 1.000000 v -1.000000 1.000000 -1.000000 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
As you can see it should be a cube rather then a stretched mess.
I've looked into why this could be happening by outputing the data of p.x,p.y,p.z to see if the data was not getting in correctly and found that the data was fine.
I was hoping someone could tell me why this stretchyness could be happening I will provide a link to the full source code below:
http://pastebin.com/ynF8w21D







