I'm currently trying to use function glMultiDrawElementsBaseVertex? in java with lwjgl and opengl but i have some questions.
first, i stored 2 meshes in one vbo then i want to draw them in one draw call.
so i did
int[] count = new int[] {this.modelManager.getElementCount().get(0), this.modelManager.getElementCount().get(1)};
int[] baseVertex = new int[] {0, this.modelManager.getElementCount().get(1)};
glMultiDrawElementsBaseVertex(GL_TRIANGLES, count, GL_UNSIGNED_INT, this.modelManager.pointerBuffer, baseVertex);
but im not sure about parameters. "getElementCount" return the numbers of indices for a mesh. "baseVertex" if understand correctly it represent how many objects of each mesh i want to draw. And for pointerBuffer im realy no sure about how i construct it but it store all indices of the two meshes.
this.pointerBuffer = PointerBuffer.create(MemoryUtil.memAddress(indicesBuffer), indices.length);
And for PointerBuffer parameter, i read somewhere that pointerBuffer must be a pointer to array of array but i dont know how to do it.
Following image is actually my result, one strangly combined of two mesh but i wanted to draw 100 objects of each mesh.
Edit: i forget to say my code works with the following call but it draw only one type of mesh
glDrawElementsInstancedBaseVertex(GL_TRIANGLES, this.modelManager.getElementCount().get(1), GL_UNSIGNED_INT, 0, NB_MAX_OBJECTS, this.modelManager.getElementCount().get(0));
question from:
https://stackoverflow.com/questions/65843968/how-to-use-function-glmultidrawelementsbasevertex 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…