Example #1
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];
 }
  private void genFBO(GL10 glUnused) {
    fboWidth = camera.getViewport().getWidth();
    fboHeight = camera.getViewport().getHeight();

    GLES20.glGenFramebuffers(1, fb, 0);
    GLES20.glGenRenderbuffers(1, depthRb, 0);
    GLES20.glGenTextures(1, renderTex, 0);

    // generate texture
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTex[0]);

    // parameters - we have to make sure we clamp the textures to the edges
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);

    // create it
    // create an empty intbuffer first
    int[] buf = new int[fboWidth * fboHeight];
    IntBuffer texBuffer =
        ByteBuffer.allocateDirect(buf.length * 4).order(ByteOrder.nativeOrder()).asIntBuffer();

    // generate the textures
    GLES20.glTexImage2D(
        GLES20.GL_TEXTURE_2D,
        0,
        GLES20.GL_RGB,
        fboWidth,
        fboHeight,
        0,
        GLES20.GL_RGB,
        GLES20.GL_UNSIGNED_BYTE,
        texBuffer);

    // create render buffer and bind 16-bit depth buffer
    GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, depthRb[0]);
    GLES20.glRenderbufferStorage(
        GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, fboWidth, fboHeight);
  }
Example #4
0
 @Override
 public void glGenFramebuffers(int n, IntBuffer framebuffers) {
   GLES20.glGenFramebuffers(n, framebuffers);
 }
Example #5
0
 @Override
 public void glGenFramebuffers(int n, int[] framebuffers, int offset) {
   GLES20.glGenFramebuffers(n, framebuffers, offset);
 }
Example #6
0
 @Override
 protected int onPrepare() {
   int[] temp = new int[1];
   GLES20.glGenFramebuffers(temp.length, temp, 0);
   return temp[0];
 }