coalesce glClear calls, fixes #4694

This commit is contained in:
codeanticode
2016-10-12 15:38:34 -04:00
parent 853478a740
commit a1dcc32044
2 changed files with 16 additions and 13 deletions
+15 -6
View File
@@ -636,13 +636,22 @@ public abstract class PGL {
// Frame rendering
protected void clearBackground(float r, float g, float b, float a, boolean depth) {
if (depth) {
clearDepth(1);
clear(PGL.DEPTH_BUFFER_BIT);
}
protected void clearBackground(float r, float g, float b, float a,
boolean depth, boolean stencil) {
clearColor(r, g, b, a);
clear(PGL.COLOR_BUFFER_BIT);
if (depth && stencil) {
clearDepth(1);
clearStencil(0);
clear(DEPTH_BUFFER_BIT | STENCIL_BUFFER_BIT | COLOR_BUFFER_BIT);
} else if (depth) {
clearDepth(1);
clear(DEPTH_BUFFER_BIT | COLOR_BUFFER_BIT);
} else if (stencil) {
clearStencil(0);
clear(STENCIL_BUFFER_BIT | COLOR_BUFFER_BIT);
} else {
clear(PGL.COLOR_BUFFER_BIT);
}
if (0 < sketch.frameCount) {
clearColor = true;
}
@@ -5325,7 +5325,7 @@ public class PGraphicsOpenGL extends PGraphics {
protected void backgroundImpl() {
flush();
pgl.clearBackground(backgroundR, backgroundG, backgroundB, backgroundA,
!hints[DISABLE_DEPTH_MASK]);
!hints[DISABLE_DEPTH_MASK], true);
loaded = false;
}
@@ -6888,12 +6888,6 @@ public class PGraphicsOpenGL extends PGraphics {
normalX = normalY = 0;
normalZ = 1;
// Clear depth and stencil buffers.
pgl.depthMask(true);
pgl.clearDepth(1);
pgl.clearStencil(0);
pgl.clear(PGL.DEPTH_BUFFER_BIT | PGL.STENCIL_BUFFER_BIT);
if (hints[DISABLE_DEPTH_MASK]) {
pgl.depthMask(false);
} else {