Okay, so I am trying to write a simple rendering loop to understand glMultiDrawElementsIndirect
. But at the moment it freezes up my whole computer(Ubuntu 14.04) and forces me to give it a cold restart.
I define this structure as guidlined by the OpenGL spec:
struct DrawElementsIndirectCommand{
GLuint count;
GLuint instanceCount;
GLuint firstIndex;
GLuint baseVertex;
GLuint baseInstance;
};
then at the moment my understanding is this (in pseudo-code):
create vertex array
create vertex buffer
create element buffer
create draw indirect buffer
bind vertex array
bind vertex buffer & allocate some base storage
bind element buffer & allocate some base storage
bind draw indirect buffer & allocate some base storage
for every mesh in meshes
load vertices into back of GL_ARRAY_BUFFER
load elements into back of GL_ELEMENT_ARRAY_BUFFER
create Draw...Command and put it at the back of GL_DRAW_INDIRECT_BUFFER
then in my drawing loop:
bind vertex array
glMultiDrawElementsIndirect(
GL_TRIANGLES,
GL_UNSIGNED_INT,
nullptr,
num of commands loaded,
0
)
And this completely freezes my computer D: I really don't think I understand the correct use of glMultiDrawElementsIndirect
, what is the correct way? and how can I do something like I am doing now? I want to load all of my meshes into one block.