Open PixelRifts opened 4 years ago
Thanks for the suggestion! I'm still sort of new to OpenGL and didn't know that this was possible.
Is this still available?
This is still open! Have at it!
!Assign (please assign it to me)
for (GameObject gameObject : gameObjects) {
// Set model view matrix for this item
Matrix4f modelViewMatrix = transformation.getModelViewMatrix(gameObject, viewMatrix);
shaderProgram.setUniform("modelViewMatrix", modelViewMatrix);
// Render the mesh for this game item
gameObject.getMesh().render();
}
Is this the area causing the issue? I see the GameObject class used to model the Object, and then this Renderer class which renders the gameItem
@xGREGKERSEYx It looks like that for loop is at least part of the code causing the issue. If you look at the render function in the Mesh class, you can see where the draw function is called:
public void render() {
// Activate firs texture bank
glActiveTexture(GL_TEXTURE0);
// Bind the texture
if(hasSpriteSheet)
glBindTexture(GL_TEXTURE_2D, spriteSheet.getTextures()[currentFrame].getId());
else
glBindTexture(GL_TEXTURE_2D, texture.getId());
// Draw the mesh
glBindVertexArray(getVaoId());
glDrawElements(GL_TRIANGLES, getVertexCount(), GL_UNSIGNED_INT, 0);
// Restore state
glBindVertexArray(0);
}
You could probably modify that code to draw multiple gameObjects with one call to the draw function.
@JacksonHoggard Hello! I sent you an e-mail [jhoggard0129@gmail.com] last week. Just wanted to make sure I had everything setup right. I can re-send it or just drop it in here, later.
@xGREGKERSEYx Hey! Just replied to your email. I tried to be as verbose as possible, but please let me know if you have any questions or if you need any help. Best of luck! :)
I see that in this Project every single GameObject is rendered using a separate draw call. (Very Slow)
Batch Rendering is not hard to implement. Only thing is one has to overhaul the entire Renderer :(