@@ -52,7 +52,7 @@ public static void log(String log) {
52
52
private int mTextureId ;
53
53
private final float [] mSTMatrix = new float [16 ];
54
54
55
- private Texture customTexture ;
55
+ // private Texture customTexture;
56
56
private PGraphicsOpenGL pg ;
57
57
private IntBuffer pixelBuffer ;
58
58
@@ -63,6 +63,7 @@ public static void log(String log) {
63
63
64
64
IntBuffer frameBuffers = IntBuffer .allocate (1 );
65
65
IntBuffer renderBuffers = IntBuffer .allocate (1 );
66
+ IntBuffer customTexture = IntBuffer .allocate (1 );
66
67
67
68
public Capture (PApplet context ) {
68
69
this (context , -1 , -1 );
@@ -84,9 +85,9 @@ public Capture(final PApplet applet, int width, int height) {
84
85
applet .registerMethod ("resume" , this );
85
86
glView = (GLSurfaceView ) applet .getSurfaceView ();
86
87
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 );
90
91
// pg.setCache(this, customTexture);
91
92
applet .runOnUiThread (new Runnable () {
92
93
@ Override
@@ -336,19 +337,22 @@ public void prepareFrameBuffers() {
336
337
GLES20 .glFramebufferRenderbuffer (GLES20 .GL_FRAMEBUFFER , GLES20 .GL_DEPTH_ATTACHMENT ,
337
338
GLES20 .GL_RENDERBUFFER , renderBuffers .get (0 ));
338
339
GlUtil .checkGlError ("glFramebufferRenderbuffer" );
340
+
341
+ GLES20 .glGenTextures (1 , customTexture );
342
+ GlUtil .checkGlError ("glGenTextures" );
339
343
340
- GLES20 .glBindTexture (GLES20 .GL_TEXTURE_2D , customTexture .glName );
344
+ GLES20 .glBindTexture (GLES20 .GL_TEXTURE_2D , customTexture .get ( 0 ) );
341
345
GlUtil .checkGlError ("glBindTexture" );
342
- /*
346
+
343
347
GLES20 .glTexParameteri (GLES20 .GL_TEXTURE_2D , GLES20 .GL_TEXTURE_MIN_FILTER , GLES20 .GL_LINEAR );
344
348
GLES20 .glTexParameteri (GLES20 .GL_TEXTURE_2D , GLES20 .GL_TEXTURE_MAG_FILTER , GLES20 .GL_LINEAR );
345
349
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 );
347
351
GLES20 .glTexImage2D (GLES20 .GL_TEXTURE_2D , 0 , GLES20 .GL_RGBA , width , height , 0 , GLES20 .GL_RGBA , GLES20 .GL_UNSIGNED_BYTE , null );
348
352
GlUtil .checkGlError ("glTexImage2D" );
349
353
350
354
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 );
352
356
GlUtil .checkGlError ("glFramebufferTexture2D" );
353
357
354
358
/*
@@ -374,7 +378,7 @@ public void getImage(boolean loadPixels) {
374
378
destpg .beginDraw ();
375
379
destpg .background (0 , 0 );
376
380
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 ,
378
382
0 , 0 , width , height );
379
383
destpg .endPGL ();
380
384
destpg .endDraw ();
0 commit comments