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

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;
}