noClear method partially working in A3D.

This commit is contained in:
codeanticode
2010-04-18 05:34:02 +00:00
parent 80f0da63e6
commit ba5d008073
@@ -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();
}