public synchronized void onDrawFrame(GL10 gl){
  if (DRAW_TEXTURE && mTextureIds == null) {
    mTextureIds=new int[2];
    gl.glGenTextures(2,mTextureIds,0);
    for (    int textureId : mTextureIds) {
      gl.glBindTexture(GL10.GL_TEXTURE_2D,textureId);
      gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
      gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_NEAREST);
      gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_S,GL10.GL_CLAMP_TO_EDGE);
      gl.glTexParameterf(GL10.GL_TEXTURE_2D,GL10.GL_TEXTURE_WRAP_T,GL10.GL_CLAMP_TO_EDGE);
    }
  }
  if (DRAW_TEXTURE && mTexturePage.getTexturesChanged()) {
    gl.glBindTexture(GL10.GL_TEXTURE_2D,mTextureIds[0]);
    Bitmap texture=mTexturePage.getTexture(mTextureRectFront,CurlPage.SIDE_FRONT);
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D,0,texture,0);
    texture.recycle();
    mTextureBack=mTexturePage.hasBackTexture();
    if (mTextureBack) {
      gl.glBindTexture(GL10.GL_TEXTURE_2D,mTextureIds[1]);
      texture=mTexturePage.getTexture(mTextureRectBack,CurlPage.SIDE_BACK);
      GLUtils.texImage2D(GL10.GL_TEXTURE_2D,0,texture,0);
      texture.recycle();
    }
 else {
      mTextureRectBack.set(mTextureRectFront);
    }
    mTexturePage.recycle();
    reset();
  }
  gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
  if (DRAW_SHADOW) {
    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA,GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
    gl.glColorPointer(4,GL10.GL_FLOAT,0,mBufShadowColors);
    gl.glVertexPointer(3,GL10.GL_FLOAT,0,mBufShadowVertices);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,mDropShadowCount);
    gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
    gl.glDisable(GL10.GL_BLEND);
  }
  if (DRAW_TEXTURE) {
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glTexCoordPointer(2,GL10.GL_FLOAT,0,mBufTexCoords);
  }
  gl.glVertexPointer(3,GL10.GL_FLOAT,0,mBufVertices);
  gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
  gl.glColorPointer(4,GL10.GL_FLOAT,0,mBufColors);
  gl.glDisable(GL10.GL_TEXTURE_2D);
  gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,mVerticesCountFront);
  if (DRAW_TEXTURE) {
    gl.glEnable(GL10.GL_BLEND);
    gl.glEnable(GL10.GL_TEXTURE_2D);
    if (!mFlipTexture || !mTextureBack) {
      gl.glBindTexture(GL10.GL_TEXTURE_2D,mTextureIds[0]);
    }
 else {
      gl.glBindTexture(GL10.GL_TEXTURE_2D,mTextureIds[1]);
    }
    gl.glBlendFunc(GL10.GL_SRC_ALPHA,GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,mVerticesCountFront);
    gl.glDisable(GL10.GL_BLEND);
    gl.glDisable(GL10.GL_TEXTURE_2D);
  }
  int backStartIdx=Math.max(0,mVerticesCountFront - 2);
  int backCount=mVerticesCountFront + mVerticesCountBack - backStartIdx;
  gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,backStartIdx,backCount);
  if (DRAW_TEXTURE) {
    gl.glEnable(GL10.GL_BLEND);
    gl.glEnable(GL10.GL_TEXTURE_2D);
    if (mFlipTexture || !mTextureBack) {
      gl.glBindTexture(GL10.GL_TEXTURE_2D,mTextureIds[0]);
    }
 else {
      gl.glBindTexture(GL10.GL_TEXTURE_2D,mTextureIds[1]);
    }
    gl.glBlendFunc(GL10.GL_SRC_ALPHA,GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,backStartIdx,backCount);
    gl.glDisable(GL10.GL_BLEND);
    gl.glDisable(GL10.GL_TEXTURE_2D);
  }
  gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
  gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
  if (DRAW_POLYGON_OUTLINES) {
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA,GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glLineWidth(1.0f);
    gl.glColor4f(0.5f,0.5f,1.0f,1.0f);
    gl.glVertexPointer(3,GL10.GL_FLOAT,0,mBufVertices);
    gl.glDrawArrays(GL10.GL_LINE_STRIP,0,mVerticesCountFront);
    gl.glDisable(GL10.GL_BLEND);
  }
  if (DRAW_CURL_POSITION) {
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA,GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glLineWidth(1.0f);
    gl.glColor4f(1.0f,0.5f,0.5f,1.0f);
    gl.glVertexPointer(2,GL10.GL_FLOAT,0,mBufCurlPositionLines);
    gl.glDrawArrays(GL10.GL_LINES,0,mCurlPositionLinesCount * 2);
    gl.glDisable(GL10.GL_BLEND);
  }
  if (DRAW_SHADOW) {
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA,GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
    gl.glColorPointer(4,GL10.GL_FLOAT,0,mBufShadowColors);
    gl.glVertexPointer(3,GL10.GL_FLOAT,0,mBufShadowVertices);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,mDropShadowCount,mSelfShadowCount);
    gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
    gl.glDisable(GL10.GL_BLEND);
  }
  gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}

public synchronized void onDrawFrame ( GL10 gl ) { if ( DRAW_TEXTURE && mTextureIds == null ) { mTextureIds = new int [ 2 ] ; gl . glGenTextures ( 2 , mTextureIds , 0 ) ; for ( int textureId : mTextureIds ) { gl . glBindTexture ( GL10 . GL_TEXTURE_2D , textureId ) ; gl . glTexParameterf ( GL10 . GL_TEXTURE_2D , GL10 . GL_TEXTURE_MIN_FILTER , GL10 . GL_NEAREST ) ; gl . glTexParameterf ( GL10 . GL_TEXTURE_2D , GL10 . GL_TEXTURE_MAG_FILTER , GL10 . GL_NEAREST ) ; gl . glTexParameterf ( GL10 . GL_TEXTURE_2D , GL10 . GL_TEXTURE_WRAP_S , GL10 . GL_CLAMP_TO_EDGE ) ; gl . glTexParameterf ( GL10 . GL_TEXTURE_2D , GL10 . GL_TEXTURE_WRAP_T , GL10 . GL_CLAMP_TO_EDGE ) ; } } if ( DRAW_TEXTURE && mTexturePage . getTexturesChanged ( ) ) { gl . glBindTexture ( GL10 . GL_TEXTURE_2D , mTextureIds [ 0 ] ) ; Bitmap texture = mTexturePage . getTexture ( mTextureRectFront , CurlPage . SIDE_FRONT ) ; GLUtils . texImage2D ( GL10 . GL_TEXTURE_2D , 0 , texture , 0 ) ; texture . recycle ( ) ; mTextureBack = mTexturePage . hasBackTexture ( ) ; if ( mTextureBack ) { gl . glBindTexture ( GL10 . GL_TEXTURE_2D , mTextureIds [ 1 ] ) ; texture = mTexturePage . getTexture ( mTextureRectBack , CurlPage . SIDE_BACK ) ; GLUtils . texImage2D ( GL10 . GL_TEXTURE_2D , 0 , texture , 0 ) ; texture . recycle ( ) ; } else { mTextureRectBack . set ( mTextureRectFront ) ; } mTexturePage . recycle ( ) ; reset ( ) ; } gl . glEnableClientState ( GL10 . GL_VERTEX_ARRAY ) ; if ( DRAW_SHADOW ) { gl . glDisable ( GL10 . GL_TEXTURE_2D ) ; gl . glEnable ( GL10 . GL_BLEND ) ; gl . glBlendFunc ( GL10 . GL_SRC_ALPHA , GL10 . GL_ONE_MINUS_SRC_ALPHA ) ; gl . glEnableClientState ( GL10 . GL_COLOR_ARRAY ) ; gl . glColorPointer ( 4 , GL10 . GL_FLOAT , 0 , mBufShadowColors ) ; gl . glVertexPointer ( 3 , GL10 . GL_FLOAT , 0 , mBufShadowVertices ) ; gl . glDrawArrays ( GL10 . GL_TRIANGLE_STRIP , 0 , mDropShadowCount ) ; gl . glDisableClientState ( GL10 . GL_COLOR_ARRAY ) ; gl . glDisable ( GL10 . GL_BLEND ) ; } if ( DRAW_TEXTURE ) { gl . glEnableClientState ( GL10 . GL_TEXTURE_COORD_ARRAY ) ; gl . glTexCoordPointer ( 2 , GL10 . GL_FLOAT , 0 , mBufTexCoords ) ; } gl . glVertexPointer ( 3 , GL10 . GL_FLOAT , 0 , mBufVertices ) ; gl . glEnableClientState ( GL10 . GL_COLOR_ARRAY ) ; gl . glColorPointer ( 4 , GL10 . GL_FLOAT , 0 , mBufColors ) ; gl . glDisable ( GL10 . GL_TEXTURE_2D ) ; gl . glDrawArrays ( GL10 . GL_TRIANGLE_STRIP , 0 , mVerticesCountFront ) ; if ( DRAW_TEXTURE ) { gl . glEnable ( GL10 . GL_BLEND ) ; gl . glEnable ( GL10 . GL_TEXTURE_2D ) ; if ( ! mFlipTexture || ! mTextureBack ) { gl . glBindTexture ( GL10 . GL_TEXTURE_2D , mTextureIds [ 0 ] ) ; } else { gl . glBindTexture ( GL10 . GL_TEXTURE_2D , mTextureIds [ 1 ] ) ; } gl . glBlendFunc ( GL10 . GL_SRC_ALPHA , GL10 . GL_ONE_MINUS_SRC_ALPHA ) ; gl . glDrawArrays ( GL10 . GL_TRIANGLE_STRIP , 0 , mVerticesCountFront ) ; gl . glDisable ( GL10 . GL_BLEND ) ; gl . glDisable ( GL10 . GL_TEXTURE_2D ) ; } int backStartIdx = Math . max ( 0 , mVerticesCountFront - 2 ) ; int backCount = mVerticesCountFront + mVerticesCountBack - backStartIdx ; gl . glDrawArrays ( GL10 . GL_TRIANGLE_STRIP , backStartIdx , backCount ) ; if ( DRAW_TEXTURE ) { gl . glEnable ( GL10 . GL_BLEND ) ; gl . glEnable ( GL10 . GL_TEXTURE_2D ) ; if ( mFlipTexture || ! mTextureBack ) { gl . glBindTexture ( GL10 . GL_TEXTURE_2D , mTextureIds [ 0 ] ) ; } else { gl . glBindTexture ( GL10 . GL_TEXTURE_2D , mTextureIds [ 1 ] ) ; } gl . glBlendFunc ( GL10 . GL_SRC_ALPHA , GL10 . GL_ONE_MINUS_SRC_ALPHA ) ; gl . glDrawArrays ( GL10 . GL_TRIANGLE_STRIP , backStartIdx , backCount ) ; gl . glDisable ( GL10 . GL_BLEND ) ; gl . glDisable ( GL10 . GL_TEXTURE_2D ) ; } gl . glDisableClientState ( GL10 . GL_TEXTURE_COORD_ARRAY ) ; gl . glDisableClientState ( GL10 . GL_COLOR_ARRAY ) ; if ( DRAW_POLYGON_OUTLINES ) { gl . glEnable ( GL10 . GL_BLEND ) ; gl . glBlendFunc ( GL10 . GL_SRC_ALPHA , GL10 . GL_ONE_MINUS_SRC_ALPHA ) ; gl . glLineWidth ( 1.0f ) ; gl . glColor4f ( 0.5f , 0.5f , 1.0f , 1.0f ) ; gl . glVertexPointer ( 3 , GL10 . GL_FLOAT , 0 , mBufVertices ) ; gl . glDrawArrays ( GL10 . GL_LINE_STRIP , 0 , mVerticesCountFront ) ; gl . glDisable ( GL10 . GL_BLEND ) ; } if ( DRAW_CURL_POSITION ) { gl . glEnable ( GL10 . GL_BLEND ) ; gl . glBlendFunc ( GL10 . GL_SRC_ALPHA , GL10 . GL_ONE_MINUS_SRC_ALPHA ) ; gl . glLineWidth ( 1.0f ) ; gl . glColor4f ( 1.0f , 0.5f , 0.5f , 1.0f ) ; gl . glVertexPointer ( 2 , GL10 . GL_FLOAT , 0 , mBufCurlPositionLines ) ; gl . glDrawArrays ( GL10 . GL_LINES , 0 , mCurlPositionLinesCount * 2 ) ; gl . glDisable ( GL10 . GL_BLEND ) ; } if ( DRAW_SHADOW ) { gl . glEnable ( GL10 . GL_BLEND ) ; gl . glBlendFunc ( GL10 . GL_SRC_ALPHA , GL10 . GL_ONE_MINUS_SRC_ALPHA ) ; gl . glEnableClientState ( GL10 . GL_COLOR_ARRAY ) ; gl . glColorPointer ( 4 , GL10 . GL_FLOAT , 0 , mBufShadowColors ) ; gl . glVertexPointer ( 3 , GL10 . GL_FLOAT , 0 , mBufShadowVertices ) ; gl . glDrawArrays ( GL10 . GL_TRIANGLE_STRIP , mDropShadowCount , mSelfShadowCount ) ; gl . glDisableClientState ( GL10 . GL_COLOR_ARRAY ) ; gl . glDisable ( GL10 . GL_BLEND ) ; } gl . glDisableClientState ( GL10 . GL_VERTEX_ARRAY ) ; }
renders our page curl mesh .
