Add initial support for boolean Uniform types.
@@ -21,10 +21,16 @@ shader_types = {
_uniform_getters = {
GLint: glGetUniformiv,
GLfloat: glGetUniformfv,
+ GLboolean: glGetUniformiv,
}
_uniform_setters = {
# uniform type: (gl_type, setter, length, count)
+ GL_BOOL: (GLint, glUniform1iv, 1, 1),
+ GL_BOOL_VEC2: (GLint, glUniform1iv, 2, 1),
+ GL_BOOL_VEC3: (GLint, glUniform1iv, 3, 1),
+ GL_BOOL_VEC4: (GLint, glUniform1iv, 4, 1),
+
GL_INT: (GLint, glUniform1iv, 1, 1),
GL_INT_VEC2: (GLint, glUniform2iv, 2, 1),
GL_INT_VEC3: (GLint, glUniform3iv, 3, 1),
@@ -36,7 +42,6 @@ _uniform_setters = {
GL_FLOAT_VEC4: (GLfloat, glUniform4fv, 4, 1),
GL_SAMPLER_1D: (GLint, glUniform1iv, 1, 1),
-
GL_SAMPLER_2D: (GLint, glUniform1iv, 1, 1),
GL_SAMPLER_2D_ARRAY: (GLint, glUniform1iv, 1, 1),
@@ -119,13 +124,10 @@ class _Uniform:
c_array = (gl_type * length)()
ptr = cast(c_array, POINTER(gl_type))
- self.get = _create_getter_func(program, location, gl_getter, c_array, length)
- self.set = _create_setter_func(location, gl_setter, c_array, length, count, ptr, is_matrix)
-
- def __repr__(self):
- return f"Uniform('{self.name}', location={self.location}, length={self.length}, count={self.count})"
-
+ self.get = self._create_getter_func(program, location, gl_getter, c_array, length)
+ self.set = self._create_setter_func(location, gl_setter, c_array, length, count, ptr, is_matrix)
+ @staticmethod
def _create_getter_func(program_id, location, gl_getter, c_array, length):
"""Factory function for creating simplified Uniform getters"""
@@ -140,7 +142,7 @@ def _create_getter_func(program_id, location, gl_getter, c_array, length):
return getter_func
-
+ @staticmethod
def _create_setter_func(location, gl_setter, c_array, length, count, ptr, is_matrix):
"""Factory function for creating simplified Uniform setters"""
@@ -163,6 +165,9 @@ def _create_setter_func(location, gl_setter, c_array, length, count, ptr, is_mat
return setter_func
+ def __repr__(self):
+ return f"Uniform('{self.name}', location={self.location}, length={self.length}, count={self.count})"
+
class Shader:
"""OpenGL Shader object"""
