Skip to content

Commit 8ee41e7

Browse files
committed
Shader: Support setting booleans
1 parent 764bd02 commit 8ee41e7

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
@@ -582,6 +582,54 @@ def uniform_4uiv(self, name, value, count=1):
582582
uniform = self.uniform_check(name, GL.GL_UNSIGNED_INT_VEC4)
583583
GL.glUniform4uiv(uniform.location, count, value)
584584

585+
# --- Booleans ---
586+
587+
def uniform_1b(self, name, value):
588+
"""
589+
Sets an bool
590+
591+
:param name: Name of the uniform
592+
:param value: Integer value
593+
"""
594+
uniform = self.uniform_check(name, GL.GL_BOOL)
595+
GL.glUniform1i(uniform.location, value)
596+
597+
def uniform_2b(self, name, x, y):
598+
"""
599+
Sets an bvec2
600+
601+
:param name: Uniform name
602+
:param x: bool
603+
:param y: bool
604+
"""
605+
uniform = self.uniform_check(name, GL.GL_BOOL_VEC2)
606+
GL.glUniform2i(uniform.location, x, y)
607+
608+
def uniform_3b(self, name, x, y, z):
609+
"""
610+
Sets an bvec3
611+
612+
:param name: Uniform name
613+
:param x: bool
614+
:param y: bool
615+
:param z: bool
616+
"""
617+
uniform = self.uniform_check(name, GL.GL_BOOL_VEC3)
618+
GL.glUniform3i(uniform.location, x, y, z)
619+
620+
def uniform_4b(self, name, x, y, z, w):
621+
"""
622+
Sets an bvec4
623+
624+
:param name: Uniform name
625+
:param x: bool
626+
:param y: bool
627+
:param z: bool
628+
:param w: bool
629+
"""
630+
uniform = self.uniform_check(name, GL.GL_BOOL_VEC4)
631+
GL.glUniform4i(uniform.location, x, y, z, w)
632+
585633
# --- Matrices ---
586634

587635
def uniform_mat3(self, name, mat):

0 commit comments

Comments
 (0)