diff options
author | Brian Paul <brianp@vmware.com> | 2009-08-12 17:25:49 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2009-08-12 17:28:45 -0600 |
commit | f989727f4c1193a05b44e596411efa13a6d24717 (patch) | |
tree | ed841f737073bc76220ebff2ad8241beadcdff56 /src/util | |
parent | 45825b116ba39074ffbe89dec7e402895ad2df00 (diff) |
progs/glsl: change uniform_info::type field to use GLSL vector types
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/shaderutil.c | 107 | ||||
-rw-r--r-- | src/util/shaderutil.h | 4 |
2 files changed, 17 insertions, 94 deletions
diff --git a/src/util/shaderutil.c b/src/util/shaderutil.c index f057adf5..23325211 100644 --- a/src/util/shaderutil.c +++ b/src/util/shaderutil.c @@ -130,21 +130,26 @@ SetUniformValues(GLuint program, struct uniform_info uniforms[]) uniforms[i].location = glGetUniformLocation(program, uniforms[i].name); - switch (uniforms[i].size) { - case 1: - if (uniforms[i].type == GL_INT) - glUniform1i(uniforms[i].location, - (GLint) uniforms[i].value[0]); - else - glUniform1fv(uniforms[i].location, 1, uniforms[i].value); + switch (uniforms[i].type) { + case GL_INT: + case GL_SAMPLER_1D: + case GL_SAMPLER_2D: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_2D_RECT_ARB: + glUniform1i(uniforms[i].location, + (GLint) uniforms[i].value[0]); + break; + case GL_FLOAT: + glUniform1fv(uniforms[i].location, 1, uniforms[i].value); break; - case 2: + case GL_FLOAT_VEC2: glUniform2fv(uniforms[i].location, 1, uniforms[i].value); break; - case 3: + case GL_FLOAT_VEC3: glUniform3fv(uniforms[i].location, 1, uniforms[i].value); break; - case 4: + case GL_FLOAT_VEC4: glUniform4fv(uniforms[i].location, 1, uniforms[i].value); break; default: @@ -171,52 +176,6 @@ GetUniforms(GLuint program, struct uniform_info uniforms[]) glGetActiveUniform(program, i, 100, &len, &size, &type, name); uniforms[i].name = strdup(name); - switch (type) { - case GL_FLOAT: - size = 1; - type = GL_FLOAT; - break; - case GL_FLOAT_VEC2: - size = 2; - type = GL_FLOAT; - break; - case GL_FLOAT_VEC3: - size = 3; - type = GL_FLOAT; - break; - case GL_FLOAT_VEC4: - size = 4; - type = GL_FLOAT; - break; - case GL_INT: - size = 1; - type = GL_INT; - break; - case GL_INT_VEC2: - size = 2; - type = GL_INT; - break; - case GL_INT_VEC3: - size = 3; - type = GL_INT; - break; - case GL_INT_VEC4: - size = 4; - type = GL_INT; - break; - case GL_FLOAT_MAT3: - /* XXX fix me */ - size = 3; - type = GL_FLOAT; - break; - case GL_FLOAT_MAT4: - /* XXX fix me */ - size = 4; - type = GL_FLOAT; - break; - default: - abort(); - } uniforms[i].size = size; uniforms[i].type = type; uniforms[i].location = glGetUniformLocation(program, name); @@ -267,42 +226,6 @@ GetAttribs(GLuint program, struct attrib_info attribs[]) glGetActiveAttrib(program, i, 100, &len, &size, &type, name); attribs[i].name = strdup(name); - switch (type) { - case GL_FLOAT: - size = 1; - type = GL_FLOAT; - break; - case GL_FLOAT_VEC2: - size = 2; - type = GL_FLOAT; - break; - case GL_FLOAT_VEC3: - size = 3; - type = GL_FLOAT; - break; - case GL_FLOAT_VEC4: - size = 4; - type = GL_FLOAT; - break; - case GL_INT: - size = 1; - type = GL_INT; - break; - case GL_INT_VEC2: - size = 2; - type = GL_INT; - break; - case GL_INT_VEC3: - size = 3; - type = GL_INT; - break; - case GL_INT_VEC4: - size = 4; - type = GL_INT; - break; - default: - abort(); - } attribs[i].size = size; attribs[i].type = type; attribs[i].location = glGetAttribLocation(program, name); diff --git a/src/util/shaderutil.h b/src/util/shaderutil.h index 22dc4dc4..0a6be026 100644 --- a/src/util/shaderutil.h +++ b/src/util/shaderutil.h @@ -7,7 +7,7 @@ struct uniform_info { const char *name; GLuint size; /**< number of value[] elements: 1, 2, 3 or 4 */ - GLenum type; /**< GL_FLOAT or GL_INT */ + GLenum type; /**< GL_FLOAT, GL_FLOAT_VEC4, GL_INT, etc */ GLfloat value[4]; GLint location; /**< filled in by InitUniforms() */ }; @@ -19,7 +19,7 @@ struct attrib_info { const char *name; GLuint size; /**< number of value[] elements: 1, 2, 3 or 4 */ - GLenum type; /**< GL_FLOAT or GL_INT */ + GLenum type; /**< GL_FLOAT, GL_FLOAT_VEC4, GL_INT, etc */ GLint location; }; |