gpt4 book ai didi

opengl - glBufferData 第二个参数是 GLsizeiptr 不是 GLsizei,为什么?

转载 作者:行者123 更新时间:2023-12-04 13:59:53 25 4
gpt4 key购买 nike

基本上就是这样,为什么glBufferData 采用指针而不是int?这个 arg 应该是缓冲区对象的大小,那么为什么不是 GLsizei 呢?

glBufferData 上的 OpenGL 文档 https://www.opengl.org/sdk/docs/man/html/glBufferData.xhtml

最佳答案

当顶点缓冲区对象是 introduced via the OpenGL extension mechanism , 新型 GLsizeiptrARB创建并提供了以下理由:

What type should <offset> and <size> arguments use?

RESOLVED: We define new types that will work well on 64-bit systems, analogous to C's "intptr_t". The new type "GLintptrARB" should be used in place of GLint whenever it is expected that values might exceed 2 billion. The new type "GLsizeiptrARB" should be used in place of GLsizei whenever it is expected that counts might exceed 2 billion. Both types are defined as signed integers large enough to contain any pointer value. As a result, they naturally scale to larger numbers of bits on systems with 64-bit or even larger pointers.

The offsets introduced in this extension are typed GLintptrARB, consistent with other GL parameters that must be non-negative, but are arithmetic in nature (not uint), and are not sizes; for example, the xoffset argument to TexSubImage*D is of type GLint. Buffer sizes are typed GLsizeiptrARB.

The idea of making these types unsigned was considered, but was ultimately rejected on the grounds that supporting buffers larger than 2 GB was not deemed important on 32-bit systems.



当这个扩展被核心 OpenGL 接受时,扩展兼容类型 GLsizeiptrARB该类型获得了标准化名称 GLsizeiptr你今天在函数签名中看到的。

关于opengl - glBufferData 第二个参数是 GLsizeiptr 不是 GLsizei,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26758129/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com