From addb1ae33714f1f77e8303f221a71a21e8b92169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20M=2E=20=C3=81=2E=20R=2E=20R?= Date: Sun, 26 May 2024 14:46:39 -0600 Subject: [PATCH] Adds two generic functions to set the value of uniform variables: uniform-float and uniform-integer. --- source/clog-webgl.lisp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/clog-webgl.lisp b/source/clog-webgl.lisp index bdf0dfc..abfabea 100644 --- a/source/clog-webgl.lisp +++ b/source/clog-webgl.lisp @@ -113,6 +113,8 @@ (active-attribute generic-function) (active-uniform generic-function) (uniform generic-function) + (uniform-float generic-function) + (uniform-integer generic-function) (program-info-log generic-function) (link-program generic-function) (use-program generic-function) @@ -1038,6 +1040,30 @@ Returns a GLint indicating the number of uniform blocks containing active unifor (query (gl obj) (format nil "getUniform(~A, ~A)" (script-id obj) (script-id location)))) +(defgeneric uniform-float (clog-webgl location x &optional y z w) + (:documentation "Sets the value of uniform at LOCATION.")) + +(defmethod uniform-float ((webgl clog-webgl) location x &optional y z w) + (execute webgl (cond + (w (format nil "uniform4fv(~A, new Float32Array([~F,~F,~F,~F]))" (script-id location) + (float x) (float y) (float z) (float w))) + (z (format nil "uniform3fv(~A, new Float32Array([~F,~F,~F]))" (script-id location) + (float x) (float y) (float z))) + (y (format nil "uniform2fv(~A, new Float32Array([~F,~F]))" (script-id location) + (float x) (float y))) + (x (format nil "uniform1fv(~A, new Float32Array([~F]))" (script-id location) + (float x)))))) + +(defgeneric uniform-integer (clog-webgl location x &optional y z w) + (:documentation "Sets the value of uniform at LOCATION.")) + +(defmethod uniform-integer ((webgl clog-webgl) location x &optional y z w) + (execute webgl (cond + (w (format nil "uniform4iv(~A, new Int32Array([~D,~D,~D,~D]))" (script-id location) x y z w)) + (z (format nil "uniform3iv(~A, new Int32Array([~D,~D,~D]))" (script-id location) x y z)) + (y (format nil "uniform2iv(~A, new Int32Array([~D,~D]))" (script-id location) x y)) + (x (format nil "uniform1iv(~A, new Int32Array([~D]))" (script-id location) x))))) + (defgeneric program-info-log (clog-webgl-program) (:documentation "Contains errors that occurred during failed linking or validation of WebGLProgram objects."))