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

Example how to call draw-triangle-strip would be nice.

Open ruffianeo opened this issue 11 months ago • 1 comments

For the heck of it - I cannot figure out, how the arguments to that function should look like. Maybe there is also something wrong with the translate-to-foreign functions.

(defcfun "DrawTriangleStrip" :void
 "Draw a triangle strip defined by points"
 (points (:pointer (:struct %vector2)))
 (point-count :int)
 (color (:struct %color)))

I tried both a list of 3d-vectors:vec2 and an array with element-type '3d-vectors:vec2 and both failed. So, I am on my wits end, what it expects me to provide.

ruffianeo avatar Mar 11 '25 18:03 ruffianeo

I have similar issue with

(defcfun "ImageDrawPixel" :void
  "Draw pixel within an image"
  (dst (:pointer (:struct %image)))
  (pos-x :int)
  (pos-y :int)
  (color (:struct %color)))

it also takes pointer to image but the function genImage* returns object, I looked at the src

(define-conversion-into-foreign-memory (object (type image-type) pointer)
    (with-foreign-slots ((data width height maps ft) pointer (:struct %image))
      (setf data (image-data object))
      (setf width (image-width object))
      (setf height (image-height object))
      (setf maps (image-maps object))
      (setf ft (image-ft object))))

(define-conversion-from-foreign (pointer (type image-type))
    (with-foreign-slots ((data width height maps ft) pointer (:struct %image))
      (make-image :data data :width width :height height :maps maps :ft ft)))

there are these functions but they don't seem to do their work

here is the error

(image-draw-pixel image x y (coloring px)) ; image is object returned from genImageColor
The value
  #S(CL-RAYLIB::IMAGE
     :DATA #.(SB-SYS:INT-SAP #X7F4A00004B40)
     :WIDTH 20
     :HEIGHT 30
     :MAPS 1
     :FT 7)

is not of type
  SB-SYS:SYSTEM-AREA-POINTER
   [Condition of type TYPE-ERROR]

I was reaading cffi docs and tried using mem-aptr and other memory accessors

(mem-aptr image '(:struct cl-raylib::%image) 1)

but it also fails

is this the limitation of cffi?

yan3ku avatar Mar 25 '25 14:03 yan3ku