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];
 }
Beispiel #2
0
 @Override
 public void glDeleteRenderbuffers(int n, IntBuffer renderbuffers) {
   GLES20.glDeleteRenderbuffers(n, renderbuffers);
 }
Beispiel #3
0
 @Override
 public void glDeleteRenderbuffers(int n, int[] renderbuffers, int offset) {
   GLES20.glDeleteRenderbuffers(n, renderbuffers, offset);
 }