private void setFBO(GL10 glUnused, boolean useBuffer) {
    if (useBuffer) {
      // Bind the framebuffer
      GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fb[0]);

      // specify texture as color attachment
      GLES20.glFramebufferTexture2D(
          GLES20.GL_FRAMEBUFFER,
          GLES20.GL_COLOR_ATTACHMENT0,
          GLES20.GL_TEXTURE_2D,
          renderTex[0],
          0);
      // attach render buffer as depth buffer
      GLES20.glFramebufferRenderbuffer(
          GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, depthRb[0]);

      // check status
      int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
      if (status != GLES20.GL_FRAMEBUFFER_COMPLETE)
        Log.e("Selection", "Frame buffer couldn't attach!");

      GLES20.glClearColor(.0f, .0f, .0f, 1.0f);
      GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
    } else {
      GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
    }
  }
示例#2
0
 public static void a(
     IntBuffer intbuffer, IntBuffer intbuffer1, IntBuffer intbuffer2, int i, int j) {
   intbuffer.position(0);
   GLES20.glGenFramebuffers(1, intbuffer);
   GLES20.glBindFramebuffer(36160, intbuffer.get(0));
   a(i, j, intbuffer2);
   if (GLES20.glCheckFramebufferStatus(36160) != 36053) {
     Log.e("FBO-Helper", "Failure with framebuffer generation");
   }
   GLES20.glBindFramebuffer(36160, 0);
 }
 private int setupRenderTextureAndRenderbuffer(final int width, final int height) {
   if (this.mTextureId != -1) {
     GLES20.glDeleteTextures(1, new int[] {this.mTextureId}, 0);
   }
   if (this.mRenderbufferId != -1) {
     GLES20.glDeleteRenderbuffers(1, new int[] {this.mRenderbufferId}, 0);
   }
   if (this.mFramebufferId != -1) {
     GLES20.glDeleteFramebuffers(1, new int[] {this.mFramebufferId}, 0);
   }
   this.mTextureId = this.createTexture(width, height, this.mTextureFormat, this.mTextureType);
   this.mTextureFormatChanged = false;
   this.checkGlError("setupRenderTextureAndRenderbuffer: create texture");
   final int[] renderbufferIds = {0};
   GLES20.glGenRenderbuffers(1, renderbufferIds, 0);
   GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, renderbufferIds[0]);
   GLES20.glRenderbufferStorage(
       GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, width, height);
   this.mRenderbufferId = renderbufferIds[0];
   this.checkGlError("setupRenderTextureAndRenderbuffer: create renderbuffer");
   final int[] framebufferIds = {0};
   GLES20.glGenFramebuffers(1, framebufferIds, 0);
   GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebufferIds[0]);
   this.mFramebufferId = framebufferIds[0];
   GLES20.glFramebufferTexture2D(
       GLES20.GL_FRAMEBUFFER,
       GLES20.GL_COLOR_ATTACHMENT0,
       GLES20.GL_TEXTURE_2D,
       this.mTextureId,
       0);
   GLES20.glFramebufferRenderbuffer(
       GLES20.GL_FRAMEBUFFER,
       GLES20.GL_DEPTH_ATTACHMENT,
       GLES20.GL_RENDERBUFFER,
       renderbufferIds[0]);
   final int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
   if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
     final String s = "Framebuffer is not complete: ";
     final String value = String.valueOf(Integer.toHexString(status));
     throw new RuntimeException((value.length() != 0) ? s.concat(value) : new String(s));
   }
   GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
   return framebufferIds[0];
 }
示例#4
0
 @Override
 public int glCheckFramebufferStatus(int target) {
   return GLES20.glCheckFramebufferStatus(target);
 }