Skip to content

Commit d32ee92

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

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

demosys/opengl/shader.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,54 @@ def uniform_4f(self, name, x, y, z, w):
254254
uniform = self.uniform_check(name, GL.GL_FLOAT_VEC4)
255255
GL.glUniform4f(uniform.location, x, y, z, w)
256256

257+
# --- Signed Integers ---
258+
259+
def uniform_1i(self, name, value):
260+
"""
261+
Sets an uint or int
262+
263+
:param name: Name of the uniform
264+
:param value: Integer value
265+
"""
266+
uniform = self.uniform_check(name, GL.GL_INT)
267+
GL.glUniform1i(uniform.location, value)
268+
269+
def uniform_2i(self, name, x, y):
270+
"""
271+
Sets an ivec2
272+
273+
:param name: Uniform name
274+
:param x: Integer
275+
:param y: Integer
276+
"""
277+
uniform = self.uniform_check(name, GL.GL_INT_VEC2)
278+
GL.glUniform2i(uniform.location, x, y)
279+
280+
def uniform_3i(self, name, x, y, z):
281+
"""
282+
Sets an ivec3
283+
284+
:param name: Uniform name
285+
:param x: Integer
286+
:param y: Integer
287+
:param z: Integer
288+
"""
289+
uniform = self.uniform_check(name, GL.GL_INT_VEC3)
290+
GL.glUniform3i(uniform.location, x, y, z)
291+
292+
def uniform_4i(self, name, x, y, z, w):
293+
"""
294+
Sets an ivec4
295+
296+
:param name: Uniform name
297+
:param x: Integer
298+
:param y: Integer
299+
:param z: Integer
300+
:param w: Integer
301+
"""
302+
uniform = self.uniform_check(name, GL.GL_INT_VEC4)
303+
GL.glUniform3i(uniform.location, x, y, z, w)
304+
257305
# --- Matrices ---
258306

259307
def uniform_mat3(self, name, mat):

0 commit comments

Comments
 (0)