Skip to content

Commit 9fc35af

Browse files
committed
don't use processing's texture
Signed-off-by: Umair Khan <[email protected]>
1 parent e47c130 commit 9fc35af

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/in/omerjerk/processing/video/android/Capture.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void log(String log) {
5252
private int mTextureId;
5353
private final float[] mSTMatrix = new float[16];
5454

55-
private Texture customTexture;
55+
// private Texture customTexture;
5656
private PGraphicsOpenGL pg;
5757
private IntBuffer pixelBuffer;
5858

@@ -63,6 +63,7 @@ public static void log(String log) {
6363

6464
IntBuffer frameBuffers = IntBuffer.allocate(1);
6565
IntBuffer renderBuffers = IntBuffer.allocate(1);
66+
IntBuffer customTexture = IntBuffer.allocate(1);
6667

6768
public Capture(PApplet context) {
6869
this(context, -1, -1);
@@ -84,9 +85,9 @@ public Capture(final PApplet applet, int width, int height) {
8485
applet.registerMethod("resume", this);
8586
glView = (GLSurfaceView) applet.getSurfaceView();
8687
pg = (PGraphicsOpenGL)applet.g;
87-
customTexture = new Texture(pg, width, height);
88-
customTexture.invertedY(true);
89-
log("cusotm texture address = " + customTexture.glName);
88+
// customTexture = new Texture(pg, width, height);
89+
// customTexture.invertedY(true);
90+
log("cusotm texture address = " + customTexture);
9091
// pg.setCache(this, customTexture);
9192
applet.runOnUiThread(new Runnable() {
9293
@Override
@@ -336,19 +337,22 @@ public void prepareFrameBuffers() {
336337
GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT,
337338
GLES20.GL_RENDERBUFFER, renderBuffers.get(0));
338339
GlUtil.checkGlError("glFramebufferRenderbuffer");
340+
341+
GLES20.glGenTextures(1, customTexture);
342+
GlUtil.checkGlError("glGenTextures");
339343

340-
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, customTexture.glName);
344+
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, customTexture.get(0));
341345
GlUtil.checkGlError("glBindTexture");
342-
/*
346+
343347
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
344348
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
345349
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
346-
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);*/
350+
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
347351
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
348352
GlUtil.checkGlError("glTexImage2D");
349353

350354
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
351-
GLES20.GL_TEXTURE_2D, customTexture.glName, 0);
355+
GLES20.GL_TEXTURE_2D, customTexture.get(0), 0);
352356
GlUtil.checkGlError("glFramebufferTexture2D");
353357

354358
/*
@@ -374,7 +378,7 @@ public void getImage(boolean loadPixels) {
374378
destpg.beginDraw();
375379
destpg.background(0, 0);
376380
PGL pgl = destpg.beginPGL();
377-
pgl.drawTexture(PGL.TEXTURE_2D, customTexture.glName, width, height,
381+
pgl.drawTexture(PGL.TEXTURE_2D, customTexture.get(0), width, height,
378382
0, 0, width, height);
379383
destpg.endPGL();
380384
destpg.endDraw();

0 commit comments

Comments
 (0)