glBufferData第二个arg是GLsizeiptr而不是GLsizei,为什么? [英] glBufferData second arg is GLsizeiptr not GLsizei, why?

查看:77
本文介绍了glBufferData第二个arg是GLsizeiptr而不是GLsizei,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Basically that's it, why does glBufferData take a pointer instead of an int? This arg is supposed to be the size of the buffer object, so why not GLsizei?

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

OpenGL doc on glBufferData https://www.opengl.org/sdk/docs/man/html/glBufferData.xhtml

推荐答案

当顶点缓冲对象是引入时, OpenGL扩展机制,创建了一种新的类型GLsizeiptrARB,并提供了以下基本原理:

When vertex buffer objects were introduced via the OpenGL extension mechanism, a new type GLsizeiptrARB was created and the following rationale was provided:

< offset>和< size>参数应使用哪种类型?

已解决:我们定义了新类型,这些新类型将在64位系统上很好地工作 系统,类似于C的"intptr_t".新类型"GLintptrARB" 只要预期会使用GLint代替 价值可能超过20亿. 新类型"GLsizeiptrARB" 应在预期的任何时候使用它代替GLsizei 可能超过20亿.这两种类型都定义为 有符号的整数,其大小足以包含任何指针值.作为一个 结果,它们自然可以扩展到系统上的更多位数 具有64位甚至更大的指针.

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.

此扩展中引入的偏移量的类型为GLintptrARB, 与必须为非负数的其他GL参数一致, 但本质上是算术的(不是uint),也不是大小;为了 例如,TexSubImage * D的xoffset参数的类型为GLint. 缓冲区大小键入GLsizeiptrARB.

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.

考虑过将这些类型设置为无符号的想法,但是 最终以支持缓冲区更大为由而拒绝 在32位系统上,不超过2 GB并不重要.

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,您今天在功能签名中看到该名称.

When this extension was accepted into core OpenGL, the extension-compliant type GLsizeiptrARB for the type got a standardized name GLsizeiptr which you see in the function signature today.

这篇关于glBufferData第二个arg是GLsizeiptr而不是GLsizei,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆