<div dir="ltr"><div><div><div><div><div><div><div><div><div>This may not be the proper list (I'm tempted to cross-post to the clozure one), but I have to start somewhere.<br><br></div>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.<br>
<br></div>I don't have a minimal test-case to share, yet. That's my next step. I'm being lazy and asking before I start trying to trim pieces down. The best nutshell of the problem I have at the moment is that the callback in question looks like:<br>
<br>(cffi:defcallback window-sizer<br>    :void<br>  ((window glfw3::glfw-window) (width :int) (height :int))<br>  ;; Have to have the OpenGL context before we can do this.<br>  ;; Q: Should I be making that window's context current?<br>
  ;; A: Seems really stupid to think otherwise.<br>  (declare (ignore window))<br>  (format t "Resizing to ~A x ~A~%" width height)<br>  (gl:viewport 0 0 width height)<br>  (format t "Setting projecting matrix~%")<br>
  (gl:matrix-mode :projection)<br>  (gl:load-identity)<br>  (let ((ratio (/ width height)))<br>    (format t "Setting ortho: ~A~%" ratio)<br>    ;; This next line is failing here, pretty spectacularly.<br>    ;; with an error message that doesn't seem to make any sense.<br>
    ;; It appears to run fine (even if it does nothing) when <br>    ;; I run it throuh the REPL.<br>    (gl:ortho (- ratio) ratio -1 1 1 -1))<br>  (format t "Returning~%"))<br><br></div>The stack trace (FWIW) looks like:<br>
The value 17465867632912 is not of the expected type DOUBLE-FLOAT.<br>   [Condition of type TYPE-ERROR]<br><br>  0: (CFFI-CALLBACKS::|GLFW3-EXAMPLE::WINDOW-SIZER| 17465867632956)<br>      Locals:<br>        #:G7819 = 17465867632956<br>
        #:G7822 = #<A Foreign Pointer [stack-allocated] #x7F14B6B009E0><br>        GLFW3-EXAMPLE::WINDOW = #<A Foreign Pointer #x7F149C034C70><br>        GLFW3-EXAMPLE::WIDTH = 649<br>        GLFW3-EXAMPLE::HEIGHT = 502<br>
        COMMON-LISP:RATIO = 649/502<br>        CL-OPENGL-BINDINGS::LEFT = -649/502<br>        #:G7833 = -1.292828685258964D0<br>        #:G7834 = 1.292828685258964D0<br>        #:G7835 = -1.0D0<br>        #:G7836 = 1.0D0<br>
        #:G7837 = 1.0D0<br>        #:G7838 = -1.0D0<br>  1: (CCL::%PASCAL-FUNCTIONS% 5 17465867632956)<br>      Locals:<br>        INDEX = 5<br>        ARGS-PTR-FIXNUM = 17465867632956<br>        LISP-FUNCTION = #<Compiled-function CFFI-CALLBACKS::|GLFW3-EXAMPLE::WINDOW-SIZER| (Non-Global)  #x302001CF9B0F><br>
        WITHOUT-INTERRUPTS = NIL<br>        *CALLBACK-TRACE-P* = NIL<br>  2: (NIL #<Unknown Arguments>)<br>  3: (POLL-EVENTS)<br>  4: (CCL::CALL-CHECK-REGS POLL-EVENTS)<br>  5: (CCL::CHEAP-EVAL (POLL-EVENTS))<br><br>
</div>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?<br>
<br></div>The C signature of the callback function is<br>typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);<br><br></div>Is there something else I can supply that I didn't realize is important?<br><br></div>Just for the record, I'm much more interested in learning how I can diagnose and fix these sorts of problems for myself than anything else. I just seemed to run into a total dead end on google.<br>
<br></div>Thanks in advance,<br></div>James<br><br></div>