├── LICENSE ├── README.md ├── cl-raylib.asd ├── examples ├── audio │ ├── audio_sound_loading.lisp │ └── resources │ │ ├── sound.wav │ │ └── target.ogg ├── billboard.lisp ├── camera.lisp ├── core │ ├── core_basic_window.lisp │ ├── core_input_keys.lisp │ ├── core_input_mouse.lisp │ ├── core_random_values.lisp │ └── core_world_screen.lisp ├── other │ └── rlgl_compute_shader.lisp ├── resources │ └── billboard.png └── text │ └── text-writing-anim.lisp └── src ├── library.lisp ├── macro.lisp ├── package.lisp ├── raylib.lisp ├── rlgl.lisp └── util.lisp /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cl-raylib 2 | Common Lisp binding of [raylib](https://www.raylib.com/) 3 | 4 | ## basic example 5 | 1. install raylib 6 | 7 | cl-raylib require raylib dynamic library 8 | 9 | run `brew install raylib` to install the library if run example on macOS 10 | 11 | 2. install `cffi` 12 | 13 | cl-raylib use cffi to load dynamic library 14 | 15 | `quicklisp` can install cffi automatically, or installing cffi with system package manager is also ok 16 | 17 | 3. fetch cl-raylib code 18 | 19 | cl-raylib is not on quicklisp now, so you should fetch it manually 20 | 21 | ```bash 22 | git clone https://github.com/longlene/cl-raylib.git ~/.quicklisp/local-projects/cl-raylib 23 | ``` 24 | my quicklisp install path is ~/.quicklisp 25 | 26 | clone to ~/.local/share/common-lisp/source/cl-raylib is ok if you has no quicklisp 27 | 28 | 4. run basic example 29 | 30 | enter sbcl repl (or ccl etc) :blush: 31 | ```bash 32 | sbcl --load ~/.quicklisp/local-projects/cl-raylib/examples/basic.lisp --quit 33 | ``` 34 | Press `ESC` to close the basic window 35 | -------------------------------------------------------------------------------- /cl-raylib.asd: -------------------------------------------------------------------------------- 1 | #+sbcl 2 | (declaim (sb-ext:muffle-conditions sb-kernel:character-decoding-error-in-comment)) 3 | 4 | #+sbcl 5 | (eval-when (:compile-toplevel :load-toplevel :execute) 6 | (sb-int:set-floating-point-modes :traps nil)) 7 | 8 | (asdf:defsystem #:cl-raylib 9 | :version "0.0.1" 10 | :author "loong0" 11 | :license "MIT" 12 | :description "Common Lisp bindings of libraylib" 13 | :depends-on (#:cffi-libffi 14 | #:alexandria 15 | #:3d-vectors 16 | #:3d-matrices) 17 | :serial t 18 | :pathname "src" 19 | :components 20 | ((:file "package") 21 | (:file "util") 22 | (:file "library") 23 | (:file "raylib") 24 | (:file "rlgl") 25 | (:file "macro"))) 26 | -------------------------------------------------------------------------------- /examples/audio/audio_sound_loading.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defun main () 9 | (let ((screen-width 800) 10 | (screen-height 450) 11 | (res-path (uiop:native-namestring (asdf:system-relative-pathname 'cl-raylib "examples/audio/resources/")))) 12 | (set-target-fps 60) ; Set our game to run at 60 FPS 13 | (with-window (screen-width screen-height "raylib [audio] example - sound loading and playing") 14 | (with-audio-device 15 | (with-sound (fx-wav (concatenate 'string res-path "sound.wav")) 16 | (with-sound (fx-ogg (concatenate 'string res-path "target.ogg")) 17 | (loop 18 | until (window-should-close) ; detect window close button or ESC key 19 | do 20 | (if (is-key-pressed :key-space) (play-sound fx-wav)) 21 | (if (is-key-pressed :key-enter) (play-sound fx-ogg)) 22 | (with-drawing 23 | (clear-background :raywhite) 24 | (draw-text "Press SPACE to PLAY the WAV sound!" 200 180 20 :lightgray) 25 | (draw-text "Press ENTER to PLAY the OGG sound!" 200 220 20 :lightgray))))))))) 26 | 27 | (main) 28 | -------------------------------------------------------------------------------- /examples/audio/resources/sound.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longlene/cl-raylib/b3896f28db8017280cff077a74251c3243306253/examples/audio/resources/sound.wav -------------------------------------------------------------------------------- /examples/audio/resources/target.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longlene/cl-raylib/b3896f28db8017280cff077a74251c3243306253/examples/audio/resources/target.ogg -------------------------------------------------------------------------------- /examples/billboard.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib :3d-vectors)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defun main () 9 | (let* ((screen-width 800) 10 | (screen-height 450) 11 | (title "raylib [models] example - drawing billboards") 12 | (camera-pos (vec 5.0 4.0 5.0)) 13 | (camera-target (vec 0.0 2.0 0.0)) 14 | (camera-up (vec 0.0 1.0 0.0)) 15 | (camera (make-camera3d :position camera-pos 16 | :target camera-target 17 | :up camera-up 18 | :fovy 45.0 19 | :projection :camera-perspective)) 20 | (bill-position (vec 0.0 2.0 0.0))) 21 | (with-window (screen-width screen-height title) 22 | (set-target-fps 60) 23 | (let ((bill 24 | (load-texture 25 | (uiop:native-namestring 26 | (asdf:system-relative-pathname 'cl-raylib 27 | "examples/resources/billboard.png"))))) 28 | (loop while (not (window-should-close)) 29 | do (update-camera camera :camera-orbital) 30 | (with-drawing 31 | (clear-background :raywhite) 32 | (with-mode-3d (camera) 33 | (draw-grid 10 1.0) 34 | (raylib:draw-billboard camera bill bill-position 2.0 :raywhite)) 35 | (draw-fps 10 10))))))) 36 | 37 | (main) 38 | -------------------------------------------------------------------------------- /examples/camera.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib :3d-vectors)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defun main () 9 | (let* ((screen-width 800) 10 | (screen-height 450) 11 | (title "raylib [core] example - 3d camera mode") 12 | (camera-pos (vec 0.0 10.0 10.0)) 13 | (camera-target (vec 0.0 0.0 0.0)) 14 | (camera-up (vec 0.0 1.0 0.0)) 15 | (camera (make-camera3d :position camera-pos 16 | :target camera-target 17 | :up camera-up 18 | :fovy 45.0 19 | :projection :camera-perspective)) 20 | (cube-pos (vec 0.0 0.0 0.0))) 21 | (with-window (screen-width screen-height title) 22 | (set-target-fps 60) ; Set our game to run at 60 FPS 23 | (loop 24 | (if (window-should-close) (return)) ; detect window close button or ESC key 25 | (with-drawing 26 | (clear-background :raywhite) 27 | (with-mode-3d (camera) 28 | (draw-cube cube-pos 2.0 2.0 2.0 :red) 29 | (draw-cube-wires cube-pos 2.0 2.0 2.0 :maroon) 30 | (draw-grid 10 1.0)) 31 | 32 | (draw-text "Welcome to the third dimension!" 10 40 20 :darkgray) 33 | (draw-fps 10 10)))))) 34 | 35 | (main) 36 | -------------------------------------------------------------------------------- /examples/core/core_basic_window.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defun main () 9 | (let ((screen-width 800) 10 | (screen-height 450)) 11 | (with-window (screen-width screen-height "raylib [core] example - basic window") 12 | (set-target-fps 60) ; Set our game to run at 60 FPS 13 | (loop 14 | until (window-should-close) ; detect window close button or ESC key 15 | do (with-drawing 16 | (clear-background :raywhite) 17 | (draw-fps 20 20) 18 | (draw-text "Congrats! You created your first window!" 190 200 20 :lightgray)))))) 19 | 20 | (main) 21 | -------------------------------------------------------------------------------- /examples/core/core_input_keys.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib :3d-vectors)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defun main () 9 | (let* ((screen-width 800) 10 | (screen-height 450) 11 | (ball-position (vec (float (/ screen-width 2)) (float (/ screen-height 2))))) 12 | (with-window (screen-width screen-height "raylib [core] example - keyboard input") 13 | (set-target-fps 60) ; Set our game to run at 60 FPS 14 | (loop until (window-should-close) ; detect window close button or ESC key 15 | do 16 | (if (is-key-down :key-right) 17 | (incf (vx ball-position) 2.0)) 18 | (if (is-key-down :key-left) 19 | (incf (vx ball-position) (- 2.0))) 20 | (if (is-key-down :key-down) 21 | (incf (vy ball-position) 2.0)) 22 | (if (is-key-down :key-up) 23 | (incf (vy ball-position) (- 2.0))) 24 | (with-drawing 25 | (clear-background :raywhite) 26 | (draw-text "move the ball with arrow keys" 10 10 20 :darkgray) 27 | (draw-circle-v ball-position 50.0 :maroon)))))) 28 | 29 | (main) 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /examples/core/core_input_mouse.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib :3d-vectors)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defun main () 9 | (let* ((screen-width 800) 10 | (screen-height 450) 11 | (ball-position (vec -100.0 -100.0)) 12 | (ball-color :darkblue)) 13 | (with-window (screen-width screen-height "raylib [core] example - mouse input") 14 | (set-target-fps 60) ; Set our game to run at 60 FPS 15 | (loop until (window-should-close) ; detect window close button or ESC key 16 | do 17 | (setf ball-position (get-mouse-position)) 18 | (cond 19 | ((is-mouse-button-pressed :mouse-button-left) 20 | (setf ball-color :maroon)) 21 | ((is-mouse-button-pressed :mouse-button-middle) 22 | (setf ball-color :lime)) 23 | ((is-mouse-button-pressed :mouse-button-right) 24 | (setf ball-color :darkblue)) 25 | ((is-mouse-button-pressed :mouse-button-side) 26 | (setf ball-color :purple)) 27 | ((is-mouse-button-pressed :mouse-button-extra) 28 | (setf ball-color :yellow)) 29 | ((is-mouse-button-pressed :mouse-button-forward) 30 | (setf ball-color :orange)) 31 | ((is-mouse-button-pressed :mouse-button-back) 32 | (setf ball-color :beige))) 33 | (with-drawing 34 | (clear-background :raywhite) 35 | (draw-circle-v ball-position 40.0 ball-color) 36 | (draw-text "move ball with mouse and click mouse button to change color" 10 10 20 :darkgreen)))))) 37 | 38 | (main) 39 | -------------------------------------------------------------------------------- /examples/core/core_random_values.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defun main () 9 | (let ((screen-width 800) 10 | (screen-height 450) 11 | (rand-value (get-random-value -8 5)) 12 | (frames-counter 0)) 13 | (with-window (screen-width screen-height "raylib [core] example - generate random values") 14 | (set-target-fps 60) ; Set our game to run at 60 FPS 15 | (loop until (window-should-close) ; detect window close button or ESC key 16 | do (incf frames-counter) 17 | (if (equal (mod (floor frames-counter 120) 2) 1) 18 | (setf rand-value (get-random-value -8 5) 19 | frames-counter 0)) 20 | (with-drawing 21 | (clear-background :raywhite) 22 | (draw-text "Every 2 seconds a new random value is generated:" 130 100 20 :maroon) 23 | (draw-text (text-format "%i" :int rand-value) 360 180 80 :lightgray)))))) 24 | 25 | (main) 26 | -------------------------------------------------------------------------------- /examples/core/core_world_screen.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib :3d-vectors)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defun main () 9 | (let* ((screen-width 800) 10 | (screen-height 450) 11 | (title "raylib [core] example - 3d camera free") 12 | (camera-pos (vec 10.0 10.0 10.0)) 13 | (camera-target (vec 0.0 0.0 0.0)) 14 | (camera-up (vec 0.0 1.0 0.0)) 15 | (camera (make-camera3d :position camera-pos 16 | :target camera-target 17 | :up camera-up 18 | :fovy 45.0 19 | :projection :camera-perspective)) 20 | (cube-pos (vec 0.0 0.0 0.0)) 21 | (cube-screen-pos (vec 0.0 0.0))) 22 | (with-window (screen-width screen-height title) 23 | (disable-cursor) 24 | (set-target-fps 60) ; Set our game to run at 60 FPS 25 | (loop 26 | until (window-should-close) ; detect window close button or ESC key 27 | do (update-camera camera :camera-free) 28 | (setf cube-screen-pos (get-world-to-screen (v+ cube-pos (vec 0 2.5 0)) camera)) 29 | (with-drawing 30 | (clear-background :raywhite) 31 | (with-mode-3d (camera) 32 | (draw-cube cube-pos 2.0 2.0 2.0 :red) 33 | (draw-cube-wires cube-pos 2.0 2.0 2.0 :maroon) 34 | (draw-grid 10 1.0)) 35 | (draw-text "Enemy: 100/100" (- (floor (vx cube-screen-pos)) (floor (measure-text "Enemy: 100/100" 20) 2)) 36 | (floor (vy cube-screen-pos) ) 20 :black) 37 | (draw-text "Text is always on top of the cube" (floor (- screen-width (measure-text "Text is always on top of the cube" 20)) 2) 25 20 :gray)))))) 38 | 39 | (main) 40 | -------------------------------------------------------------------------------- /examples/other/rlgl_compute_shader.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib :3d-vectors)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defparameter +gol-logic-shader+ 9 | "#version 430 10 | 11 | // Game of Life logic shader 12 | 13 | #define GOL_WIDTH 768 14 | 15 | layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in; 16 | 17 | layout(std430, binding = 1) readonly restrict buffer golLayout { 18 | uint golBuffer[]; // golBuffer[x, y] = golBuffer[x + gl_NumWorkGroups.x * y] 19 | }; 20 | 21 | layout(std430, binding = 2) writeonly restrict buffer golLayout2 { 22 | uint golBufferDest[]; // golBufferDest[x, y] = golBufferDest[x + gl_NumWorkGroups.x * y] 23 | }; 24 | 25 | #define fetchGol(x, y) ((((x) < 0) || ((y) < 0) || ((x) > GOL_WIDTH) || ((y) > GOL_WIDTH)) ? (0) : (golBuffer[(x) + GOL_WIDTH * (y)])) 26 | 27 | #define setGol(x, y, value) golBufferDest[(x) + GOL_WIDTH*(y)] = value 28 | 29 | void main() 30 | { 31 | uint neighbourCount = 0; 32 | uint x = gl_GlobalInvocationID.x; 33 | uint y = gl_GlobalInvocationID.y; 34 | 35 | neighbourCount += fetchGol(x - 1, y - 1); // Top left 36 | neighbourCount += fetchGol(x, y - 1); // Top middle 37 | neighbourCount += fetchGol(x + 1, y - 1); // Top right 38 | neighbourCount += fetchGol(x - 1, y); // Left 39 | neighbourCount += fetchGol(x + 1, y); // Right 40 | neighbourCount += fetchGol(x - 1, y + 1); // Bottom left 41 | neighbourCount += fetchGol(x, y + 1); // Bottom middle 42 | neighbourCount += fetchGol(x + 1, y + 1); // Bottom right 43 | 44 | if (neighbourCount == 3) setGol(x, y, 1); 45 | else if (neighbourCount == 2) setGol(x, y, fetchGol(x, y)); 46 | else setGol(x, y, 0); 47 | }") 48 | 49 | (defparameter +gol-render-shader+ 50 | "#version 430 51 | 52 | // Game of Life rendering shader 53 | // Just renders the content of the ssbo at binding 1 to screen 54 | 55 | #define GOL_WIDTH 768 56 | 57 | // Input vertex attributes (from vertex shader) 58 | in vec2 fragTexCoord; 59 | 60 | // Output fragment color 61 | out vec4 finalColor; 62 | 63 | // Input game of life grid. 64 | layout(std430, binding = 1) readonly buffer golLayout 65 | { 66 | uint golBuffer[]; 67 | }; 68 | 69 | // Output resolution 70 | uniform vec2 resolution; 71 | 72 | void main() 73 | { 74 | ivec2 coords = ivec2(fragTexCoord*resolution); 75 | 76 | if ((golBuffer[coords.x + coords.y*uvec2(resolution).x]) == 1) finalColor = vec4(1.0); 77 | else finalColor = vec4(0.0, 0.0, 0.0, 1.0); 78 | }") 79 | 80 | (defparameter +gol-transfert-shader+ 81 | "#version 430 82 | 83 | // Game of life transfert shader 84 | 85 | #define GOL_WIDTH 768 86 | 87 | // Game Of Life Update Command 88 | // NOTE: matches the structure defined on main program 89 | struct GolUpdateCmd { 90 | uint x; // x coordinate of the gol command 91 | uint y; // y coordinate of the gol command 92 | uint w; // width of the filled zone 93 | uint enabled; // whether to enable or disable zone 94 | }; 95 | 96 | // Local compute unit size 97 | layout (local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 98 | 99 | // Output game of life grid buffer 100 | layout(std430, binding = 1) buffer golBufferLayout 101 | { 102 | uint golBuffer[]; // golBuffer[x, y] = golBuffer[x + GOL_WIDTH * y] 103 | }; 104 | 105 | // Command buffer 106 | layout(std430, binding = 3) readonly restrict buffer golUpdateLayout 107 | { 108 | uint count; 109 | GolUpdateCmd commands[]; 110 | }; 111 | 112 | #define isInside(x, y) (((x) >= 0) && ((y) >= 0) && ((x) < GOL_WIDTH) && ((y) < GOL_WIDTH)) 113 | #define getBufferIndex(x, y) ((x) + GOL_WIDTH * (y)) 114 | 115 | void main() 116 | { 117 | uint cmdIndex = gl_GlobalInvocationID.x; 118 | GolUpdateCmd cmd = commands[cmdIndex]; 119 | 120 | for (uint x = cmd.x; x < (cmd.x + cmd.w); x++) 121 | { 122 | for (uint y = cmd.y; y < (cmd.y + cmd.w); y++) 123 | { 124 | if (isInside(x, y)) 125 | { 126 | if (cmd.enabled != 0) atomicOr(golBuffer[getBufferIndex(x, y)], 1); 127 | else atomicAnd(golBuffer[getBufferIndex(x, y)], 0); 128 | } 129 | } 130 | } 131 | }") 132 | 133 | (defconstant +gol-width+ 768) 134 | (defconstant +max-buffered-transfers+ 48) 135 | 136 | (cffi:defcstruct %gol-update-cmd 137 | (x :uint) 138 | (y :uint) 139 | (w :uint) 140 | (enabled :uint)) 141 | 142 | (cffi:defcstruct %gol-update-ssbo 143 | (count :uint) 144 | (commands (:array (:struct %gol-update-cmd) 48))) 145 | 146 | (defun main () 147 | (let ((screen-width +gol-width+) 148 | (screen-height +gol-width+)) 149 | (with-window (screen-width screen-height "raylib [rlgl] example - compute shader - game of life") 150 | (let* ((brush-size 8) 151 | (gol-logic-shader (rlgl:compile-shader +gol-logic-shader+ rlgl:+compute-shader+)) 152 | (gol-logic-program (rlgl:load-compute-shader-program gol-logic-shader)) 153 | 154 | (gol-render-shader (raylib:load-shader-from-memory (cffi:null-pointer) +gol-render-shader+)) 155 | (res-uniform-loc (get-shader-location gol-render-shader "resolution")) 156 | 157 | (gol-transfert-shader (rlgl:compile-shader +gol-transfert-shader+ rlgl:+compute-shader+)) 158 | (gol-transfert-program (rlgl:load-compute-shader-program gol-transfert-shader)) 159 | 160 | (ssbo-a (rlgl:load-shader-buffer (* +gol-width+ +gol-width+ (cffi:foreign-type-size :uint)) 161 | (cffi:null-pointer) 162 | rlgl:+dynamic-copy+)) 163 | (ssbo-b (rlgl:load-shader-buffer (* +gol-width+ +gol-width+ (cffi:foreign-type-size :uint)) 164 | (cffi:null-pointer) 165 | rlgl:+dynamic-copy+)) 166 | (ssbo-transfert (rlgl:load-shader-buffer (cffi:foreign-type-size '(:struct %gol-update-ssbo)) 167 | (cffi:null-pointer) 168 | rlgl:+dynamic-copy+)) 169 | 170 | (white-tex (let ((white-image (gen-image-color +gol-width+ +gol-width+ :white))) 171 | (unwind-protect 172 | (load-texture-from-image white-image) 173 | (unload-image white-image))))) 174 | (unwind-protect 175 | (progn 176 | (cffi:with-foreign-objects ((transfert-buffer '(:struct %gol-update-ssbo)) 177 | (resolution '(:struct raylib::%vector2))) 178 | (cffi:with-foreign-slots ((raylib::x raylib::y) resolution (:struct raylib::%vector2)) 179 | (setf raylib::x (coerce +gol-width+ 'float) 180 | raylib::y (coerce +gol-width+ 'float))) 181 | (loop 182 | until (window-should-close) 183 | do (incf brush-size (get-mouse-wheel-move)) 184 | (cffi:with-foreign-slots ((count (:pointer commands)) transfert-buffer (:struct %gol-update-ssbo)) 185 | (cond 186 | ((and (or (is-mouse-button-down :mouse-button-left) 187 | (is-mouse-button-down :mouse-button-right)) 188 | (< count +max-buffered-transfers+)) 189 | (cffi:with-foreign-slots ((x y w enabled) (cffi:mem-aptr commands '(:struct %gol-update-cmd) count) (:struct %gol-update-cmd)) 190 | (setf x (round (- (get-mouse-x) (/ brush-size 2))) 191 | y (round (- (get-mouse-y) (/ brush-size 2))) 192 | w (round brush-size) 193 | enabled (if (is-mouse-button-down :mouse-button-left) 1 0))) 194 | (incf count)) 195 | ((> count 0) 196 | (rlgl:update-shader-buffer ssbo-transfert transfert-buffer (cffi:foreign-type-size '(:struct %gol-update-ssbo)) 0) 197 | (rlgl:enable-shader gol-transfert-program) 198 | (rlgl:bind-shader-buffer ssbo-a 1) 199 | (rlgl:bind-shader-buffer ssbo-transfert 3) 200 | (rlgl:compute-shader-dispatch count 1 1) 201 | (rlgl:disable-shader) 202 | (setf count 0)) 203 | (t 204 | (rlgl:enable-shader gol-logic-program) 205 | (rlgl:bind-shader-buffer ssbo-a 1) 206 | (rlgl:bind-shader-buffer ssbo-b 2) 207 | (rlgl:compute-shader-dispatch (/ +gol-width+ 16) (/ +gol-width+ 16) 1) 208 | (rlgl:disable-shader) 209 | (rotatef ssbo-a ssbo-b)))) 210 | 211 | (rlgl:bind-shader-buffer ssbo-a 1) 212 | (set-shader-value gol-render-shader res-uniform-loc resolution :shader-uniform-vec2) 213 | (with-drawing 214 | (clear-background :blank) 215 | (begin-shader-mode gol-render-shader) 216 | (draw-texture white-tex 0 0 :blank) 217 | (end-shader-mode) 218 | (draw-rectangle-lines (round (- (get-mouse-x) (/ brush-size 2))) 219 | (round (- (get-mouse-y) (/ brush-size 2))) 220 | (round brush-size) 221 | (round brush-size) 222 | :red) 223 | (draw-fps 20 20))))) 224 | (progn 225 | (rlgl:unload-shader-buffer ssbo-transfert) 226 | (rlgl:unload-shader-buffer ssbo-b) 227 | (rlgl:unload-shader-buffer ssbo-a) 228 | 229 | (unload-texture white-tex) 230 | 231 | (rlgl:unload-shader-program gol-transfert-program) 232 | (unload-shader gol-render-shader) 233 | (rlgl:unload-shader-program gol-logic-program))))))) 234 | 235 | (main) 236 | -------------------------------------------------------------------------------- /examples/resources/billboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longlene/cl-raylib/b3896f28db8017280cff077a74251c3243306253/examples/resources/billboard.png -------------------------------------------------------------------------------- /examples/text/text-writing-anim.lisp: -------------------------------------------------------------------------------- 1 | (require :cl-raylib) 2 | 3 | (defpackage :raylib-user 4 | (:use :cl :raylib)) 5 | 6 | (in-package :raylib-user) 7 | 8 | (defun main () 9 | (let ((screen-width 800) 10 | (screen-height 450) 11 | (frame-counter 0) 12 | (message (format nil "This sample illustrates a text writing~%animation effect! Check it out!"))) 13 | (with-window (screen-width screen-height "raylib [text] example - text writing anim") 14 | (set-target-fps 60) ; Set our game to run at 60 FPS 15 | (loop 16 | until (window-should-close) ; detect window close button or ESC key 17 | do 18 | (setf frame-counter 19 | (cond 20 | ((is-key-down :key-space) (+ frame-counter 8)) 21 | ((is-key-down :key-enter) 0) 22 | (t (1+ frame-counter)))) 23 | (with-drawing 24 | (incf frame-counter) 25 | (clear-background :raywhite) 26 | (draw-text 27 | (text-subtext message 0 (floor frame-counter 10)) 28 | ;;message 29 | 210 160 20 :maroon)))))) 30 | 31 | (main) 32 | -------------------------------------------------------------------------------- /src/library.lisp: -------------------------------------------------------------------------------- 1 | (in-package #:cl-raylib) 2 | (define-foreign-library libraylib 3 | (:darwin "libraylib.dylib") 4 | (:unix "libraylib.so") 5 | (:windows (:or "raylib.dll" "libraylib.dll")) 6 | (t (:default "libraylib"))) 7 | 8 | (unless (foreign-library-loaded-p 'libraylib) 9 | (use-foreign-library libraylib)) 10 | 11 | -------------------------------------------------------------------------------- /src/macro.lisp: -------------------------------------------------------------------------------- 1 | (in-package #:cl-raylib) 2 | 3 | (defmacro with-window ((width height title) &body body) 4 | `(progn (init-window ,width ,height ,title) 5 | (unwind-protect (progn ,@body) 6 | (close-window)))) 7 | 8 | (defmacro with-drawing (&body body) 9 | `(progn (begin-drawing) 10 | (unwind-protect (progn ,@body) 11 | (end-drawing)))) 12 | 13 | (defmacro with-mode-2d ((camera) &body body) 14 | `(progn (begin-mode-2d ,camera) 15 | (unwind-protect (progn ,@body) 16 | (end-mode-2d)))) 17 | 18 | (defmacro with-mode-3d ((camera) &body body) 19 | `(progn (begin-mode-3d ,camera) 20 | (unwind-protect (progn ,@body) 21 | (end-mode-3d)))) 22 | 23 | (defmacro with-texture-mode ((target) &body body) 24 | `(progn (begin-texture-mode ,target) 25 | (unwind-protect (progn ,@body) 26 | (end-texture-mode)))) 27 | 28 | (defmacro with-shader-mode ((shader) &body body) 29 | `(progn (begin-shader-mode ,shader) 30 | (unwind-protect (progn ,@body) 31 | (end-shader-mode)))) 32 | 33 | (defmacro with-blend-mode ((mode) &body body) 34 | `(progn (begin-blend-mode ,mode) 35 | (unwind-protect (progn ,@body) 36 | (end-blend-mode)))) 37 | 38 | (defmacro with-audio-device (&body body) 39 | `(progn (init-audio-device) 40 | (unwind-protect (progn ,@body) 41 | (close-audio-device)))) 42 | 43 | (defmacro with-audio-stream ((stream sample-rate sample-size channels) &body body) 44 | `(let ((,stream (load-audio-stream ,sample-rate ,sample-size ,channels))) 45 | (unwind-protect (progn ,@body) 46 | (unload-audio-stream ,stream)))) 47 | 48 | (defmacro with-sound ((sound file-name) &body body) 49 | `(let ((,sound (load-sound ,file-name))) 50 | (unwind-protect (progn ,@body) 51 | (unload-sound ,sound)))) 52 | -------------------------------------------------------------------------------- /src/package.lisp: -------------------------------------------------------------------------------- 1 | (defpackage #:cl-raylib-util 2 | (:use #:cl #:cffi) 3 | (:export #:translate-name-from-foreign 4 | #:translate-name-to-foreign 5 | #:define-conversion-into-foreign-memory 6 | #:define-conversion-from-foreign)) 7 | 8 | (defpackage #:cl-raylib 9 | (:nicknames #:raylib) 10 | (:use #:cl #:cffi #:alexandria #:cl-raylib-util) 11 | (:export 12 | #:make-rgba 13 | 14 | #:make-vector2 15 | #:vector2-x 16 | #:vector2-y 17 | 18 | #:make-vector3 19 | #:vector3-x 20 | #:vector3-y 21 | #:vector3-z 22 | 23 | #:make-vector4 24 | #:vector4-x 25 | #:vector4-y 26 | #:vector4-z 27 | #:vector4-w 28 | 29 | #:make-rectangle 30 | #:rectangle-x 31 | #:rectangle-y 32 | #:rectangle-width 33 | #:rectangle-height 34 | 35 | #:make-texture 36 | #:texture-id 37 | #:texture-width 38 | #:texture-height 39 | #:texture-mipmaps 40 | #:texture-format 41 | 42 | #:make-render-texture 43 | #:render-texture-id 44 | #:render-texture-texture 45 | #:render-texture-depth 46 | #:render-texture-depth-texture 47 | 48 | #:make-patch-info 49 | #:patch-info-rec 50 | #:patch-info-left 51 | #:patch-info-top 52 | #:patch-info-right 53 | #:patch-info-bottom 54 | #:patch-info-type 55 | 56 | #:make-char-info 57 | #:char-info-value 58 | #:char-info-offset-x 59 | #:char-info-offset-y 60 | #:char-info-advance-x 61 | #:char-info-image 62 | 63 | #:make-font 64 | #:font-base-size 65 | #:font-chars-count 66 | #:font-texture 67 | #:font-recs 68 | #:font-chars 69 | 70 | #:make-camera3d 71 | #:camera3d-position 72 | #:camera3d-target 73 | #:camera3d-up 74 | #:camera3d-fovy 75 | #:camera3d-type 76 | 77 | #:make-camera2d 78 | #:camera2d-offset 79 | #:camera2d-target 80 | #:camera2d-rotation 81 | #:camera2d-zoom 82 | 83 | #:init-window 84 | #:window-should-close 85 | #:close-window 86 | #:is-window-ready 87 | #:is-window-fullscreen 88 | #:is-window-hidden 89 | #:is-window-minimized 90 | #:is-window-maximized 91 | #:is-window-focused 92 | #:is-window-resized 93 | #:is-window-state 94 | #:set-window-state 95 | #:clear-window-state 96 | #:toggle-fullscreen 97 | #:toggle-borderless-windowed 98 | #:maximize-window 99 | #:minimize-window 100 | #:restore-window 101 | #:set-window-icon 102 | #:set-window-icons 103 | #:set-window-title 104 | #:set-window-position 105 | #:set-window-monitor 106 | #:set-window-min-size 107 | #:set-window-maxsize 108 | #:set-window-size 109 | #:set-window-opacity 110 | #:set-window-focused 111 | #:get-window-handle 112 | #:get-screen-width 113 | #:get-screen-height 114 | #:get-render-width 115 | #:get-render-height 116 | #:get-monitor-count 117 | #:get-current-monitor 118 | #:get-monitor-position 119 | #:get-monitor-width 120 | #:get-monitor-height 121 | #:get-monitor-physical-width 122 | #:get-monitor-physical-height 123 | #:get-monitor-refresh-rate 124 | #:get-window-position 125 | #:get-window-scale-dpi 126 | #:get-monitor-name 127 | #:get-clipboard-text 128 | #:set-clipboard-text 129 | #:enable-event-waiting 130 | #:disable-event-waiting 131 | #:show-cursor 132 | #:hide-cursor 133 | #:is-cursor-hidden 134 | #:enable-cursor 135 | #:disable-cursor 136 | #:is-cursor-on-screen 137 | #:clear-background 138 | #:begin-drawing 139 | #:end-drawing 140 | #:begin-mode-2d 141 | #:end-mode-2d 142 | #:begin-mode-3d 143 | #:end-mode-3d 144 | #:begin-texture-mode 145 | #:end-texture-mode 146 | #:begin-scissor-mode 147 | #:end-scissor-mode 148 | #:begin-vr-stereo-mode 149 | #:end-vr-stereo-mode 150 | #:load-vr-stereo-config 151 | #:unload-vr-stereo-config 152 | #:get-mouse-ray 153 | #:get-camera-matrix 154 | #:get-camera-matrix-2d 155 | #:get-world-to-screen 156 | #:get-screen-to-world-2d 157 | #:get-world-to-screen-ex 158 | #:get-world-to-screen-2d 159 | #:set-target-fps 160 | #:get-fps 161 | #:get-frame-time 162 | #:get-time 163 | #:swap-screen-buffer 164 | #:poll-input-events 165 | #:wait-time 166 | #:color-to-int 167 | #:color-normalize 168 | #:color-from-normalized 169 | #:color-to-hsv 170 | #:color-from-hsv 171 | #:color-tint 172 | #:color-brightness 173 | #:color-contrast 174 | #:color-alpha 175 | #:color-alpha-blend 176 | #:get-color 177 | #:get-pixel-color 178 | #:set-pixel-color 179 | #:get-pixel-data-size 180 | #:fade 181 | #:set-config-flags 182 | #:set-trace-log-level 183 | #:mem-alloc 184 | #:mem-realloc 185 | #:mem-free 186 | #:take-screenshot 187 | #:set-random-seed 188 | #:get-random-value 189 | #:load-random-sequence 190 | #:unload-random-sequence 191 | #:load-file-data 192 | #:unload-file-data 193 | #:save-file-data 194 | #:export-data-as-code 195 | #:load-file-text 196 | #:unload-file-text 197 | #:save-file-text 198 | #:file-exists 199 | #:is-file-extension 200 | #:directory-exists 201 | #:get-file-length 202 | #:get-file-extension 203 | #:get-file-name 204 | #:get-file-name-without-ext 205 | #:get-directory-path 206 | #:get-prev-directory-path 207 | #:get-working-directory 208 | #:get-application-directory 209 | #:change-directory 210 | #:is-path-file 211 | #:load-directory-files 212 | #:load-directory-files-ex 213 | #:unload-directory-files 214 | #:is-file-dropped 215 | #:load-dropped-files 216 | #:unload-dropped-files 217 | #:get-file-mod-time 218 | #:compress-data 219 | #:decompress-data 220 | #:encode-data-base64 221 | #:decode-data-base64 222 | #:load-automation-event-list 223 | #:unload-automation-event-list 224 | #:export-automation-event-list 225 | #:set-automation-event-list 226 | #:set-automation-event-base-frame 227 | #:start-automation-event-recording 228 | #:stop-automation-event-recording 229 | #:play-automation-event 230 | #:open-url 231 | #:is-key-pressed 232 | #:is-key-pressed-repeat 233 | #:is-key-down 234 | #:is-key-released 235 | #:is-key-up 236 | #:set-exit-key 237 | #:get-key-pressed 238 | #:get-char-pressed 239 | #:is-gamepad-available 240 | #:get-gamepad-name 241 | #:is-gamepad-button-pressed 242 | #:is-gamepad-button-down 243 | #:is-gamepad-button-released 244 | #:is-gamepad-button-up 245 | #:get-gamepad-button-pressed 246 | #:get-gamepad-axis-count 247 | #:get-gamepad-axis-movement 248 | #:set-gamepad-mappings 249 | #:is-mouse-button-pressed 250 | #:is-mouse-button-down 251 | #:is-mouse-button-released 252 | #:is-mouse-button-up 253 | #:get-mouse-x 254 | #:get-mouse-y 255 | #:get-mouse-position 256 | #:get-mouse-delta 257 | #:set-mouse-position 258 | #:set-mouse-offset 259 | #:set-mouse-scale 260 | #:get-mouse-wheel-move 261 | #:get-mouse-wheel-move-v 262 | #:set-mouse-cursor 263 | #:get-touch-x 264 | #:get-touch-y 265 | #:get-touch-position 266 | #:get-touch-point-id 267 | #:get-touch-point-count 268 | #:set-gestures-enabled 269 | #:is-gesture-detected 270 | #:get-gesture-detected 271 | #:get-gesture-hold-duration 272 | #:get-gesture-drag-vector 273 | #:get-gesture-drag-angle 274 | #:get-gesture-pinch-vector 275 | #:get-gesture-pinch-angle 276 | #:update-camera 277 | #:update-camera-pro 278 | #:set-shapes-texture 279 | #:draw-pixel 280 | #:draw-pixel-v 281 | #:draw-line 282 | #:draw-line-v 283 | #:draw-line-ex 284 | #:draw-line-bezier 285 | #:draw-line-strip 286 | #:draw-circle 287 | #:draw-circle-sector 288 | #:draw-circle-sector-lines 289 | #:draw-circle-gradient 290 | #:draw-circle-v 291 | #:draw-circle-lines 292 | #:draw-circle-lines-v 293 | #:draw-ellipse 294 | #:draw-ellipse-lines 295 | #:draw-ring 296 | #:draw-ring-lines 297 | #:draw-rectangle 298 | #:draw-rectangle-v 299 | #:draw-rectangle-rec 300 | #:draw-rectangle-pro 301 | #:draw-rectangle-gradient-v 302 | #:draw-rectangle-gradient-h 303 | #:draw-rectangle-gradient-ex 304 | #:draw-rectangle-lines 305 | #:draw-rectangle-lines-ex 306 | #:draw-rectangle-rounded 307 | #:draw-rectangle-rounded-lines 308 | #:draw-triangle 309 | #:draw-triangle-lines 310 | #:draw-triangle-fan 311 | #:draw-triangle-strip 312 | #:draw-poly 313 | #:draw-poly-lines 314 | #:draw-poly-lines-ex 315 | #:draw-spline-linear 316 | #:draw-spline-linear 317 | #:draw-spline-basis 318 | #:draw-spline-catmull-rom 319 | #:draw-spline-bezier-quadratic 320 | #:draw-spline-bezier-cubic 321 | #:draw-spline-segment-linear 322 | #:draw-spline-segment-basis 323 | #:draw-spline-segment-catmull-rom 324 | #:draw-spline-segment-bezier-quadratic 325 | #:draw-spline-segment-bezier-cubic 326 | #:get-spline-point-linear 327 | #:get-spline-point-basis 328 | #:get-spline-point-catmull-rom 329 | #:get-spline-point-bezier-quad 330 | #:get-spline-point-bezier-cubic 331 | #:check-collision-recs 332 | #:check-collision-circles 333 | #:check-collision-circle-rec 334 | #:check-collision-point-rec 335 | #:check-collision-point-circle 336 | #:check-collision-point-triangle 337 | #:check-collision-lines 338 | #:check-collision-point-line 339 | #:check-collision-point-poly 340 | #:get-collision-rec 341 | #:load-image 342 | #:load-image-raw 343 | #:load-image-svg 344 | #:load-image-anim 345 | #:load-image-from-memory 346 | #:load-image-from-texture 347 | #:load-image-from-screen 348 | #:is-image-ready 349 | #:unload-image 350 | #:export-image 351 | #:export-image-to-memory 352 | #:export-image-as-code 353 | #:gen-image-color 354 | #:gen-image-gradient-linear 355 | #:gen-image-gradient-radial 356 | #:gen-image-gradient-square 357 | #:gen-image-checked 358 | #:gen-image-white-noise 359 | #:gen-image-perlin-noise 360 | #:gen-image-cellular 361 | #:gen-image-text 362 | #:image-copy 363 | #:image-from-image 364 | #:image-text 365 | #:image-text-ex 366 | #:image-format 367 | #:image-to-pot 368 | #:image-crop 369 | #:image-alpha-crop 370 | #:image-alpha-clear 371 | #:image-alpha-mask 372 | #:image-alpha-premultiply 373 | #:image-blur-gaussian 374 | #:image-resize 375 | #:image-resize-nn 376 | #:image-resize-canvas 377 | #:image-mipmaps 378 | #:image-dither 379 | #:image-flip-vertical 380 | #:image-flip-horizontal 381 | #:image-rotate 382 | #:image-rotate-cw 383 | #:image-rotate-ccw 384 | #:image-color-tint 385 | #:image-color-invert 386 | #:image-color-grayscale 387 | #:image-color-contrast 388 | #:image-color-brightness 389 | #:image-color-replace 390 | #:load-image-colors 391 | #:load-image-palette 392 | #:unload-image-colors 393 | #:unload-image-palette 394 | #:get-image-alpha-border 395 | #:get-image-color 396 | #:image-clear-background 397 | #:image-draw-pixel 398 | #:image-draw-pixel-v 399 | #:image-draw-line 400 | #:image-draw-line-v 401 | #:image-draw-circle 402 | #:image-draw-circle-v 403 | #:image-draw-circle-lines 404 | #:image-draw-circle-lines-v 405 | #:image-draw-rectangle 406 | #:image-draw-rectangle-v 407 | #:image-draw-rectangle-rec 408 | #:image-draw-rectangle-lines 409 | #:image-draw 410 | #:image-draw-text 411 | #:image-draw-text-ex 412 | #:load-texture 413 | #:load-texture-from-image 414 | #:load-texture-cubemap 415 | #:load-render-texture 416 | #:is-texture-ready 417 | #:unload-texture 418 | #:is-render-texture-ready 419 | #:unload-render-texture 420 | #:update-texture 421 | #:update-texture-rec 422 | #:gen-texture-mipmaps 423 | #:set-texture-filter 424 | #:set-texture-wrap 425 | #:draw-texture 426 | #:draw-texture-v 427 | #:draw-texture-ex 428 | #:draw-texture-rec 429 | #:draw-texture-pro 430 | #:draw-texture-n-patch 431 | #:get-font-default 432 | #:load-font 433 | #:load-font-ex 434 | #:load-font-from-image 435 | #:load-font-from-memory 436 | #:is-font-ready 437 | #:load-font-data 438 | #:gen-image-font-atlas 439 | #:unload-font-data 440 | #:unload-font 441 | #:export-font-as-code 442 | #:draw-fps 443 | #:draw-text 444 | #:draw-text-ex 445 | #:draw-text-pro 446 | #:draw-text-codepoint 447 | #:draw-text-codepoints 448 | #:set-text-line-spacing 449 | #:measure-text 450 | #:measure-text-ex 451 | #:get-glyph-index 452 | #:get-glyph-info 453 | #:get-glyph-atlas-rec 454 | #:load-utf8 455 | #:unload-utf8 456 | #:load-codepoints 457 | #:unload-codepoints 458 | #:get-codepoint-count 459 | #:get-codepoint 460 | #:get-codepoint-next 461 | #:get-codepoint-previous 462 | #:text-copy 463 | #:text-is-equal 464 | #:text-length 465 | #:text-format 466 | #:text-subtext 467 | #:text-replace 468 | #:text-insert 469 | #:text-join 470 | #:text-split 471 | #:text-append 472 | #:text-find-index 473 | #:text-to-upper 474 | #:text-to-lower 475 | #:text-to-pascal 476 | #:text-to-integer 477 | #:codepoint-to-utf8 478 | #:draw-line-3d 479 | #:draw-point-3d 480 | #:draw-triangle-3d 481 | #:draw-triangle-strip-3d 482 | #:draw-circle-3d 483 | #:draw-cube 484 | #:draw-cube-v 485 | #:draw-cube-wires 486 | #:draw-cube-wires-v 487 | #:draw-sphere 488 | #:draw-sphere-ex 489 | #:draw-sphere-wires 490 | #:draw-cylinder 491 | #:draw-cylinder-ex 492 | #:draw-cylinder-wires 493 | #:draw-cylinder-wires-ex 494 | #:draw-capsule 495 | #:draw-capsule-wires 496 | #:draw-plane 497 | #:draw-ray 498 | #:draw-grid 499 | #:load-model 500 | #:load-model-from-mesh 501 | #:is-model-ready 502 | #:unload-model 503 | #:get-model-bounding-box 504 | #:export-mesh 505 | #:upload-mesh 506 | #:update-mesh-buffer 507 | #:unload-mesh 508 | #:draw-mesh 509 | #:draw-mesh-instanced 510 | #:load-materials 511 | #:load-material-default 512 | #:is-material-ready 513 | #:unload-material 514 | #:set-material-texture 515 | #:set-model-mesh-material 516 | #:load-model-animations 517 | #:unload-model-animations 518 | #:update-model-animation 519 | #:unload-model-animation 520 | #:is-model-animation-valid 521 | #:get-mesh-bounding-box 522 | #:gen-mesh-tangents 523 | #:gen-mesh-poly 524 | #:gen-mesh-plane 525 | #:gen-mesh-cube 526 | #:gen-mesh-sphere 527 | #:gen-mesh-hemi-sphere 528 | #:gen-mesh-cylinder 529 | #:gen-mesh-torus 530 | #:gen-mesh-knot 531 | #:gen-mesh-heightmap 532 | #:gen-mesh-cubicmap 533 | #:gen-mesh-cone 534 | #:draw-model 535 | #:draw-model-ex 536 | #:draw-model-wires 537 | #:draw-model-wires-ex 538 | #:draw-bounding-box 539 | #:draw-billboard 540 | #:draw-billboard-rec 541 | #:draw-billboard-pro 542 | #:check-collision-spheres 543 | #:check-collision-boxes 544 | #:check-collision-box-sphere 545 | #:get-ray-collision-sphere 546 | #:get-ray-collision-box 547 | #:get-ray-collision-mesh 548 | #:get-ray-collision-triangle 549 | #:get-ray-collision-quad 550 | #:load-shader 551 | #:load-shader-from-memory 552 | #:is-shader-ready 553 | #:unload-shader 554 | #:get-shader-location 555 | #:get-shader-location-attrib 556 | #:set-shader-value 557 | #:set-shader-value-v 558 | #:set-shader-value-matrix 559 | #:set-shader-value-texture 560 | #:begin-shader-mode 561 | #:end-shader-mode 562 | #:begin-blend-mode 563 | #:end-blend-mode 564 | #:init-audio-device 565 | #:close-audio-device 566 | #:is-audio-device-ready 567 | #:set-master-volume 568 | #:get-master-volume 569 | #:load-wave 570 | #:load-wave-from-memory 571 | #:is-wave-ready 572 | #:load-sound 573 | #:load-sound-from-wave 574 | #:load-sound-alias 575 | #:is-sound-ready 576 | #:update-sound 577 | #:unload-wave 578 | #:unload-sound 579 | #:unload-sound-alias 580 | #:export-wave 581 | #:export-wave-as-code 582 | #:play-sound 583 | #:stop-sound 584 | #:pause-sound 585 | #:resume-sound 586 | #:is-sound-playing 587 | #:set-sound-volume 588 | #:set-sound-pitch 589 | #:set-sound-pan 590 | #:wave-format 591 | #:get-wave-samples 592 | #:unload-wave-samples 593 | #:wave-copy 594 | #:wave-crop 595 | #:load-music-stream 596 | #:load-music-stream-from-memory 597 | #:is-music-ready 598 | #:unload-music-stream 599 | #:play-music-stream 600 | #:is-music-stream-playing 601 | #:update-music-stream 602 | #:stop-music-stream 603 | #:pause-music-stream 604 | #:resume-music-stream 605 | #:seek-music-stream 606 | #:set-music-volume 607 | #:set-music-pitch 608 | #:set-music-pan 609 | 610 | #:get-music-time-length 611 | #:get-music-time-played 612 | #:update-audio-stream 613 | #:load-audio-stream 614 | #:is-audio-stream-ready 615 | #:unload-audio-stream 616 | #:update-audio-stream 617 | #:is-audio-stream-processed 618 | #:play-audio-stream 619 | #:pause-audio-stream 620 | #:resume-audio-stream 621 | #:is-audio-stream-playing 622 | #:stop-audio-stream 623 | #:set-audio-stream-volume 624 | #:set-audio-stream-pitch 625 | #:set-audio-stream-pan 626 | #:set-audio-stream-buffer-size-default 627 | #:set-audio-stream-callback 628 | #:attach-audio-stream-processor 629 | #:detach-audio-stream-processor 630 | #:attach-audio-mixed-processor 631 | #:detach-audio-mixed-processor 632 | 633 | 634 | ;; high level api 635 | #:with-window 636 | #:with-drawing 637 | #:with-mode-2d 638 | #:with-mode-3d 639 | #:with-texture-mode 640 | #:with-shader-mode 641 | #:with-blend-mode 642 | #:with-audio-device 643 | #:with-audio-stream 644 | #:with-sound)) 645 | 646 | (defpackage #:cl-rlgl 647 | (:nicknames #:rlgl) 648 | (:use #:cl #:cffi #:alexandria #:cl-raylib-util) 649 | (:export 650 | #:+texture-wrap-s+ 651 | #:+texture-wrap-t+ 652 | #:+texture-map-filter+ 653 | #:+texture-min-filter+ 654 | 655 | #:+texture-filter-nearest+ 656 | #:+texture-filter-linear+ 657 | #:+texture-filter-mip-nearest+ 658 | #:+texture-filter-nearest-mip-linear+ 659 | #:+texture-filter-linear-mip-nearest+ 660 | #:+texture-filter-mip-linear+ 661 | #:+texture-filter-anisotropic+ 662 | #:+texture-mipmap-bias-ratio+ 663 | 664 | #:+texture-wrap-repeat+ 665 | #:+texture-wrap-clamp+ 666 | #:+texture-wrap-mirror-repeat+ 667 | #:+texture-wrap-minnor-clamp+ 668 | 669 | #:+modelview+ 670 | #:+projection+ 671 | #:+texture+ 672 | 673 | #:+lines+ 674 | #:+triangles+ 675 | #:+quads+ 676 | 677 | #:+unsigned-byte+ 678 | #:+float+ 679 | 680 | #:+stream-draw+ 681 | #:+stream-read+ 682 | #:+stream-copy+ 683 | #:+static-draw+ 684 | #:+static-read+ 685 | #:+static-copy+ 686 | #:+dynamic-draw+ 687 | #:+dynamic-read+ 688 | #:+dynamic-copy+ 689 | 690 | #:+fragment-shader+ 691 | #:+vertext-shader+ 692 | #:+compute-shader+ 693 | 694 | #:+zero+ 695 | #:+one+ 696 | #:+src-color+ 697 | #:+one-minu-src-color+ 698 | #:+src-alpha+ 699 | #:+one-minus-src-alpha+ 700 | #:+dst-alpha+ 701 | #:+one-minus-dst-alpha+ 702 | #:+dst-color+ 703 | #:+one-minus-dst-color+ 704 | #:+src-alpha-saturate+ 705 | #:+constant-color+ 706 | #:+one-minus-constant-color+ 707 | #:+constant-alpha+ 708 | #:+one-minus-constant-alpha+ 709 | 710 | #:+func-add+ 711 | #:+min+ 712 | #:+max+ 713 | #:+func-subtract+ 714 | #:+func-reverse-subtract+ 715 | #:+blend-equation+ 716 | #:+blend-equation-rgb+ 717 | #:+blend-equation-alpha+ 718 | #:+blend-dst-rgb+ 719 | #:+blend-src-rgb+ 720 | #:+blend-dst-alpha+ 721 | #:+blend-src-alpha+ 722 | #:+blend-color+ 723 | 724 | #:%vertex-buffer 725 | #:%draw-call 726 | #:%render-batch 727 | 728 | #:matrix-mode 729 | #:push-matrix 730 | #:pop-matrix 731 | #:load-identity 732 | #:translate-f 733 | #:rotate-f 734 | #:scale-f 735 | #:mult-matrix-f 736 | #:frustum 737 | #:ortho 738 | #:viewport 739 | #:begin 740 | #:end 741 | #:vertex-2i 742 | #:vertex-2f 743 | #:vertex-3f 744 | #:textcoord-2f 745 | #:normal-3f 746 | #:color-4ub 747 | #:color-3f 748 | #:color-4f 749 | #:enable-vertext-array 750 | #:disable-vertext-array 751 | #:enable-vertex-buffer 752 | #:disable-vertex-buffer 753 | #:enable-vertex-buffer-element 754 | #:disable-vertex-buffer-element 755 | #:enable-vertex-buffer-attribute 756 | #:disable-vertex-buffer-attribute 757 | #:active-texture-slot 758 | #:enable-texture 759 | #:disable-texture 760 | #:enable-texture-cubemap 761 | #:disable-texture-cubemap 762 | #:texture-parameters 763 | #:cubemap-parameters 764 | #:enable-shader 765 | #:disable-shader 766 | #:enable-framebuffer 767 | #:disable-framebuffer 768 | #:active-draw-buffers 769 | #:enable-color-blend 770 | #:disable-color-blend 771 | #:enable-depth-test 772 | #:disable-depth-test 773 | #:enable-depth-mask 774 | #:disable-depth-mask 775 | #:enable-backface-culling 776 | #:disable-backface-culling 777 | #:set-cull-face 778 | #:enable-scissor-test 779 | #:disable-scissor-test 780 | #:scissor 781 | #:enable-wire-mode 782 | #:disable-wire-mode 783 | #:set-line-width 784 | #:get-line-width 785 | #:enable-smooth-lines 786 | #:disable-smooth-lines 787 | #:enable-stereo-render 788 | #:disable-sterea-render 789 | #:is-stereo-render-enabled 790 | #:clear-color 791 | #:clear-screen-buffers 792 | #:check-errors 793 | #:set-blend-mode 794 | #:set-blend-factors 795 | #:set-blend-factors-separate 796 | 797 | #:rlgl-init 798 | #:rlgl-close 799 | #:load-extensions 800 | #:get-version 801 | 802 | #:set-framebuffer-width 803 | #:get-framebuffer-width 804 | #:set-framebuffer-height 805 | #:get-framebuffer-height 806 | 807 | #:get-texture-id-default 808 | #:get-shader-id-default 809 | #:get-shader-locs-default 810 | 811 | #:load-render-batch 812 | #:unload-render-batch 813 | #:draw-render-batch 814 | #:set-render-batch-active 815 | #:draw-render-batch-active 816 | #:check-render-batch-limit 817 | 818 | #:set-texture 819 | 820 | #:load-vertex-array 821 | #:load-vertex-buffer 822 | #:load-vertext-buffer-element 823 | #:update-vertex-buffer 824 | #:update-vertex-buffer-elements 825 | #:unload-vertex-array 826 | #:unload-vertex-buffer 827 | #:set-vertex-attribute 828 | #:set-vertex-attribute-divisor 829 | #:set-vertex-attribute-default 830 | #:draw-vertex-array 831 | #:draw-vertex-array-elements 832 | #:draw-vertex-array-instanced 833 | #:draw-vertex-array-elements-instanced 834 | 835 | #:load-texture 836 | #:load-texture-depth 837 | #:load-texture-cubemap 838 | #:update-texture 839 | #:get-gl-texture-formats 840 | #:get-pixel-format-name 841 | #:unload-texture 842 | #:gen-texture-mipmaps 843 | #:read-texture-pixels 844 | #:read-screen-pixels 845 | 846 | #:load-framebuffer 847 | #:framebuffer-attach 848 | #:framebuffer-complete 849 | #:unload-framebuffer 850 | 851 | #:load-shader-code 852 | #:compile-shader 853 | #:load-shader-program 854 | #:unload-shader-program 855 | #:get-location-uniform 856 | #:get-location-attrib 857 | #:set-uniform 858 | #:set-uniform-matrix 859 | #:set-uniform-sampler 860 | #:set-shader 861 | #:load-compute-shader-program 862 | #:compute-shader-dispatch 863 | #:load-shader-buffer 864 | #:unload-shader-buffer 865 | #:update-shader-buffer 866 | #:bind-shader-buffer 867 | #:read-shader-buffer 868 | #:copy-shader-buffers 869 | #:get-shader-buffer-size 870 | #:bind-image-texture 871 | 872 | #:get-matrix-modelview 873 | #:get-matrix-projection 874 | #:get-matrix-transform 875 | #:get-matrix-projection-stereo 876 | #:get-matrix-view-offset-stereo 877 | #:set-matrix-projection 878 | #:set-matrix-modelview 879 | #:set-matrix-projection-stereo 880 | #:set-matrix-view-offset-stereo 881 | #:load-draw-cube 882 | #:load-draw-quad)) 883 | -------------------------------------------------------------------------------- /src/util.lisp: -------------------------------------------------------------------------------- 1 | (in-package #:cl-raylib-util) 2 | 3 | (defmethod translate-name-from-foreign ((spec string) (package (eql (find-package 'cl-raylib))) &optional varp) 4 | (let ((name (translate-camelcase-name spec :upper-initial-p t :special-words '("2D" "3D" "FPS" "HSV" "POT" "RES" "TTF" "BRDF" "URL" "UTF8")))) 5 | (if varp (intern (format nil "*~a" name)) name))) 6 | 7 | (defmethod translate-name-to-foreign ((spec symbol) (package (eql (find-package 'cl-raylib))) &optional varp) 8 | (let ((name (translate-camelcase-name spec :upper-initial-p t :special-words '("2D" "3D" "FPS" "HSV" "POT" "RES" "TTF" "BRDF" "URL" "UTF8")))) 9 | (if varp (subseq name 1 (1- (length name))) name))) 10 | 11 | (defmacro define-conversion-into-foreign-memory (lambda-list &body body) 12 | (let ((unquoted (mapcar (lambda (x) 13 | (etypecase x 14 | (symbol x) 15 | (list (car x)))) 16 | (list (first lambda-list) (third lambda-list))))) 17 | (labels ((walk-and-quote (form) 18 | "A simple code walker that works fine without symbol shadowing" 19 | (typecase form 20 | (list (cond 21 | ((eql (first form) 'quote) `(quote ,form)) 22 | ((eql form body) `(list 'progn . ,(mapcar #'walk-and-quote form))) 23 | (t `(list . ,(mapcar #'walk-and-quote form))))) 24 | (t (if (member form unquoted) form `(quote ,form)))))) 25 | `(progn 26 | (eval-when (:compile-toplevel :load-toplevel :execute) 27 | (defmethod expand-into-foreign-memory ,lambda-list 28 | ,(walk-and-quote body))) 29 | (defmethod translate-into-foreign-memory ,lambda-list 30 | ,@body))))) 31 | 32 | (defmacro define-conversion-from-foreign (lambda-list &body body) 33 | (let ((unquoted (let ((arg1 (first lambda-list))) 34 | (etypecase arg1 35 | (symbol arg1) 36 | (list arg1))))) 37 | (labels ((walk-and-quote (form) 38 | "A simple code walker that works fine without symbol shadowing" 39 | (typecase form 40 | (list (cond 41 | ((eql (first form) 'quote) `(quote ,form)) 42 | ((eql form body) `(list 'progn . ,(mapcar #'walk-and-quote form))) 43 | (t `(list . ,(mapcar #'walk-and-quote form))))) 44 | (t (if (eql form unquoted) form `(quote ,form)))))) 45 | `(progn 46 | (eval-when (:compile-toplevel :load-toplevel :execute) 47 | (defmethod expand-from-foreign ,lambda-list 48 | ,(walk-and-quote body))) 49 | (defmethod translate-from-foreign ,lambda-list 50 | ,@body))))) 51 | --------------------------------------------------------------------------------