Skip to content

Commit a08ae4b

Browse files
committed
loadPixels working (ultra slow)
Signed-off-by: Umair Khan <[email protected]>
1 parent dd42c36 commit a08ae4b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public static void log(String log) {
5959
IntBuffer renderBuffers = IntBuffer.allocate(1);
6060
IntBuffer customTexture = IntBuffer.allocate(1);
6161

62+
// private IntBuffer pixelBuffer;
63+
6264
private boolean isAvailable = false;
6365

6466
public Capture(PApplet context) {
@@ -122,7 +124,19 @@ public boolean available() {
122124
@Override
123125
public void loadPixels() {
124126
super.loadPixels();
125-
//TODO: implement loadPixels intelligently
127+
//It's ultra slow right now
128+
/*
129+
if (pixelBuffer == null) {
130+
pixelBuffer = IntBuffer.allocate(width * height);
131+
}
132+
pixelBuffer.position(0);
133+
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBuffers.get(0));
134+
GLES20.glViewport(0, 0, width, height);
135+
GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, pixelBuffer);
136+
pixelBuffer.position(0);
137+
pixelBuffer.get(Capture.this.pixels);
138+
*/
139+
getImage(true);
126140
}
127141

128142
public void pause() {
@@ -419,7 +433,7 @@ public void getImage(boolean loadPixels) {
419433
Texture tex = destpg.getTexture();
420434
pg.setCache(this, tex);
421435
if (loadPixels) {
422-
this.loadPixels();
436+
super.loadPixels();
423437
tex.get(this.pixels);
424438
this.setLoaded(false);
425439
}

0 commit comments

Comments
 (0)