19 Jun 2013 04:16
Debugging a Callback
James Ashley <james.ashley <at> gmail.com>
2013-06-19 02:16:21 GMT
2013-06-19 02:16:21 GMT
This may not be the proper list (I'm tempted to cross-post to the clozure one), but I have to start somewhere.
I'm putting together a wrapper around the recently released version of the C library GLFW. In the middle of a callback (written in CL and mostly using cl-glfw), I'm winding up in the debugger, and I'm not having any luck figuring out why.(cffi:defcallback window-sizer
:void
((window glfw3::glfw-window) (width :int) (height :int))
;; Have to have the OpenGL context before we can do this.
;; Q: Should I be making that window's context current?
;; A: Seems really stupid to think otherwise.
(declare (ignore window))
(format t "Resizing to ~A x ~A~%" width height)
(gl:viewport 0 0 width height)
(format t "Setting projecting matrix~%")
(gl:matrix-mode :projection)
(gl:load-identity)
(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))
(format t "Returning~%"))
The value 17465867632912 is not of the expected type DOUBLE-FLOAT.
[Condition of type TYPE-ERROR]
0: (CFFI-CALLBACKS::|GLFW3-EXAMPLE::WINDOW-SIZER| 17465867632956)
Locals:
#:G7819 = 17465867632956
#:G7822 = #<A Foreign Pointer [stack-allocated] #x7F14B6B009E0>
GLFW3-EXAMPLE::WINDOW = #<A Foreign Pointer #x7F149C034C70>
GLFW3-EXAMPLE::WIDTH = 649
GLFW3-EXAMPLE::HEIGHT = 502
COMMON-LISP:RATIO = 649/502
CL-OPENGL-BINDINGS::LEFT = -649/502
#:G7833 = -1.292828685258964D0
#:G7834 = 1.292828685258964D0
#:G7835 = -1.0D0
#:G7836 = 1.0D0
#:G7837 = 1.0D0
#:G7838 = -1.0D0
1: (CCL::%PASCAL-FUNCTIONS% 5 17465867632956)
Locals:
INDEX = 5
ARGS-PTR-FIXNUM = 17465867632956
LISP-FUNCTION = #<Compiled-function CFFI-CALLBACKS::|GLFW3-EXAMPLE::WINDOW-SIZER| (Non-Global) #x302001CF9B0F>
WITHOUT-INTERRUPTS = NIL
*CALLBACK-TRACE-P* = NIL
2: (NIL #<Unknown Arguments>)
3: (POLL-EVENTS)
4: (CCL::CALL-CHECK-REGS POLL-EVENTS)
5: (CCL::CHEAP-EVAL (POLL-EVENTS))
typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);

RSS Feed