PDA

View Full Version : Vertex Buffer Object - usage HELP!


Mr.Pink
15-Jan-2007, 15:01
i want to draw an .obj model in openGL using VBO, but i am confused with "index buffer", "index array" and other legacy functionality.
i cannot found anything clear about that on the web

i wrote an .obj reader, so in my system memory i have this situation

3 STL c++ vector representing data ridden from file

vector<Vec3> m_vertexCoords;
vector<Vec2> m_textureCoords;
vector<Vec3> m_normalCoords;

unsigned int m_numVertices;
unsigned int m_numTextures;
unsigned int m_numNormals;
(Vec* is a class with * float members)


and


struct Face
{
vector<unsigned int> vertices;
vector<unsigned int> texcoords;
vector<unsigned int> normals;
};

vector<Face> m_faces;

unsigned int m_numFaces;
this vector of faces(triangles) each one containing indices to previous vectors of float

can someone tell me how to initialize buffer and draw them each frame? thanks

cass
15-Jan-2007, 15:30
Hi Mr Pink,

It's not clear to me that you need VBOs just yet.

You first need to restructure your data such that you have a single index list instead of a separate index for each vertex attribute. Then you should be able to render using conventional (slow) vertex arrays. There are lots of examples of how to do this.

Once you get your code working with conventional arrays, you'll want to create VBOs to hold the arrays. Again, there are numerous examples (including the VBO extension spec) for how to do this.

Thanks -
Cass

Mr.Pink
15-Jan-2007, 17:24
Hi Mr Pink,

It's not clear to me that you need VBOs just yet.

You first need to restructure your data such that you have a single index list instead of a separate index for each vertex attribute. Then you should be able to render using conventional (slow) vertex arrays. There are lots of examples of how to do this.

Once you get your code working with conventional arrays, you'll want to create VBOs to hold the arrays. Again, there are numerous examples (including the VBO extension spec) for how to do this.

Thanks -
Cass


can you tell me some sources for tutorials/documentation/code using VBO drawing mesh from a file? thanks again

cass
15-Jan-2007, 17:46
There's a good whitepaper on efficient VBO usage here:
http://www.spec.org/gpc/opc.static/vbo_whitepaper.html

As for rendering from file, I would suggest looking online for
examples that do the kind of rendering you want.

Mr.Pink
03-Feb-2007, 18:29
For other people with the same problem,
I have found very useful the step by step tutorial for loading .obj mesh with VBO at this link:
http://www.robthebloke.org/opengl_programming.html