Reputation: 8509
this is what I found in the opengl documentation:
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.
but my problem is, I have no idea what the current vertex is. How do I set the current vertex? Can I use this to test weather my attributes that I've sent to opengl contain correct data?
Upvotes: 2
Views: 817
Reputation: 9144
glGetVertexAttrib
returns the value associated with a generic vertex attribute, which can be set with the glVertexAttrib
function.
In more detail, there are two types of attributes available in OpenGL:
glDrawArrays
) is executed.For example, let's say you enable two arrays for use as vertex attributes using glVertexAttribPointer
, and glEnableVertexAttribArray
, and then you render by calling glDrawArrays( GL_POINTS, 0, NumPoints )
. In this case, the bound vertex shader will be executed NumPoints
times, each time a new value read from each of the two arrays.
However, if you only enabled on array (say, vertex array zero), you could set an attribute value for attribute one using of the glVertexAttrib
functions. If you once again rendering by calling glDrawArrays( GL_POINTS, 0, NumPoints )
, the vertex shader would again be executed NumPoints
times, with attribute zero's values being update with values from the enabled vertex attribute array, but attribute one's values being "constant", and set to the value provided by glVertexAttrib
.
Upvotes: 3