0

Let's imagine a scene composed by 3 objects (2 boxes and a plane). These 3 meshes are stored within a unique Vertex Buffer Object (VBO) as follow:

VBO(id = 1) {[Box_1_vertex][Box_2_vertex][Box_3_vertex]}

I currently use a specific Index Buffer Object (IBO) to manage the indexation of the vertices of each mesh of my scene as follow:

IBO(id = 2) {Box_1_index}
IBO(id = 3) {Box_2_index}
IBO(id = 4) {Box_3_index}

So, to render my scene I need a unique binding call for my vertex buffer and 3 binding calls for index buffer as follow:

VBO(id = 1)->Bind()
{
    FOR_EACH(IBO in IBO_LIST(size = 3))
    {
         (*IBO)->Bind();
         {
            glDrawElements(...);
         }
    }
}

So I wonder if it's possible to store all the indices (Box_1_index + Box_2_index + Box_3_index) in a unique IBO (like for the VBO) and use rather than the function glBindBuffer but this time the function glBindBufferRange to focus on my IBO data ?

This way I will have the following pattern of code:

VBO(id = 1)->Bind()
{
    IBO(id = 2)->Bind();
    {
        glDrawElements(...);
    }
}

But according to the official OpenGL documentation the first parameter of the function 'glBindBufferRange' can be GL_TRANSFORM_FEEDBACK_BUFFER or GL_UNIFORM_BUFFER but not GL_ELEMENT_ARRAY_BUFFER (I currently use this one to bind an IBO).

So, is it possible to bind a specific segment of data contained within a specific IBO using the function 'glBindBufferRange'?

genpfault
  • 51,148
  • 11
  • 85
  • 139
user1364743
  • 5,283
  • 6
  • 51
  • 90
  • 1
    You know that the last parameter to `glDrawElements` is the offset in the buffer, right? It looks like a pointer (for legacy reasons) but it is not. – harold Mar 15 '15 at 16:29
  • Yes of course. I don't need the function glBindBufferRange. All I need to know is the offset and the size of the index data within the bound IBO. Thank you. – user1364743 Mar 15 '15 at 17:34

0 Answers0