Skip to content

Commit e47c130

Browse files
committed
copy the code from syphon library
Signed-off-by: Umair Khan <[email protected]>
1 parent 5579eaa commit e47c130

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

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

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -296,29 +296,7 @@ public void run() {
296296
surfaceTexture.getTransformMatrix(mSTMatrix);
297297
mFullScreen.drawFrame(mTextureId, mSTMatrix);
298298

299-
if (destpg == null) {
300-
destpg = (PGraphicsOpenGL) parent.createGraphics(width, height, P2D);
301-
302-
destpg.beginDraw();
303-
destpg.background(0, 0);
304-
pgl = destpg.beginPGL();
305-
pgl.drawTexture(PGL.TEXTURE_2D, customTexture.glName, width, height,
306-
0, 0, width, height);
307-
destpg.endPGL();
308-
destpg.endDraw();
309-
310-
// Uses the PGraphics texture as the cache object for the image
311-
Texture tex = destpg.getTexture();
312-
pg.setCache(Capture.this, tex);
313-
} else {
314-
destpg.beginDraw();
315-
destpg.background(0, 0);
316-
pgl = destpg.beginPGL();
317-
pgl.drawTexture(PGL.TEXTURE_2D, customTexture.glName, width, height,
318-
0, 0, width, height);
319-
destpg.endPGL();
320-
destpg.endDraw();
321-
}
299+
getImage(false);
322300

323301
/*
324302
pixelBuffer.position(0);
@@ -386,4 +364,28 @@ public void prepareFrameBuffers() {
386364
throw new RuntimeException("Framebuffer not complete, status=" + status);
387365
}
388366
}
367+
368+
public void getImage(boolean loadPixels) {
369+
370+
if (destpg == null || destpg.width != width || destpg.height != height) {
371+
destpg = (PGraphicsOpenGL) parent.createGraphics(width, height, PConstants.P2D);
372+
}
373+
374+
destpg.beginDraw();
375+
destpg.background(0, 0);
376+
PGL pgl = destpg.beginPGL();
377+
pgl.drawTexture(PGL.TEXTURE_2D, customTexture.glName, width, height,
378+
0, 0, width, height);
379+
destpg.endPGL();
380+
destpg.endDraw();
381+
382+
// Uses the PGraphics texture as the cache object for the image
383+
Texture tex = destpg.getTexture();
384+
pg.setCache(this, tex);
385+
if (loadPixels) {
386+
this.loadPixels();
387+
tex.get(this.pixels);
388+
this.setLoaded(false);
389+
}
390+
}
389391
}

0 commit comments

Comments
 (0)