In openGL. How do you copy part of a texture to another texture

て烟熏妆下的殇ゞ 提交于 2019-12-05 15:53:41

If you have access to OpenGL 4.3 or the ARB_copy_image extension (or its older cousin, NV_copy_image), then you can use glCopyImageSubData.

Otherwise, you could use FBO blitting. You attach the source texture to an FBO, attach the destination texture to an FBO (possibly the same one, but if so, then obviously not to the same attachment point), set the read buffers and draw buffers for the FBOs to read from the source attachment and draw to the destination attachment, and then blit from one framebuffer to the other.

The trick you're trying to do doesn't work, BTW, because you never allocated storage for your new texture. glTexSubImage cannot be called for an image in a texture unless storage for that image has been allocated. This can be by a call to glTexImage or one of a number of other functions. The "SubImage" functions are all for uploading to existing storage, not for creating new storage.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!