mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Revised clear-buffer logic
This commit is contained in:
@@ -440,28 +440,14 @@ public class PGL {
|
||||
// Simplest scenario: clear mode means we clear both the color and depth buffers.
|
||||
// No need for saving front color buffer, etc.
|
||||
GLES20.glClearColor(0, 0, 0, 0);
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
||||
} else {
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (!clear) {
|
||||
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo[0]);
|
||||
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, textures[frontTex], 0);
|
||||
|
||||
int status = glCheckFramebufferStatus(PGL.GL_FRAMEBUFFER);
|
||||
if (status != PGL.GL_FRAMEBUFFER_COMPLETE) {
|
||||
if (status == PGL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_INCOMPLETE_FORMATS (" + Integer.toHexString(status) + ")");
|
||||
} else if (status == PGL.GL_FRAMEBUFFER_UNSUPPORTED) {
|
||||
throw new RuntimeException("PFramebuffer: GL_FRAMEBUFFER_UNSUPPORTED" + Integer.toHexString(status));
|
||||
} else {
|
||||
throw new RuntimeException("PFramebuffer: unknown framebuffer error (" + Integer.toHexString(status) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
validateFramebuffer();
|
||||
|
||||
// We need to save the color buffer after finishing with the rendering of this frame,
|
||||
// to use is as the background for the next frame ("incremental drawing").
|
||||
GLES20.glClearColor(0, 0, 0, 0);
|
||||
@@ -469,12 +455,15 @@ public class PGL {
|
||||
if (firstOnscreenFrame) {
|
||||
// No need to draw back color buffer because we are in the first frame.
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
||||
firstOnscreenFrame = false;
|
||||
} else {
|
||||
// Render previous draw texture as background.
|
||||
drawTexture(GLES20.GL_TEXTURE_2D, textures[backTex], texWidth, texHeight, 0, 0, pg.width, pg.height, 0, 0, pg.width, pg.height);
|
||||
}
|
||||
}
|
||||
|
||||
if (firstOnscreenFrame) {
|
||||
firstOnscreenFrame = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1748,6 +1748,8 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
manipulatingCamera = false;
|
||||
|
||||
clearColorBuffer = false;
|
||||
|
||||
if (fbStack == null) {
|
||||
fbStack = new Stack<PFramebuffer>();
|
||||
|
||||
@@ -4352,7 +4354,9 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
protected void backgroundImpl(PImage image) {
|
||||
backgroundImpl();
|
||||
set(0, 0, image);
|
||||
clearColorBuffer = true;
|
||||
if (0 < parent.frameCount) {
|
||||
clearColorBuffer = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4371,7 +4375,9 @@ public class PGraphicsAndroid3D extends PGraphics {
|
||||
|
||||
pgl.glClearColor(backgroundR, backgroundG, backgroundB, 1);
|
||||
pgl.glClear(PGL.GL_COLOR_BUFFER_BIT);
|
||||
clearColorBuffer = true;
|
||||
if (0 < parent.frameCount) {
|
||||
clearColorBuffer = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user