VBOs and Materials

Is is possible to specify several materials for a single VBO? If so, how?

A VBO is simply a storage for vertex data (position, normals etc). You can use one VBO for several different draw calls, in various ways.

I guess what you mean is if you can specify several materials for a single draw call. Afaik that is not possible.

You could however use a common shader which would mix or switch between textures and/or lighting models based on a vertex attribute. If it pays off is another question though :slight_smile:

It’s like this: I’m loading a mesh specified by an OBJ and MTL file and I want the vertex data to be stored as a VBO. The problem is that thosse vertices represent several faces which, in turn, can have different materials.

It seems it can’t be done, so I’ll have to use display lists, right? Or even vertex arrays?

I don’t know anything about shaders, but I’ll be learning soon, though.

Vertex arrays are is the same as using VBOs just that VBOs are supposed to be more efficient since you don’t always have to retransmit the vertex data to the card. To render to your model you do not need display lists at all. You can do everything without them.

You simply store all the vertex data in a VBO and then you need to set the appropriate material parameters and make the draw call for rendering all the faces with this material. Then you move an to the next material and do the same.

[ www.trenki.net | vector_math (3d math library) | software renderer ]

… So you could make & use several index arrays (with GL_ELEMENT_ARRAY_BUFFER) for the vbo of your object, one array for each material.