OpenGL API 之 glVertexAttribPointer

glVertexAttribPointer

  定义通用顶点属性数据的数组

 C Specification

  format

void glVertexAttribPointer(GLuint index,
 	                       GLint size,
 	                       GLenum type,
 	                       GLboolean normalized,
 	                       GLsizei stride,
 	                       const void * pointer);

 Parameters

name type description
index GLuint  Specifies the index of the generic vertex attribute to be modified.
size GLint Specifies the number of components per generic vertex attribute. Must be 1, 2, 3, 4. Additionally, the symbolic constant GL_BGRA is accepted by glVertexAttribPointer. The initial value is 4.
type GLenum Specifies the data type of each component in the array. The symbolic constants GL_BYTEGL_UNSIGNED_BYTEGL_SHORTGL_UNSIGNED_SHORTGL_INT, and GL_UNSIGNED_INT are accepted by glVertexAttribPointer and glVertexAttribIPointer. Additionally GL_HALF_FLOATGL_FLOATGL_DOUBLEGL_FIXEDGL_INT_2_10_10_10_REVGL_UNSIGNED_INT_2_10_10_10_REV and GL_UNSIGNED_INT_10F_11F_11F_REV are accepted by glVertexAttribPointerGL_DOUBLE is also accepted by glVertexAttribLPointer and is the only token accepted by the type parameter for that function. The initial value is GL_FLOAT.
normalized GLboolean For glVertexAttribPointer, specifies whether fixed-point data values should be normalized (GL_TRUE) or converted directly as fixed-point values (GL_FALSE) when they are accessed.
stride GLsizei Specifies the byte offset between consecutive generic vertex attributes. If stride is 0, the generic vertex attributes are understood to be tightly packed in the array. The initial value is 0.
pointer const void * Specifies a offset of the first component of the first generic vertex attribute in the array in the data store of the buffer currently bound to the GL_ARRAY_BUFFER target. The initial value is 0.

描述

        glVertexAttribPointer、glVertexAttribIPointer 和 glVertexAttribLPointer 指定在索引索引处的通用顶点属性数组的位置和数据格式,以便在渲染时使用。size 指定每个属性的组件数,并且必须为 1、2、3、4 或 GL_BGRA。Type 指定每个组件的数据类型,Stride 指定从一个属性到下一个属性的字节步幅,允许将顶点和属性打包到单个数组中或存储在单独的数组中。

        对于 glVertexAttribPointer,如果规范化设置为 GL_TRUE,则表示以整数格式存储的值在访问并转换为浮点时将映射到范围 [-1,1](对于有符号值)或 [0,1](对于无符号值)。否则,值将直接转换为浮点数,而无需规范化。

         对于 glVertexAttribIPointer,仅接受整数类型GL_BYTE、GL_UNSIGNED_BYTE、GL_SHORT、GL_UNSIGNED_SHORT、GL_INT GL_UNSIGNED_INT。值始终保留为整数值。

        glVertexAttribLPointer 指定与使用 64 位双精度组件声明的着色器属性变量关联的通用顶点属性数组的状态。类型必须GL_DOUBLE。索引、大小和步幅的行为与 glVertexAttribPointer 和 glVertexAttribIPointer 所述。

        如果指针不为 NULL,则必须将非零命名的缓冲区对象绑定到GL_ARRAY_BUFFER目标(请参阅 glBindBuffer),否则将生成错误。指针被视为缓冲区对象数据存储中的字节偏移量。缓冲区对象绑定 (GL_ARRAY_BUFFER_BINDING) 保存为索引索引的通用顶点属性数组状态 (GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING)。

        指定通用顶点属性数组时,除了当前顶点数组缓冲区对象绑定外,大小、类型、规范化、步幅和指针将另存为顶点数组状态。

        要启用和禁用通用顶点属性数组,请调用 glEnableVertexAttribArray 和 glDisableVertexAttribArray with index。如果启用,则在调用 glDrawArrays、glMultiDrawArrays、glDrawElements、glMultiDrawElements 或 glDrawRangeElements 时使用通用顶点属性数组。

注意

        每个通用顶点属性数组最初都是禁用的,并且在调用 glDrawElements、glDrawRangeElements、glDrawArrays、glMultiDrawArray 或 glMultiDrawElements 时无法访问该数组。

        仅当 GL 版本为 4.4 或更高版本时,类型才接受 GL_UNSIGNED_INT_10F_11F_11F_REV。

参考

OpenGL 4 Reference Pages (khronos.org)

你可能感兴趣的:(OpenGL,翻译,规范说明书,OpenGL)