Is it possible to have different objects (of the same type) contained in different buffers? That is, can I have one surface saved in one buffer and another surface saved in another buffer?

If so, how can I bind the different buffer attributes to the same variable? That is, if I have two different buffers, both with vertex coordinates, how do I get them both to be interpreted as such in the shader?

I can't simply call

glBindAttribLocation(Environment.ShaderProgram,One Buffer,"in_Position");
glBindAttribLocation(Environment.ShaderProgram,Oth erBuffer,"in_Position");
can I? Those will obviously clash.

Alfonse Reinheart

08-22-2011, 12:55 PM

You might notice that glBindAttribLocation does not take a buffer object. That's because it has nothing to do with buffer objects. It sets the attribute location that the program uses.

Buffer objects don't have attribute locations. They're just blocks of memory. That's why you have to use glVertexAttribPointer to tell OpenGL where in that block of memory to look for a particular attribute.

If you have the position values for one object in one buffer, then you, before rendering, use glBindBuffer, glEnableVertexAttribArray and glVertexAttribPointer to tell OpenGL where the data for that attribute comes from. To render the a different object using the same shader but with a different buffer, you simply repeat the process.

and it will know that the attribute stretches between both buffers? Quite clever, that is.

Do I need to reset glEnableVertexAttribArray for the new buffer or can I just use it once and it will be set for them all?

Alfonse Reinheart

08-22-2011, 04:37 PM

You're confusing initialization with what you do when you draw a frame.. You should read chapters 1 (http://www.arcsynthesis.org/gltut/Basics/Tutorial%2001.html) and 2 (http://www.arcsynthesis.org/gltut/Basics/Tutorial%2002.html) of my tutorial, as they explain this stuff with diagrams and everything.