问题描述
有
glVertexAttribPointer()
glVertexAttribIPointer()
glVertexAttribLPointer()
据我所知,可以使用 glVertexAttribPointer
代替其他两个.
As far as I know, glVertexAttribPointer
can be used instead of the other two.
如果是这样,为什么会存在 I
和 L
变体?
If so, why do the I
and L
variations exist?
推荐答案
我在 OpenGL Insights 中读到了相关内容
I read about this in OpenGL Insights
当使用 glVertexAttribPointer()
时,一切都会被转换为浮点数.glVertexAttribIPointer()
只能公开存储整数的顶点数组,而 glVertexAttribLPointer()
仅用于双精度数.
When using glVertexAttribPointer()
everything gets cast to a float. While glVertexAttribIPointer()
can only expose vertex arrays that store integers and glVertexAttribLPointer()
is only for doubles.
正如此 OpenGL.org 页面上的引用所证实:
As confirmed by a quote on this OpenGL.org page:
对于 glVertexAttribPointer,如果 normalized 设置为 GL_TRUE,则表示以整数格式存储的值将被映射到范围 [-1,1](对于有符号值)或 [0,1](对于无符号值)当它们被访问并转换为浮点时.否则,值将直接转换为浮点数,无需标准化.
对于 glVertexAttribIPointer,只有整数类型 GL_BYTE,GL_UNSIGNED_BYTE、GL_SHORT、GL_UNSIGNED_SHORT、GL_INT、接受 GL_UNSIGNED_INT.值始终保留为整数值.
For glVertexAttribIPointer, only the integer types GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT are accepted. Values are always left as integer values.
glVertexAttribLPointer 指定通用顶点属性的状态与使用 64 位声明的着色器属性变量关联的数组双精度元件.类型必须是 GL_DOUBLE.索引,大小,和 stride 的行为与 glVertexAttribPointer 和glVertexAttribIPointer.
glVertexAttribLPointer specifies state for a generic vertex attribute array associated with a shader attribute variable declared with 64-bit double precision components. type must be GL_DOUBLE. index, size, and stride behave as described for glVertexAttribPointer and glVertexAttribIPointer.
这篇关于为什么存在 glVertexAttribPointer 的不同变体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!