Skip to content

Commit 7e80dbf

Browse files
committed
Shader: Support setting double uniforms
1 parent 01f5ccc commit 7e80dbf

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
@@ -300,6 +300,54 @@ def uniform_4fv(self, name, value, count=1):
300300
uniform = self.uniform_check(name, GL.GL_FLOAT_VEC4)
301301
GL.glUniform4fv(uniform.location, count, value)
302302

303+
# --- Double precision floats ---
304+
305+
def uniform_1d(self, name, value):
306+
"""
307+
Set a double uniform
308+
309+
:param name: Name of the uniform
310+
:param value: double value
311+
"""
312+
uniform = self.uniform_check(name, GL.GL_DOUBLE)
313+
GL.glUniform1d(uniform.location, value)
314+
315+
def uniform_2d(self, name, x, y):
316+
"""
317+
Set a dvec2 uniform
318+
319+
:param name: name of the uniform
320+
:param x: double value
321+
:param y: double value
322+
"""
323+
uniform = self.uniform_check(name, GL.GL_DOUBLE_VEC2)
324+
GL.glUniform2d(uniform.location, x, y)
325+
326+
def uniform_3d(self, name, x, y, z):
327+
"""
328+
Set a dvec3 uniform
329+
330+
:param name: Name of the uniform
331+
:param x: double value
332+
:param y: double value
333+
:param z: double value
334+
"""
335+
uniform = self.uniform_check(name, GL.GL_DOUBLE_VEC3)
336+
GL.glUniform3d(uniform.location, x, y, z)
337+
338+
def uniform_4d(self, name, x, y, z, w):
339+
"""
340+
Set a dvec4 uniform
341+
342+
:param name: Name of the uniform
343+
:param x: double value
344+
:param y: double value
345+
:param z: double value
346+
:param w: double value
347+
"""
348+
uniform = self.uniform_check(name, GL.GL_DOUBLE_VEC4)
349+
GL.glUniform4d(uniform.location, x, y, z, w)
350+
303351
# --- Signed Integers ---
304352

305353
def uniform_1i(self, name, value):

0 commit comments

Comments
 (0)