OpenGL:如何更新矩形纹理的子图像?
我正在尝试更新大矩形纹理中的小方形部分。
我尝试使用 glTexSubImage2D 并将目标设置为 GL_TEXTURE_RECTANGLE_ARB,但我遇到了问题。可能只是我不知道如何正确使用 glTexSubImage2D 。这些问题可能是由于我在更新子图像之前尝试不使用 glTexImage2D 将整个纹理加载到主内存中?
谁能告诉我是否可以更新矩形纹理的子图像,而不必将整个纹理读入主内存?我看到 glTexCopyTexSubImage2D ...仍然想知道这些方法是否适用于不过矩形纹理。
I am trying to update a small square section in a large rectangular texture.
I've tried using glTexSubImage2D with the target set to GL_TEXTURE_RECTANGLE_ARB, but I'm running into issues. It may just be that I don't know how to use glTexSubImage2D correctly though. The issues may be due to the fact that I'm trying not to load the whole texture into main memory using glTexImage2D before updating the subimage?
Can anyone tell me if it's possible to update a subimage of a rectangular texture without having to read the entire texture into main memory? I see glTexCopyTexSubImage2D... Still wondering if these methods work with rectangular textures though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很确定你至少必须使用 glTexImage2D 上传一次全尺寸纹理。如果您一开始无法访问整个图像,您甚至可以使用空白数组。
glCopyTexSubImage2D 并不真正像你想要的那样。它将特定部分从“帧缓冲区”复制到纹理。但是,您想从主内存上传,对吗?
我不明白为什么这些方法不能支持矩形纹理,除非有一个损坏的驱动程序。
考虑到矩形纹理不像其他纹理那样使用 [0..1] 范围内的纹理坐标。相反,它们使用 [0..Width] 和 [0..Height] 范围。
I'm quite sure you have to at least upload full-size texture even once with glTexImage2D. You can even use a blank array if you don't have any access to whole image at the beginning.
glCopyTexSubImage2D is not really like what you want. It copies a specific portion from "frame buffer" to a texture. But, you want to upload from main memory, right?
I don't see any reason why rectangular textures cannot be supported by those methods unless there is a broken driver.
Consider that rectangular textures do not use texture coordinates in [0..1] range like the other textures. Instead they use [0..Width] and [0..Height] range.