OpenGL中glTexSubImage和glTexImage函数的区别

发布于 2024-08-24 04:26:59 字数 39 浏览 2 评论 0原文

这两个函数有什么区别? 有性能差异吗?

谢谢..

What is the difference between the two functions?
Any performance difference?

Thanks..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

东走西顾 2024-08-31 04:26:59

您使用glTexImage创建纹理,然后使用glTexSubImage更新其内容。更新纹理时,您可以更新整个纹理,或仅更新它的子矩形。

创建一个纹理并更新它比创建它并重复删除它要高效得多,因此从这个意义上说,如果您有要更新的纹理,请始终使用 glTexSubImage (在初始纹理之后)创建)。

其他技术可能适用于纹理更新。例如,请参阅这篇关于纹理流的文章以获取更多信息。

(最初,这篇文章建议使用 glMapBuffer 进行纹理更新 - 请参阅下面的讨论。)

You create a texture using glTexImage, and then update its contents with glTexSubImage. When you update the texture, you can update the entire texture, or just a sub-rectangle of it.

It is far more efficient to create the one texture and update it than to create it and delete it repeatedly, so in that sense if you have a texture you want to update, always use glTexSubImage (after the initial creation).

Other techniques may be applicable for texture updates. For example, see this article on texture streaming for further information.

(Originally, this post suggested using glMapBuffer for texture updates - see discussion below.)

灵芸 2024-08-31 04:26:59

名称中带有“sub”的 gl 函数不限于 2 的幂维度。正如 gavinb 指出的那样,您需要使用一次非子变体来设置总体尺寸,但我不同意重复调用非子变体比使用“sub”进行更新慢——GPU只要您使用相同的纹理 ID,仍然可以自由地覆盖现有纹理。

The gl functions with "sub" in the name aren't limited to power-of-2 dimensions. As gavinb points out, you need to use the non-sub variant once to set the overall dimensions, but I don't agree that calling the non-sub variant repeatedly is any slower than using "sub" for updates -- the GPU is still free to overwrite the existing texture in place as long as you are using the same texture id.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文