I try to load and render an obj file with openGL 2.0 but it looks very buggy! I hope somebody can help me!
Source:
void LoadObjects() { ifstream obj; string obj_str; float Vektor[9999][3]; float x, y, z; int counter = 0; int i = 0; obj.open("box.obj", ios::in); while (!obj.eof()) { getline(obj, obj_str); size_t pos = obj_str.find("v "); if (pos == 0) { sscanf(obj_str.c_str(), "v %f %f %f", &x, &y, &z); Vektor[0] = x; Vektor[1] = y; Vektor[2] = z; i++; counter++; }; }; obj.close(); int j = 0; while (j <= counter) { glBegin(GL_TRIANGLES); j++; glVertex3f(Vektor[j][0], Vektor[j][1], Vektor[j][2]); j++; glVertex3f(Vektor[j][0], Vektor[j][1], Vektor[j][2]); j++; glVertex3f(Vektor[j][0], Vektor[j][1], Vektor[j][2]); glEnd(); }; }
Picture is attachet! Sry for bad english but I hope you understand the Problem and can help me