From ba5d008073c566fae6499e2e9aad9bc28a7c8644 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Sun, 18 Apr 2010 05:34:02 +0000 Subject: [PATCH] noClear method partially working in A3D. --- .../processing/core/PGraphicsAndroid3D.java | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/android/core/src/processing/core/PGraphicsAndroid3D.java b/android/core/src/processing/core/PGraphicsAndroid3D.java index 000bc0379..e50a13a57 100644 --- a/android/core/src/processing/core/PGraphicsAndroid3D.java +++ b/android/core/src/processing/core/PGraphicsAndroid3D.java @@ -422,36 +422,49 @@ public class PGraphicsAndroid3D extends PGraphics { protected void createScreenTexture() { - // Screen texture hasn't been initialized yet or the screen changed size.. - int[] pix = new int[width * height]; - for (int i = 0; i < width * height; i++) pix[i] = 0xFF0000; + // Screen texture hasn't been initialized yet or the screen changed size. + //int w = width; + //int h = height; + int w = 256; + int h = 512; + + + int[] pix = new int[w * h]; + for (int i = 0; i < w * h; i++) pix[i] = 0xFF000000; // The screen texture must have NEAREST filtering, otherwise it degrades after consecutive // renderings. - screenTex = parent.createImage(width, height, ARGB, NEAREST); + screenTex = parent.createImage(w, h, ARGB, NEAREST); screenTex.getTexture().set(pix); } protected void drawScreenTexture() { // TODO: try using glDrawTexiOES - //tint(255); + tint(255); + fill(255); + int w = 256; + int h = 512; + beginShape(QUADS); texture(screenTex); - vertex(0, 0, 0, screenTex.height); - vertex(width, 0, screenTex.width, screenTex.height); - vertex(width, height, screenTex.width, 0); + vertex(0, height - h, 0, h); + vertex(w, height - h, w, h); + vertex(w, height, w, 0); vertex(0, height, 0, 0); endShape(); } protected void copyFrameToScreenTexture() { + int w = 256; + int h = 512; + gl.glFinish(); // Make sure that the execution off all the openGL commands is finished. gl.glBindTexture(GL10.GL_TEXTURE_2D, screenTex.getTexture().getGLTextureID()); //TODO: try using glCopyTexSubImage2D - //gl.glCopyTexSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height); - gl.glCopyTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGB, 0,0, 256, 256, 0); + //gl.glCopyTexSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, 0, 0, w, h); + gl.glCopyTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGB, 0,0, w, h, 0); gl.glBindTexture(GL10.GL_TEXTURE_2D, 0); } @@ -546,9 +559,13 @@ public class PGraphicsAndroid3D extends PGraphics { gl.glClearColor(0, 0, 0, 0); gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); } else { - if (screenTex == null || screenTex.width != width || screenTex.height != height ) { + //if (screenTex == null || screenTex.width != width || screenTex.height != height ) { + if (screenTex == null) { createScreenTexture(); } + gl.glClearColor(0, 0, 0, 0); + gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); + drawScreenTexture(); }