Open shelvick opened 3 years ago
Sorry for that. As the raylib library use the struct and pointer to the struct at the same time, some APIs may not work as expected. Those APIs may be could be rewrote with Common Lisp. I'll try it when I have time.
The issue here might just be that the bones
and bind-pose
members are declared as structs CL but they are pointers in the C struct. The code is likely just reading invalid memory.
;;
;;// Model, meshes, materials and animation data
;;typedef struct Model {
;; Matrix transform; // Local transform matrix
;;
;; int meshCount; // Number of meshes
;; int materialCount; // Number of materials
;; Mesh *meshes; // Meshes array
;; Material *materials; // Materials array
;; int *meshMaterial; // Mesh material number
;;
;; // Animation data
;; int boneCount; // Number of bones
;; BoneInfo *bones; // Bones information (skeleton)
;; Transform *bindPose; // Bones base transformation (pose)
;;} Model;
(defcstruct (%model :class model-type)
"Model type"
(transform (:struct %matrix))
(mesh-count :int)
(material-count :int)
(meshes (:pointer (:struct %mesh)))
(materials (:pointer (:struct %material)))
(mesh-material (:pointer :int))
(bone-count :int)
(bones (:struct %bone-info))
(bind-pose (:struct %transform)))
When I try to load and draw a simple model, such as in this example, I get pointer errors in
(draw-model)
:This works in C so at least on some level I am using the library correctly. Do you have a working Lisp example? Am I doing something wrong or is this related to #3?