@@ -296,29 +296,7 @@ public void run() {
296
296
surfaceTexture .getTransformMatrix (mSTMatrix );
297
297
mFullScreen .drawFrame (mTextureId , mSTMatrix );
298
298
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 );
322
300
323
301
/*
324
302
pixelBuffer.position(0);
@@ -386,4 +364,28 @@ public void prepareFrameBuffers() {
386
364
throw new RuntimeException ("Framebuffer not complete, status=" + status );
387
365
}
388
366
}
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
+ }
389
391
}
0 commit comments