您当前的位置: 首页 > 

鱼儿-1226

暂无认证

  • 0浏览

    0关注

    1100博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

OpenGL中如何将某个texture拷贝到另外一个texture

鱼儿-1226 发布时间:2020-08-28 15:48:58 ,浏览量:0

参考stackoverflow,可行的方法为 一、使用glCopyImageSubData,这个方法最直观而且简单。不过需要 OpenGL 4.3 二、为目标texture创建FBO。使用shader,采用texture2D把源texture画到目标texture 三、为源texture创建FBO。使用glCopyTexSubImage2D从framebuffer拷贝到目标纹理

 
  1. fboId = srcTex->GetFrameBufferId();

  2. glBindFramebuffer(GL_FRAMEBUFFER, fboId);

  3. outTexId = dstTex->GetTextureId();

  4. glActiveTexture(GL_TEXTURE0);

  5. glBindTexture(GL_TEXTURE_2D, outTexId);

  6. glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,

  7. 0, 0, srcTex->GetWidth(), srcTex->GetHeight());

  8. glBindTexture(GL_TEXTURE_2D, 0);

  9. glBindFramebuffer(GL_FRAMEBUFFER, 0);

四、glBlitFramebuffer。这个需要OpenGL ES 3.0以上支持

 
  1. glBindFramebuffer(GL_FRAMEBUFFER, fbo);

  2. glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,

  3. GL_TEXTURE_2D, tex1, 0);

  4. glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,

  5. GL_TEXTURE_2D, tex2, 0);

  6. glDrawBuffer(GL_COLOR_ATTACHMENT1);

  7. glBlitFramebuffer(0, 0, width, height, 0, 0, width, height,

  8. GL_COLOR_BUFFER_BIT, GL_NEAREST);

五、glCopyPixels

opengl - Best method to copy texture to texture - Stack Overflowopengl - How to copy texture1 to texture2 efficiently? - Stack Overflow

关注
打赏
1604459285
查看更多评论
立即登录/注册

微信扫码登录

0.0412s