拷贝纹理的两种方式

  1. 获取纹理再拷贝
unsigned char * data = new unsigned char[normal_texture.width*normal_texture.Hight*4];
glBindTexture(GL_TEXTURE_2D,src_id);
glGetTexImage(GL_TEXTURE_2D,0,GL_RGBA,GL_UNSIGNED_BYTE,data);
glBindTexture(GL_TEXTURE_2D,dest_id);glTexSubImage2D(GL_TEXTURE_2D,0,0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,data);
glBindTexture(GL_TEXTURE_2D,0);
  1. FBO拷贝
GLuint fbo;glGenFramebuffers(1,&fbo);
/// bind the FBO
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
/// attach the source texture to the fbo
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, src_id, 0);
/// bind the destination texture
glBindTexture(GL_TEXTURE_2D, dest_id);
/// copy from framebuffer (here, the FBO!) to the bound texture
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width,height);
/// unbind the FBO
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D,0);
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容