PDA

View Full Version : Beginner question: Using vbos with vertexHandle/normalHandle causes trouble



abe_no_i
08-15-2012, 02:23 AM
I am loading a 3d model within java by parsing an *.obj file which was created by exporting it out of Blender. So far so good the import is working.
I am storing all vertices and normals coordinates in an 2 ArrayLists<Vector3f>. Thats working.

I am getting into trouble when importing 2 or 3 different models, because glgenBuffers() is returning values 1 and 2 when creating vbo_vertexHandle and vbo_normalHandle for the first object, 3 and 4 for the 2nd object and 5 and 6 for the 3rd object. Do I hav to have ONE global vertexHandle (all vertices of all 3 models) and ONE global normalHandle (all normal indices of all 3 objects) -> so I only have to work with Handles 1 and 2, or may I as I supposed store the vertexHandle and normalHandle for each object within the 3dmodel instance (1 and 2 for obj01, 2 and 3 for obj02...) and using them dependingly on WHICH model I want to render?

Do anyone perhaps know a good src to learn how to deal with 2 or more different 3dobjects ( in java I mean real instances not only drawing 2 quads )?

Thank you for the possible answer.
regards Alexander

Alfonse Reinheart
08-15-2012, 02:57 AM
What is a "vbo_vertexHandle" and so forth?

V-man
08-15-2012, 05:10 AM
I guess he means VBO ID.
Yes, every time you call glGenBuffers, you get a new ID.
If you are just starting out and learning about GL, that is fine.
Later on, if you want to optimize, then you can pack multiple models in a single large VBO. You can write a "VBO manager class" for that.
You can even pack vertex, normal, texcoord in the same VBO.
VBOs are explained here and there is a sample code
http://www.opengl.org/wiki/Vertex_Buffer_Object