cl-raylib icon indicating copy to clipboard operation
cl-raylib copied to clipboard

Functions that require pointers signal error

Open compufox opened this issue 4 years ago • 2 comments

I could be doing this wrong (I'm new to ffi programming) but when I try and call a function like update-camera or draw-triangle-fan with the appropriate struct (camera3d and vector2 respectfully) the function signals an error saying that the struct is not a pointer.

When trying various ways to get a pointer for the object I get errors as well.

Unsure if this is a bug, or my misunderstanding, but I figured an issue wouldn't hurt.

Thank you for your work!

compufox avatar Nov 02 '20 22:11 compufox

ok, I encounter the same problem with update-camera and still no way to use struct and pointer to struct at the same time. Maybe implement update-camera in pure Lisp is a way?

longlene avatar Nov 03 '20 01:11 longlene

check this example:

(defun input-keys () (let* ((screen-width 800) (screen-height 450) (ball-position (r::make-vector2 :x (/ screen-width 2.0) :y (/ screen-height 2.0)))) (unwind-protect (progn (r:init-window screen-width screen-height "raylib [core] example - keyboard input") (r:set-target-fps 60) (loop :do (when (r:is-key-down +key-right+) (setf (r::vector2-x ball-position) (+ (r::vector2-x ball-position) 2.0))) (when (r:is-key-down +key-left+) (setf (r::vector2-x ball-position) (- (r::vector2-x ball-position) 2.0))) (when (r:is-key-down +key-down+) (setf (r::vector2-y ball-position) (+ (r::vector2-y ball-position) 2.0))) (when (r:is-key-down +key-up+) (setf (r::vector2-y ball-position) (- (r::vector2-y ball-position) 2.0))) (r:begin-drawing) (r:clear-background r:+raywhite+) (r:draw-text "move the ball with arrow keys" 10 10 20 +darkgray+) (r:draw-circle-v ball-position 50.0 +maroon+) (r:end-drawing) :until (r:window-should-close))) (r:close-window))))

;; +key-right+=262 ;; +key-left+=263 ;; ... ;; check the others in https://github.com/longlene/cl-raylib/blob/master/src/raylib.lisp

olegharput avatar Nov 03 '20 18:11 olegharput

I'll close the issue as camera related API should be usable now.

longlene avatar Aug 07 '22 04:08 longlene