OpenGL - VBO 内的顶点数组以及索引和索引纹理数组在外面?

发布于 2024-12-10 15:11:06 字数 57 浏览 4 评论 0原文

是否可以将一组顶点放入 VBO 中,但采用索引和纹理坐标。来自常规内存的数组?如果是,使用哪种语法?

Is it possible to place a set of Vertices into a VBO, but take the Index and Texture coord. Arrays from regular memory? If yes, which syntax to use?

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

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

发布评论

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

评论(1

柠檬色的秋千 2024-12-17 15:11:06

是的,这是可以做到的。但你不应该。

使用缓冲区对象的原因是为了提高性能。执行您的建议只会降低通过正确使用缓冲区对象获得的性能。

而且,这是大多数驾驶员不常看到的驾驶员路径。人们要么使用缓冲区对象来存储顶点数据,要么使用客户端内存数组。由于这是一条人迹罕至的道路,因此您更有可能遇到驱动程序错误。

语法只是常规语法。 gl*Pointer 调用是否使用缓冲区对象取决于缓冲区对象是否在 gl*Pointer 时绑定到 GL_ARRAY_BUFFER > 已拨打电话。因此,您可以将缓冲区绑定到 GL_ARRAY_BUFFER,使用偏移量进行 gl*Pointer 调用,然后将 0 绑定到 GL_ARRAY_BUFFER 并进行使用实际指针调用 gl*Pointer

同样,如果缓冲区绑定到 GL_ELEMENT_ARRAY_BUFFER,则 glDraw*Elements* 调用将使用缓冲区对象。因此,如果您想将客户端内存用于这些功能,请将 0 绑定到该内存。

Yes, it is possible to do this. But you shouldn't.

The reason to use buffer objects is to improve performance. Doing what you suggest simply reduces the performance you would have gained by properly using buffer objects.

Also, it's a driver path that most drivers don't see very often. Either people use buffer objects for vertex data, or they use client memory arrays. Since it's a road less traveled, you're more likely to encounter driver bugs.

The syntax is just the regular syntax. The gl*Pointer calls use buffer objects or not based on whether a buffer object is bound to GL_ARRAY_BUFFER at the time the gl*Pointer call is made. As such, you can bind a buffer to GL_ARRAY_BUFFER, make a gl*Pointer call with an offset, then bind 0 to GL_ARRAY_BUFFER and make a gl*Pointer call with an actual pointer.

Similarly, the glDraw*Elements* calls use a buffer object if a buffer is bound to GL_ELEMENT_ARRAY_BUFFER. So if you want to use client memory for these functions, bind 0 to that.

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