Skip to content

Commit 90a7b4a

Browse files
committed
Shader: Support setting double arrays
1 parent 7e80dbf commit 90a7b4a

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
@@ -348,6 +348,52 @@ def uniform_4d(self, name, x, y, z, w):
348348
uniform = self.uniform_check(name, GL.GL_DOUBLE_VEC4)
349349
GL.glUniform4d(uniform.location, x, y, z, w)
350350

351+
# --- Double precision floats arrays ---
352+
353+
def uniform_1dv(self, name, value, count=1):
354+
"""
355+
Set a double uniform
356+
357+
:param name: Name of the uniform
358+
:param value: float array
359+
:param count: Length of the uniform array (default 1)
360+
"""
361+
uniform = self.uniform_check(name, GL.GL_DOUBLE)
362+
GL.glUniform1dv(uniform.location, count, value)
363+
364+
def uniform_2dv(self, name, value, count=1):
365+
"""
366+
Set a dvec2 uniform
367+
368+
:param name: name of the uniform
369+
:param value: float array
370+
:param count: Length of the uniform array (default 1)
371+
"""
372+
uniform = self.uniform_check(name, GL.GL_DOUBLE_VEC2)
373+
GL.glUniform2dv(uniform.location, count, value)
374+
375+
def uniform_3dv(self, name, value, count=1):
376+
"""
377+
Set a dvec3 uniform
378+
379+
:param name: Name of the uniform
380+
:param value: float array
381+
:param count: Length of the uniform array (default 1)
382+
"""
383+
uniform = self.uniform_check(name, GL.GL_DOUBLE_VEC3)
384+
GL.glUniform3dv(uniform.location, count, value)
385+
386+
def uniform_4dv(self, name, value, count=1):
387+
"""
388+
Set a dvec4 uniform
389+
390+
:param name: Name of the uniform
391+
:param value: float array
392+
:param count: Length of the uniform array (default 1)
393+
"""
394+
uniform = self.uniform_check(name, GL.GL_DOUBLE_VEC4)
395+
GL.glUniform4dv(uniform.location, count, value)
396+
351397
# --- Signed Integers ---
352398

353399
def uniform_1i(self, name, value):

0 commit comments

Comments
 (0)