I decided after a long time of trying to do a graphical user interface using just opengl graphics to go back to a gui toolkit and in the process have had to port alot of my code to win32.
But to get too the actual problem my glDrawElement function crashes when I execute the program.
This happens when I use anything but GL_INT for the 3rd parameter of the function and when I execute the program with GL_INT it doesn't render anything to the frustum.
So I was trying to figure out why and I just don't understand I thought I did everything correct but I guess not....
here is my .obj file for reference:
Code :# Blender v2.61 (sub 0) OBJ File: '' # [url]www.blender.org[/url] 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 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
I'm using a parser I created to get the faces/vertexes in my .obj file:
using this struct to store the x,y,z positions also this vector was used with Point:Code :char modelbuffer [20000]; unsigned int face[3]; ifstream file (szFileName); //While FileObject not equal end of file while (!file.eof() ) { char modelbuffer[20000]; file.getline(modelbuffer, 20000); 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 %d %d %d %d", &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; } }
Code :vector<Point>points;
Code :struct Point { float x, y, z; };
If someone could tell me why its not working and how to fix it that would be awesome I also provide a pastebin to the full source code if you want a closer look.
http://pastebin.com/FsJ93ykj



