Debugging a Callback
Luís Oliveira
luismbo at gmail.com
Wed Jun 19 10:18:17 UTC 2013
James Ashley <james.ashley at gmail.com> writes:
> (let ((ratio (/ width height)))
> (format t "Setting ortho: ~A~%" ratio)
> ;; This next line is failing here, pretty spectacularly.
> ;; with an error message that doesn't seem to make any sense.
> ;; It appears to run fine (even if it does nothing) when
> ;; I run it throuh the REPL.
> (gl:ortho (- ratio) ratio -1 1 1 -1))
[...]
> The value 17465867632912 is not of the expected type DOUBLE-FLOAT.
[...]
> COMMON-LISP:RATIO = 649/502
> CL-OPENGL-BINDINGS::LEFT = -649/502
[...]
> Does anyone have a suggestion about where I should look to try to
> figure out where that value it's complaining about comes from? Or
> what's expecting the DOUBLE-FLOAT? Is there something else in the
> stack trace (or anywhere else) that I'm just totally missing due to
> my noobishness?
The stack trace is not being very helpful, no. GL:ORTHO tries to coerce
each of its arguments into doubles via (float x 1.0d0). Maybe
something's going wrong in that process? There's also inlining going on,
as the GL:ORTHO is defined via %GL:DEFGLFUN which might not get
triggered when you try it out from the REPL.
So, I'd try to (1) convert the ratio to double before passing it to
GL:ORTHO and maybe the other arguments as well, (2) call glOrtho() using
plain CFFI:FOREIGN-FUNCALL, (3) use CCL:EXTERNAL-CALL. You can quickly
figure out how to get the appropriate CCL:EXTERNAL-CALL form by
macroexpansing CFFI:FOREIGN-FUNCALL.
HTH,
--
Luís Oliveira
http://kerno.org/~luis
More information about the cffi-devel
mailing list