@@ -511,8 +511,8 @@ protected void unbindFrontTexture() {
511511 protected void syncBackTexture () {
512512 if (usingFrontTex ) needSepFrontTex = true ;
513513 if (1 < numSamples ) {
514- bindFramebuffer (READ_FRAMEBUFFER , glMultiFbo .get (0 ));
515- bindFramebuffer (DRAW_FRAMEBUFFER , glColorFbo .get (0 ));
514+ bindFramebufferImpl (READ_FRAMEBUFFER , glMultiFbo .get (0 ));
515+ bindFramebufferImpl (DRAW_FRAMEBUFFER , glColorFbo .get (0 ));
516516 blitFramebuffer (0 , 0 , fboWidth , fboHeight ,
517517 0 , 0 , fboWidth , fboHeight ,
518518 COLOR_BUFFER_BIT , NEAREST );
@@ -529,12 +529,12 @@ protected void beginDraw(boolean clear0) {
529529 if (needFBOLayer (clear0 )) {
530530 if (!fboLayerCreated ) createFBOLayer ();
531531
532- bindFramebuffer (FRAMEBUFFER , glColorFbo .get (0 ));
532+ bindFramebufferImpl (FRAMEBUFFER , glColorFbo .get (0 ));
533533 framebufferTexture2D (FRAMEBUFFER , COLOR_ATTACHMENT0 ,
534534 TEXTURE_2D , glColorTex .get (backTex ), 0 );
535535
536536 if (1 < numSamples ) {
537- bindFramebuffer (FRAMEBUFFER , glMultiFbo .get (0 ));
537+ bindFramebufferImpl (FRAMEBUFFER , glMultiFbo .get (0 ));
538538 }
539539
540540 if (firstFrame ) {
@@ -580,7 +580,7 @@ protected void endDraw(boolean clear0) {
580580 syncBackTexture ();
581581
582582 // Draw the contents of the back texture to the screen framebuffer.
583- bindFramebuffer (FRAMEBUFFER , 0 );
583+ bindFramebufferImpl (FRAMEBUFFER , 0 );
584584
585585 clearDepth (1 );
586586 clearColor (0 , 0 , 0 , 0 );
@@ -670,14 +670,14 @@ private void createFBOLayer() {
670670 frontTex = 1 ;
671671
672672 genFramebuffers (1 , glColorFbo );
673- bindFramebuffer (FRAMEBUFFER , glColorFbo .get (0 ));
673+ bindFramebufferImpl (FRAMEBUFFER , glColorFbo .get (0 ));
674674 framebufferTexture2D (FRAMEBUFFER , COLOR_ATTACHMENT0 , TEXTURE_2D ,
675675 glColorTex .get (backTex ), 0 );
676676
677677 if (multisample ) {
678678 // Creating multisampled FBO
679679 genFramebuffers (1 , glMultiFbo );
680- bindFramebuffer (FRAMEBUFFER , glMultiFbo .get (0 ));
680+ bindFramebufferImpl (FRAMEBUFFER , glMultiFbo .get (0 ));
681681
682682 // color render buffer...
683683 genRenderbuffers (1 , glColorBuf );
@@ -766,7 +766,7 @@ private void createFBOLayer() {
766766 clearColor (r , g , b , a );
767767 clear (DEPTH_BUFFER_BIT | STENCIL_BUFFER_BIT | COLOR_BUFFER_BIT );
768768
769- bindFramebuffer (FRAMEBUFFER , 0 );
769+ bindFramebufferImpl (FRAMEBUFFER , 0 );
770770
771771 fboLayerCreated = true ;
772772 }
@@ -2559,11 +2559,11 @@ protected interface FontOutline {
25592559 // to glReadPixels() should be done in readPixelsImpl().
25602560
25612561 public void readPixels (int x , int y , int width , int height , int format , int type , Buffer buffer ){
2562- boolean needEndBegin = format != STENCIL_INDEX &&
2563- format != DEPTH_COMPONENT && format != DEPTH_STENCIL ;
2564- if (needEndBegin ) pg .beginReadPixels ();
2562+ boolean pgCall = format != STENCIL_INDEX &&
2563+ format != DEPTH_COMPONENT && format != DEPTH_STENCIL ;
2564+ if (pgCall ) pg .beginReadPixels ();
25652565 readPixelsImpl (x , y , width , height , format , type , buffer );
2566- if (needEndBegin ) pg .endReadPixels ();
2566+ if (pgCall ) pg .endReadPixels ();
25672567 }
25682568
25692569 protected abstract void readPixelsImpl (int x , int y , int width , int height , int format , int type , Buffer buffer );
@@ -2745,7 +2745,13 @@ public void bindTexture(int target, int texture) {
27452745
27462746 // Framebuffers Objects
27472747
2748- public abstract void bindFramebuffer (int target , int framebuffer );
2748+ public void bindFramebuffer (int target , int framebuffer ) {
2749+ pg .beginBindFramebuffer (target , framebuffer );
2750+ bindFramebufferImpl (target , framebuffer );
2751+ pg .endBindFramebuffer (target , framebuffer );
2752+ }
2753+ protected abstract void bindFramebufferImpl (int target , int framebuffer );
2754+
27492755 public abstract void deleteFramebuffers (int n , IntBuffer framebuffers );
27502756 public abstract void genFramebuffers (int n , IntBuffer framebuffers );
27512757 public abstract void bindRenderbuffer (int target , int renderbuffer );
0 commit comments