I'm currently trying to use glMultiDrawElementsIndirect
in with LWJGL in Java, but I have an error INVALID_OPERATION.
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, this.modelManager.indirect, NB_TYPE_MESH, 0);
I see in the documentation this error is about the GL_DRAW_INDIRECT_BUFFER
or GL_ELEMENT_ARRAY_BUFFER
, but I don't know where the problem is in my code.
Indirect buffer
int[] indirect = new int[NB_TYPE_MESH*5];
for(int i=0; i<2; i++) {
indirect[i] = getElementCount().get(i);
indirect[1+i] = Game.NB_MAX_OBJECTS/2;
indirect[2+i] = 0;
indirect[3+i] = i==0?0:getElementCount().get(i-1);
indirect[4+i] = i; // maybe 0
}
vboIdIndirect = glGenBuffers();
IntBuffer gIndirectBuffer = MemoryUtil.memAllocInt(indirect.length);
gIndirectBuffer.put(indirect).flip();
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, vboIdIndirect);
glBufferData(GL_DRAW_INDIRECT_BUFFER, gIndirectBuffer, GL_DYNAMIC_DRAW);
and my elements buffer
vboId = glGenBuffers();
vboIdList.add(vboId);
indicesBuffer = MemoryUtil.memAllocInt(indices.length);
indicesBuffer.put(indices).flip();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL_DYNAMIC_DRAW);
indices contains indices for NB_TYPE_MESH
types of mesh
question from:
https://stackoverflow.com/questions/65859578/why-do-i-get-error-invalid-operation-when-i-call-glmultidrawelementsindirect 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…