好的,所以我正在尝试编写一个简单的渲染循环来理解glMultiDrawElementsIndirect
. 但目前它冻结了我的整个计算机(Ubuntu 14.04)并迫使我冷启动它。
我将这个结构定义为 OpenGL 规范的指导:
struct DrawElementsIndirectCommand{
GLuint count;
GLuint instanceCount;
GLuint firstIndex;
GLuint baseVertex;
GLuint baseInstance;
};
那么目前我的理解是这样的(在伪代码中):
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
然后在我的绘图循环中:
bind vertex array
glMultiDrawElementsIndirect(
GL_TRIANGLES,
GL_UNSIGNED_INT,
nullptr,
num of commands loaded,
0
)
这完全冻结了我的电脑 D:我真的不认为我理解 的正确用法glMultiDrawElementsIndirect
,正确的方法是什么?我怎么能像现在这样做?我想将所有网格加载到一个块中。