小编FaN*_*NaT的帖子

将OpenGL ES 2.0渲染纹理转换为位图和背面

我想用RenderScript模糊渲染的纹理,为此我需要将其转换为位图格式并使用它我需要将其转换回OpenGL纹理.

纹理渲染正在起作用.问题必须在某处,但我不明白为什么它不起作用.我有黑屏

  public void renderToTexture(){
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fb[0]);
    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

    // 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);
    drawRender();

   Bitmap bitmap = SavePixels(0,0,texW,texH);
   //blur bitmap and get back a bluredBitmap not yet implemented
   texture = TextureHelper.loadTexture(bluredBitmap, 128);

   GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
   GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
   GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture);

    drawRender2();

}
Run Code Online (Sandbox Code Playgroud)

为了创建一个位图,我从帧缓冲区读取像素,因为没有找到任何其他方法来做,但我对其他方法开放

    public …
Run Code Online (Sandbox Code Playgroud)

android bitmap render-to-texture opengl-es-2.0

6
推荐指数
1
解决办法
3419
查看次数