Search
lxdream.org :: lxdream :: r1206:a9b41bcb8410
lxdream 0.9.1
released Jun 29
Download Now
changeset1206:a9b41bcb8410
parent1205:a486ac64f34b
child1207:f7ca985659c6
authornkeynes
dateMon Jan 30 23:11:03 2012 +1000 (7 years ago)
Add support for matrix uniforms + vertex attribs
src/pvr2/gl_sl.c
src/pvr2/glutil.h
1.1 --- a/src/pvr2/gl_sl.c Mon Jan 30 20:11:08 2012 +1000
1.2 +++ b/src/pvr2/gl_sl.c Mon Jan 30 23:11:03 2012 +1000
1.3 @@ -156,11 +156,21 @@
1.4 return glGetUniformLocationARB(program, name);
1.5 }
1.6
1.7 +static inline GLint glsl_get_attrib_location_prim(gl_program_t program, const char *name)
1.8 +{
1.9 + return glGetAttribLocationARB(program, name);
1.10 +}
1.11 +
1.12 static inline void glsl_set_uniform_int_prim(GLint location, GLint value)
1.13 {
1.14 glUniform1iARB(location,value);
1.15 }
1.16
1.17 +static inline void glsl_set_uniform_mat4_prim(GLint location, GLfloat *value)
1.18 +{
1.19 + glUniformMatrix4fvARB(location, 1, GL_FALSE, value);
1.20 +}
1.21 +
1.22 #elif HAVE_OPENGL_SHADER
1.23
1.24 gboolean glsl_is_supported()
1.25 @@ -278,6 +288,15 @@
1.26 glUniform1i(location, value);
1.27 }
1.28
1.29 +static inline void glsl_set_uniform_mat4_prim(GLint location, GLfloat *value)
1.30 +{
1.31 + glUniformMatrix4fv(location, 1, GL_TRUE, value);
1.32 +}
1.33 +
1.34 +static inline GLint glsl_get_attrib_location_prim(gl_program_t program, const char *name)
1.35 +{
1.36 + return glGetAttribLocation(program, name);
1.37 +}
1.38 #else
1.39 gboolean glsl_is_supported()
1.40 {
1.41 @@ -324,6 +343,15 @@
1.42 static inline void glsl_set_uniform_int_prim(GLint location, GLint value)
1.43 {
1.44 }
1.45 +
1.46 +static inline void glsl_set_uniform_mat4_prim(GLint location, GLfloat *value)
1.47 +{
1.48 +}
1.49 +
1.50 +static inline GLint glsl_get_attrib_location_prim(gl_program_t program, const char *name)
1.51 +{
1.52 + return 0;
1.53 +}
1.54 #endif
1.55
1.56 /****************************************************************************/
1.57 @@ -435,6 +463,13 @@
1.58 return glsl_get_uniform_location_prim(program_array[program], name);
1.59 }
1.60
1.61 +GLint glsl_get_attrib_location( unsigned program, const char *name )
1.62 +{
1.63 + assert( program >= 0 && program <= GLSL_LAST_PROGRAM );
1.64 +
1.65 + return glsl_get_attrib_location_prim(program_array[program], name);
1.66 +}
1.67 +
1.68 void glsl_set_uniform_int( unsigned program, const char *name, GLint value )
1.69 {
1.70 assert( program >= 0 && program <= GLSL_LAST_PROGRAM );
1.71 @@ -442,6 +477,13 @@
1.72 glsl_set_uniform_int_prim(location, value);
1.73 }
1.74
1.75 +void glsl_set_uniform_mat4( unsigned program, const char *name, GLfloat *value )
1.76 +{
1.77 + assert( program >= 0 && program <= GLSL_LAST_PROGRAM );
1.78 + GLint location = glsl_get_uniform_location_prim(program_array[program], name);
1.79 + glsl_set_uniform_mat4_prim(location, value);
1.80 +}
1.81 +
1.82 void glsl_clear_shader()
1.83 {
1.84 glsl_use_program(0);
2.1 --- a/src/pvr2/glutil.h Mon Jan 30 20:11:08 2012 +1000
2.2 +++ b/src/pvr2/glutil.h Mon Jan 30 23:11:03 2012 +1000
2.3 @@ -65,6 +65,8 @@
2.4 void glsl_clear_shader();
2.5 GLint glsl_get_uniform_location( unsigned program, const char *name );
2.6 void glsl_set_uniform_int( unsigned program, const char *name, GLint value );
2.7 +void glsl_set_uniform_mat4( unsigned program, const char *name, GLfloat *value );
2.8 +GLint glsl_get_attrib_location(unsigned program, const char *name);
2.9
2.10 /* Convenience formatting function for driver use */
2.11 void fprint_extensions( FILE *out, const char *extensions );
.