Skip to content

Commit f5607af

Browse files
committed
Shader: Support setting unsigned integers
1 parent d32ee92 commit f5607af

File tree

1 file changed

+51
-3
lines changed

1 file changed

+51
-3
lines changed

demosys/opengl/shader.py

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def uniform_4f(self, name, x, y, z, w):
258258

259259
def uniform_1i(self, name, value):
260260
"""
261-
Sets an uint or int
261+
Sets an int
262262
263263
:param name: Name of the uniform
264264
:param value: Integer value
@@ -269,7 +269,7 @@ def uniform_1i(self, name, value):
269269
def uniform_2i(self, name, x, y):
270270
"""
271271
Sets an ivec2
272-
272+
273273
:param name: Uniform name
274274
:param x: Integer
275275
:param y: Integer
@@ -300,7 +300,55 @@ def uniform_4i(self, name, x, y, z, w):
300300
:param w: Integer
301301
"""
302302
uniform = self.uniform_check(name, GL.GL_INT_VEC4)
303-
GL.glUniform3i(uniform.location, x, y, z, w)
303+
GL.glUniform4i(uniform.location, x, y, z, w)
304+
305+
# --- Unsigned Integers ---
306+
307+
def uniform_1ui(self, name, value):
308+
"""
309+
Sets an uint
310+
311+
:param name: Name of the uniform
312+
:param value: Integer value
313+
"""
314+
uniform = self.uniform_check(name, GL.GL_UNSIGNED_INT)
315+
GL.glUniform1ui(uniform.location, value)
316+
317+
def uniform_2ui(self, name, x, y):
318+
"""
319+
Sets an uvec2
320+
321+
:param name: Uniform name
322+
:param x: Integer
323+
:param y: Integer
324+
"""
325+
uniform = self.uniform_check(name, GL.GL_UNSIGNED_INT_VEC2)
326+
GL.glUniform2ui(uniform.location, x, y)
327+
328+
def uniform_3ui(self, name, x, y, z):
329+
"""
330+
Sets an uvec3
331+
332+
:param name: Uniform name
333+
:param x: Integer
334+
:param y: Integer
335+
:param z: Integer
336+
"""
337+
uniform = self.uniform_check(name, GL.GL_UNSIGNED_INT_VEC3)
338+
GL.glUniform3ui(uniform.location, x, y, z)
339+
340+
def uniform_4ui(self, name, x, y, z, w):
341+
"""
342+
Sets an uvec4
343+
344+
:param name: Uniform name
345+
:param x: Integer
346+
:param y: Integer
347+
:param z: Integer
348+
:param w: Integer
349+
"""
350+
uniform = self.uniform_check(name, GL.GL_UNSIGNED_INT_VEC4)
351+
GL.glUniform4ui(uniform.location, x, y, z, w)
304352

305353
# --- Matrices ---
306354

0 commit comments

Comments
 (0)