I posted this further down, but realized that many might miss it down there, pasted it here instead:
This is an edit of the original post. Instead of creating a totally new thread.
So, I'm "finished" with the VBO problems I had (the code I'm using now is pasted down below).
I'm now looking at loading DDS textures instead of the TGA's I'm using now.
However, I'm stumped at how complicated it looks when I'm checking out sample code and the MSDN guide (which is focused on Direct3D...).
I'm wondering if maybe anyone here could discuss the process with me? I've used Nehe's now deprecated TGA tutorial before and I think I've understood most of that.
I guess I'm asking for a lot, but it would be very helpful if anyone would like to help me out with this.
I never thought there would be so much to learn when I started this project :)
Original post VBO-stuff
Hi,
I'm working on getting my OBJ-loader (and later on COLLADA-loader) working with VBO's.
This is my first turn trying to understand them. I'm reading the specs and trying out stuff.
At the moment I'm allmost getting the results I want. I just can't figure out why my sphere does this:
The model loads fine with my old "non-VBO" loader and code for displaying the sphere. So something's gone iffy with the VBO's.
If anyone could shed some light on this, I'd be a very happy guy :)
I just can't seem to figure it out on my own.
GLuint VBO_verts = 0; GLuint VBO_faces = 0; glGenBuffers(1, &VBO_verts); glBindBuffer(GL_ARRAY_BUFFER, VBO_verts); glBufferData(GL_ARRAY_BUFFER, ((int)(model1.vertices.size()) * 4 * sizeof(float)), &(model1.vertices.at(0)), GL_STATIC_DRAW); glGenBuffers(1, &VBO_faces); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VBO_faces); glBufferData(GL_ELEMENT_ARRAY_BUFFER, ((int)(model1.faces_v.size()) * 4 * sizeof(float)), &(model1.faces_v.at(0)), GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, VBO_verts); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VBO_faces); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, 0); glDrawElements(GL_TRIANGLES, (model1.faces_v.size()), GL_UNSIGNED_INT, 0); glDisableClientState(GL_VERTEX_ARRAY);
Thanks in advance,
Marcus Axelsson
EDIT
I've also noticed that when I try to load a model with more than 20000 face references my program crashes. Which I really don't want.
And when I load my VBO-indices ("f" from the obj-file) should I load those face values that reference the same vertex?
f 544/544/544 551/551/551 552/552/552f 544/544/544 552/552/552 545/545/545f 545/545/545 552/552/552 553/553/553f 545/545/545 553/553/553 546/546/546f 546/546/546 553/553/553 554/554/554f 546/546/546 554/554/554 547/547/547
That's a few of my f-references. The numbers before the first slash is a vertex reference. Here you wan see that 544 is referenced twice, 552 twice, 553 four times and so on.
But if I don't reference those numbers, how do I build my globe model later? Vertices must be shared between the faces, right? If not I would get gaps?
Normals are shared because of how they are angled and thus handle light, one vertex in the middle of three polygons would give three normals, either pointing in the same direction or not.
The vertex between the polygons, say "V5" is shared between the polygons. However it's not repeated. There's not three vertices at the same spot.
Have I got this wrong?
[Edited by - tre on July 28, 2010 10:06:19 AM]