Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Java by registered user yulongfei88 ( 8 years ago )
public class GlTexture
 {
 
 private static String TAG = "GlTexture";
 private IntBuffer mTextureBuffer;
  
  public GlTexture(int type, int width, int height)
   {
     mTextureBuffer = IntBuffer.allocate(1);
     GLES20.glGenTextures(1, mTextureBuffer);
     GlUtil.checkGlError("glGenTextures");
     GLES20.glBindTexture(type, mTextureBuffer.get(0));
     GlUtil.checkGlError("glBindTexture");
     if (type == GLES20.GL_TEXTURE_2D)
     {
       GLES20.glTexImage2D(type, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
       GLES20.glTexParameteri(type, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
       GLES20.glTexParameteri(type, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
       GLES20.glTexParameteri(type, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
       GLES20.glTexParameteri(type, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
     }
   }

   public int getID()
   {
     return this.mTextureBuffer.get(0);
   }
   
   public void release()
   {
     GLES20.glDeleteTextures(1, this.mTextureBuffer);
   }
}


public class GlFrameBuffer
{
  private static String TAG = "GlFrameBuffer";
  private IntBuffer mFrameBuffer;
  
  public GlFrameBuffer(int textureID)
  {
    mFrameBuffer = IntBuffer.allocate(1);
    GLES20.glGenFramebuffers(1, this.mFrameBuffer);
    GlUtil.checkGlError("glGenFramebuffers");
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, this.mFrameBuffer.get(0)); //GL_FRAMEBUFFER GL_FRAMEBUFFER
    GlUtil.checkGlError("glBindFramebuffer");
    GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, textureID, 0);
    GlUtil.checkGlError("glFramebufferTexture2D");
    int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
    if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
      Log.e(TAG, "GlFrameBuffer complete failed");
    }
  }
  
  public void release()
  {
    GLES20.glDeleteFramebuffers(1, this.mFrameBuffer);
  }
  
  public int getID()
  {
    return this.mFrameBuffer.get(0);
  }
}

 

Revise this Paste

Your Name: Code Language: