这是我在opengl文档中找到的:
void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params);
GL_CURRENT_VERTEX_ATTRIB
params returns four
values that represent the current value for the
generic vertex attribute specified by index. Generic
vertex attribute 0 is unique in that it has no
current state, so an error will be generated if
index is 0. The initial value
for all other generic vertex attributes is
(0,0,0,1).
glGetVertexAttribdv and glGetVertexAttribfv
return the current attribute values as four single-precision floating-point values;
glGetVertexAttribiv reads them as floating-point values and
converts them to four integer values; glGetVertexAttribIiv and
glGetVertexAttribIuiv read and return them as signed or unsigned
integer values, respectively; glGetVertexAttribLdv reads and returns
them as four double-precision floating-point values.
但我的问题是,我不知道当前的顶点是什么。如何设置当前顶点?我可以使用它来测试天气,我发送给opengl的属性包含正确的数据吗?
答案 0 :(得分:3)
glGetVertexAttrib
返回与通用顶点属性关联的值,可以使用glVertexAttrib
函数设置。
更详细地说,OpenGL中有两种类型的属性:
glDrawArrays
)时处理的已启用顶点数组中的每个顶点更新的那些。例如,假设您使用glVertexAttribPointer
和glEnableVertexAttribArray
启用两个数组作为顶点属性,然后通过调用glDrawArrays( GL_POINTS, 0, NumPoints )
进行渲染。在这种情况下,每次从两个数组中的每一个读取一个新值时,绑定顶点着色器将执行NumPoints
次。
但是,如果仅在数组上启用(例如,顶点数组为零),则可以使用glVertexAttrib
函数为属性1设置属性值。如果再次通过调用glDrawArrays( GL_POINTS, 0, NumPoints )
进行渲染,顶点着色器将再次执行NumPoints
次,属性零值将使用启用的顶点属性数组中的值进行更新,但属性1的值为“常量” ,并设置为glVertexAttrib
提供的值。