hsalokor / rkt-glfw

Racket bindings for GLFW library
1 stars 5 forks source link

GLFW callback setters do not work #4

Open jstimpfle opened 3 years ago

jstimpfle commented 3 years ago

Hello,

I tried out this library and with my brand new racket installation, the GLFW function setter functions did not work. For example,

#lang racket/base

(require glfw3)

(define (myKeyCallback win a b c d) (println "Key"))

(glfwInit)
(define window (glfwCreateWindow 800 600 "MyWindow" #f #f))
(glfwSetKeyCallback window myKeyCallback)

would result in an error

_ptr: cannot be used to send values to C

The reason seems to be that all the GLFW function types in this library are defined like

(GLFWkeyfun (_ptr o (_fun _pointer _int _int _int _int -> _void)))

On my computer, the above program runs without error (and catches key presses) if I remove the _ptr wrap around the _fun spec:

(GLFWkeyfun (_fun _pointer _int _int _int _int -> _void))

Maybe this is due to a change in the Racket FFI? Maybe I was doing something wrong? I can't know, I'm just trying Racket for the first time. If it's a problem in this library, it would be great if you could update.

Kind regards, Jens

HectareaGalbis commented 3 years ago

@jstimpfle I was having the same problem. I think that's an error. Also, the file glfw.rkt is outdated. I'm going to update it in the next days. Meanwhile, consider using this branch (still unfinished).

HectareaGalbis commented 3 years ago

I have made a pull request with the update.