现在的位置: 首页 > 综合 > 正文

graphics shaders 2 attribute,uniform

2018年05月27日 ⁄ 综合 ⁄ 共 1661字 ⁄ 字号 评论关闭

Notice that the glVertexAttrib* routines do not take a program
handle as one of their arguments. Since you set the attribute variables
as you do the drawing, it is assumed that the intended shader program
has already been made active when glVertexAttrib* is called.

Notice that none of these glUniform* routines take a program handle as
one of its arguments. Those routines set uniform variables in the currently
active shader program. So be sure that you call glUseProgram( ) on
the correct program before setting that program’s variables.
However, there is another set of GLSL API routines that let you
specify the program. They look like this:
glProgramUniform*( program,loc, count, value(s) );

The first way sets scalar or simple vector data with the function glUniform{i}{t}(GLint location, TYPE val)
where i can be 1, 2, 3, or 4, depending on the dimension of the variable, and t can be either f or i, depending on whether the type’s base is floating-point
or integer. The function causes the value of the parameter val to be loaded into the location indicated. This parameter can be a simple vec1, vec2, vec3, vec4,
ivec1, ivec2, ivec3, or ivec4, but not an array of these types.

The second way sets array (vector) data with glUniform{i}{t}v( GLint location, GLuint length, const TYPE *val )
where the meanings i and t are the same, but the data in val is a vector of the specified type (including vec* and ivec*) whose length is length.

Finally, the third way sets matrices, and is glUniformMatrix{i}fv( GLint location, GLuint count,GLboolean transpose, const GLfloat *val )
If i has the value 2, *val must be a 2 × 2 matrix; if 3, a 3 × 3 matrix; and if 4, a 4 × 4 matrix. If transpose has value GLfalse, the matrix is taken to be in standard
OpenGL column matrix order, while if transpose has value GLtrue, the matrix is taken to be in row-major order. The value of count is the number of
matrices that are being passed, so if you are only passing a single matrix, that value is 1.

抱歉!评论已关闭.