[cl-opengl-devel] uniformf problem (and patch)

Billy web at lamberta.org
Fri Oct 2 04:57:24 UTC 2009


Hi, I was running into some problems setting a uniform variable with
UNIFORMF - I could give it a number, but for some reason it wasn't
evaluating anything else passed to it, reporting "The value X is not
of type REAL."

Anyway with some discussion on #lisp, stassats came up with a little
patch that seems to work.

Here's my original effort that had problems: http://paste.lisp.org/display/88062

And the patch:
diff -rN -u old-cl-opengl/gl/opengl.lisp new-cl-opengl/gl/opengl.lisp
--- old-cl-opengl/gl/opengl.lisp        2009-10-02 08:37:02.397150466 +0400
+++ new-cl-opengl/gl/opengl.lisp        2009-10-02 08:37:02.454149983 +0400
@@ -633,11 +633,15 @@

 (define-compiler-macro uniformf (&whole form location x &optional y z w)
   (declare (ignore form))
-  (cond
-    (w `(%gl:uniform-4f ,location ,(float x) ,(float y) ,(float z) ,(float w)))
-    (z `(%gl:uniform-3f ,location ,(float x) ,(float y) ,(float z)))
-    (y `(%gl:uniform-2f ,location ,(float x) ,(float y)))
-    (x `(%gl:uniform-1f ,location ,(float x)))))
+  (flet ((float* (x)
+           (if (numberp x)
+               (float x)
+               `(float ,x))))
+    (cond
+      (w `(%gl:uniform-4f ,location ,(float* x) ,(float* y) ,(float*
z) ,(float* w)))
+      (z `(%gl:uniform-3f ,location ,(float* x) ,(float* y) ,(float* z)))
+      (y `(%gl:uniform-2f ,location ,(float* x) ,(float* y)))
+      (x `(%gl:uniform-1f ,location ,(float* x))))))

 (defun uniform-matrix (location dim matrices &optional (transpose t))
   (check-type dim (integer 2 4))




More information about the cl-opengl-devel mailing list