Skip to content

Commit

Permalink
Merge pull request #187 from JamesTKhan/reduce-batch-flushes
Browse files Browse the repository at this point in the history
Reduce batch flushes
  • Loading branch information
JamesTKhan authored Jun 9, 2023
2 parents 6ac57fd + b1c1d20 commit 7f719ea
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions commons/src/main/com/mbrlabs/mundus/commons/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,18 @@ public void render(float delta) {
}

renderShadowMap(delta);
batch.begin(cam);
renderWater(delta);
renderObjects(delta);
renderSkybox();
batch.end();
}

protected void renderObjects(float delta) {
// Render objects
batch.begin(cam);
sceneGraph.render(delta, clippingPlaneDisable, 0);
modelCacheManager.triggerBeforeRenderEvent();
batch.render(modelCacheManager.modelCache, environment);
batch.end();
}

protected void renderWater(float delta) {
Expand All @@ -188,9 +188,7 @@ protected void renderWater(float delta) {
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

// Render Water
batch.begin(cam);
sceneGraph.renderWater(delta, reflection, refraction, refractionDepth);
batch.end();

Gdx.gl.glDisable(GL20.GL_BLEND);
}
Expand Down Expand Up @@ -245,8 +243,8 @@ protected void captureReflectionFBO(float delta) {
batch.begin(cam);
sceneGraph.render(delta, clippingPlaneReflection, -settings.waterHeight + settings.distortionEdgeCorrection);
batch.render(modelCacheManager.modelCache, environment);
batch.end();
renderSkybox();
batch.end();
fboWaterReflection.end();

// Restore camera data
Expand All @@ -269,9 +267,7 @@ protected void captureDepth(float delta) {

protected void renderSkybox() {
if (skybox != null && skybox.active) {
batch.begin(cam);
batch.render(skybox.getSkyboxInstance(), environment, skybox.shader);
batch.end();
}
}

Expand Down

0 comments on commit 7f719ea

Please sign in to comment.