Lack of draw call batching
Kakapio opened this issue · 1 comments
Kakapio commented
in your kek3d/main.cpp at line 260 do not call drawarrays several times.
`for (glm::vec3 cubePosition : cubePositions)
{
glm::mat4 model = glm::mat4(1.0f);
//model = glm::translate(model, cubePosition);
//model = glm::rotate(model, glm::radians(45.0f) * (float)glfwGetTime(), glm::vec3(0.0f, 1.0f, 0.0f));
shader.setUniformMat4(model, "model");
glDrawArrays(GL_TRIANGLES, 0, 36);
}`
do something like this instead, combine vertex data and pass it in one call:
`[Test]
public void GetAllVertices_Offset_Test()
{
//offset 5 blocks to the right, 1 up, 1 in.
var result = BlockMesh.GetAllVertices(new Vector3(5, 1, 1));
Assert.AreEqual(new Vector3[]
{
new Vector3(4.5f, 0.5f, 0.5f), //Left Bottom Back
new Vector3(5.5f, 0.5f, 0.5f), //Right Bottom Back
new Vector3(5.5f, 1.5f, 0.5f), //Right Top Back
new Vector3(4.5f, 1.5f, 0.5f), //Left Top Back - One face is completed!
new Vector3(4.5f, 0.5f, 1.5f), //Left Bottom Front
new Vector3(5.5f, 0.5f, 1.5f), //Right Bottom Front
new Vector3(5.5f, 1.5f, 1.5f), //Right Top Front
new Vector3(4.5f, 1.5f, 1.5f), //Left Top Front
},result);
}`
kevinsadi commented
Resolved. Great comment, thanks.