Skip to content

Commit e8da817

Browse files
committed
Shader: Support setting signed integer arrays
1 parent 77ed921 commit e8da817

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

demosys/opengl/shader.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,52 @@ def uniform_4i(self, name, x, y, z, w):
442442
uniform = self.uniform_check(name, GL.GL_INT_VEC4)
443443
GL.glUniform4i(uniform.location, x, y, z, w)
444444

445+
# --- Signed Integers Arrays ---
446+
447+
def uniform_1iv(self, name, value, count=1):
448+
"""
449+
Sets an int
450+
451+
:param name: Name of the uniform
452+
:param value: integer array
453+
:param count: Length of the uniform array (default 1)
454+
"""
455+
uniform = self.uniform_check(name, GL.GL_INT)
456+
GL.glUniform1iv(uniform.location, count, value)
457+
458+
def uniform_2iv(self, name, value, count=1):
459+
"""
460+
Sets an ivec2
461+
462+
:param name: Uniform name
463+
:param value: integer array
464+
:param count: Length of the uniform array (default 1)
465+
"""
466+
uniform = self.uniform_check(name, GL.GL_INT_VEC2)
467+
GL.glUniform2iv(uniform.location, count, value)
468+
469+
def uniform_3iv(self, name, value, count=1):
470+
"""
471+
Sets an ivec3
472+
473+
:param name: Uniform name
474+
:param value: integer array
475+
:param count: Length of the uniform array (default 1)
476+
"""
477+
uniform = self.uniform_check(name, GL.GL_INT_VEC3)
478+
GL.glUniform3iv(uniform.location, count, value)
479+
480+
def uniform_4iv(self, name, value, count=1):
481+
"""
482+
Sets an ivec4
483+
484+
:param name: Uniform name
485+
:param value: integer array
486+
:param count: Length of the uniform array (default 1)
487+
"""
488+
uniform = self.uniform_check(name, GL.GL_INT_VEC4)
489+
GL.glUniform4iv(uniform.location, count, value)
490+
445491
# --- Unsigned Integers ---
446492

447493
def uniform_1ui(self, name, value):

0 commit comments

Comments
 (0)