So I was being stoic for the time and skipping out on batch rendering, but it lead me to a question…
public static void render3DElement(Entity element, Mat4 projection, Mat4 camera, Light light) {
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glCullFace(GL11.GL_BACK); //ignore this gross testing artifact
final ShaderModel shader_model = element.getShaderModel();
final Model model = element.getModel();
final Material[] materials = element.getMaterials();
GL30.glBindVertexArray(model.getVao());
GL20.glUseProgram(shader_model.getShader().getProgram());
shader_model.bindMaterials(materials);
shader_model.updateMatrix(projection, element.getMatrix(), camera);
shader_model.updateVector3(light.getPosition(), light.getColor());
GL11.glDrawElements(GL11.GL_TRIANGLES, model.getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
GL20.glUseProgram(0);
GL30.glBindVertexArray(0);
}
So the above code binds a bunch of things, but I need to iterate over a list of spacial positions and their differentiations inside of Entity element. Although each entity isn’t bound to different textures, they are bound to different matrices and such. So my question is…
GL20.glUseProgram(shader_model.getShader().getProgram());
shader_model.bindMaterials(materials);
shader_model.updateVector3(light.getPosition(), light.getColor());
for each entity... {
shader_model.updateMatrix(projection, next.getMatrix(), camera);
GL11.glDrawElements(GL11.GL_TRIANGLES, next.getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
}
GL20.glUseProgram(0);
or…
for each entity... {
GL20.glUseProgram(shader_model.getShader().getProgram());
shader_model.bindMaterials(materials);
shader_model.updateVector3(light.getPosition(), light.getColor());
shader_model.updateMatrix(projection, next.getMatrix(), camera);
GL11.glDrawElements(GL11.GL_TRIANGLES, next.getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
GL20.glUseProgram(0);
}
I can see the reliability and flexibility, but I know I am missing something.
Thanks for the help JGO <3