Can material properties [ambient properties, etc] be used in conjunction with VBOs? And if so, what is the best approach and does anyone know of some good tutorials?
I’ve checked the red-book but couldn’t find anything about mixing VBOs and material properties.
I’ve checked the red-book but couldn’t find anything about mixing VBOs and material properties.
And why would you? What do buffer objects have to do with fixed-function material properties? The two concepts have nothing to do with one another.
It’s like asking if you can use textures with buffer objects. Only it makes less sense, because at least there, fixed-function texturing usually relies on texture coordinates taken from vertex attributes.
In short, there is no interaction between fixed-function lighting and using buffer objects.
gmseed, the equivalent of material properties in a modern opengl approach (i.e. one where you do everything via VBOs), is to write your own vertex and fragment shaders.
VBOs can contain any kind of data, so you can put “material properties” in them, but since you are using your own lighting algorithm, they are not the material properties defined by opengl. From the API point of view, they are just data, it’s your code that will decide that such VBO (or part of it) represent ambient/diffuse/specular/… components. Depending on the lighting algorithm used, you will need different data.
Unfortunately, last time I checked there was very few tutorials for non-fixed function OpenGL coding. One that seems very good is here:
I guess you are asking if you can use glMaterial. Yes you can. BTW, there are many ways to send vertices to the graphics cards and non of them state that you can’t use some particular function.
The best approach? I guess the best approach is to call glMaterial before rendering your geometry.
With the legacy fixed function pipeline it is possible to control some material properties per vertex from the VBO. Enable GL_COLOR_MATERIAL and use glColorMaterial() to choose which material property to control.
You can also have a per vertex material ambient, emission, diffuse, specular and shininess with shaders, which means you have more control with shaders. With fixed function, you can only control one of the properties per vertex.
This allows VBOs [without shaders] to be used and existing material properties used.
And it would work just as well if you were using client-side vertex arrays instead of buffer objects. My point is that the use of buffer objects to supply vertex arrays (aka: VBO) has nothing to do with how lighting works.