raylib
TOC »
- raylib
- Description
- Requirements
- Documentation
- Color interface
- Vector interface
- Rectangle interface
- Texture interface
- Font interface
- Camera2D interface
- Camera3D interface
- Audio interface
- Constants
- General interface
- Window-related functions
- Drawing-related functions
- Timing-related functions
- Input-related functions: keyboard
- Input-related functions: mouse
- Misc. functions
- File system functions
- Texture loading functions
- Basic shapes drawing functions
- Texture drawing functions
- Text drawing functions
- Basic geometric 3D shapes drawing functions
- Audio
- Quality of life
- Example
- Source repository
- Authors
- License
Description
Bindings to the raylib game library version 5.5. These are not complete yet, but all of the functions I commonly use are ported over. It's a very thin wrapper around the raylib C library that hopefully has minimal performance drawbacks.
Types such as Color, Vector2, Vector3, and Rectangle are represented as SRFI-4 vectors to keep the memory managed by CHICKEN.
See raylib.h for more info on each function.
Requirements
- foreigners
- raylib c library (should be installed as a SHARED library on your system. See install-raylib.sh)
Documentation
Color interface
- make-color R G B Aprocedure
Represented as u8vector.
Vector interface
- make-vec2 X Yprocedure
- vec2-x Vprocedure
- vec2-y Vprocedure
- make-vec3 X Y Zprocedure
- vec3-x Vprocedure
- vec3-y Vprocedure
- vec3-z Vprocedure
Represented as f32vector.
Rectangle interface
- make-rect X Y W Hprocedure
- rect-x RECTprocedure
- rect-y RECTprocedure
- rect-w RECTprocedure
- rect-h RECTprocedure
Represented as f32vector.
Texture interface
- make-textureprocedure
- free-texture TEXTUREprocedure
Allocates C struct in unmanaged memory (C_malloc). Remember to free.
- texture-id TEXTUREprocedure
- texture-width TEXTUREprocedure
- texture-height TEXTUREprocedure
- texture-mipmaps TEXTUREprocedure
- texture-format TEXTUREprocedure
Font interface
- make-fontprocedure
- free-font FONTprocedure
Allocates C struct in unmanaged memory (C_malloc). Remember to free.
- font-base-size FONTprocedure
- font-glyph-count FONTprocedure
- font-glyph-padding FONTprocedure
- font-texture TEXTUREOUT FONTprocedure
- font-rec FONT INDEXprocedure
- font-glyph-value FONT INDEXprocedure
- font-glyph-offset-x FONT INDEXprocedure
- font-glyph-offset-y FONT INDEXprocedure
- font-glyph-advance-x FONT INDEXprocedure
Camera2D interface
- make-camera2dprocedure
- free-camera2d CAMERAprocedure
Allocates C struct in unmanaged memory (C_malloc). Remember to free.
- camera2d-offset CAMERAprocedure
- camera2d-target CAMERAprocedure
Return f32vector (Vector2).
- camera2d-rotation CAMERAprocedure
- camera2d-zoom CAMERAprocedure
Return flonum.
- camera2d-offset-set! CAMERA VEC2procedure
- camera2d-target-set! CAMERA VEC2procedure
- camera2d-rotation-set! CAMERA ROTATIONprocedure
- camera2d-zoom-set! CAMERA ZOOMprocedure
Set the specified slots.
Camera3D interface
- make-camera3dprocedure
- free-camera3d CAMERAprocedure
Allocates C struct in unmanaged memory (C_malloc). Remember to free.
- camera3d-position CAMERAprocedure
- camera3d-target CAMERAprocedure
- camera3d-up CAMERAprocedure
Return f32vector (Vector3).
- camera3d-fovy CAMERAprocedure
Return flonum.
- camera3d-projection CAMERAprocedure
Return fixnum.
- camera3d-position-set! CAMERA VEC3procedure
- camera3d-target-set! CAMERA VEC3procedure
- camera3d-up-set! CAMERA VEC3procedure
- camera3d-fovy-set! CAMERA FOVYprocedure
- camera3d-projection-set! CAMERA PROJprocedure
Audio interface
- make-waveprocedure
- free-wave WAVEprocedure
- make-soundprocedure
- free-sound SOUNDprocedure
- wave-frame-count WAVEprocedure
- wave-sample-rate WAVEprocedure
- wave-sample-size WAVEprocedure
- wave-channels WAVEprocedure
- wave-data WAVEprocedure
- wave-frame-count-set! WAVE VALprocedure
- wave-sample-rate-set! WAVE VALprocedure
- wave-sample-size-set! WAVE VALprocedure
- wave-channels-set! WAVE VALprocedure
- wave-data-set! WAVE VALprocedure
Constants
The following are defined from raylib.h:
- Colors (e.g. LIGHTGRAY)
- KEY_* (e.g. KEY_ENTER)
- MOUSE_BUTTON_* (e.g. MOUSE_BUTTON_LEFT)
- LOG_* (e.g. LOG_INFO)
General interface
Window-related functions
- init-window WIDTH HEIGHT TITLEprocedure
Initialize window and OpenGL context.
- close-windowprocedure
Close window and unload OpenGL context.
- get-screen-widthprocedure
Get current screen width.
- get-screen-heightprocedure
Get current screen height.
- window-should-close?procedure
Check if application should close (KEY_ESCAPE pressed or window's close icon clicked).
- set-config-flags FLAGSprocedure
Setup init configuration flags (view FLAGS in raylib.h).
Drawing-related functions
- begin-drawingprocedure
Setup canvas (framebuffer) to start drawing.
- end-drawingprocedure
End canvas drawing and swap buffers (double buffering).
- begin-mode-2d CAMERAprocedure
Begin 2D mode with custom camera (2D).
- end-mode-2dprocedure
Ends 2D mode with custom camera.
- begin-mode-3d CAMERAprocedure
Begin 3D mode with custom camera (3D).
- end-mode-3dprocedure
Ends 3D mode and returns to default 2D orthographic mode.
- clear-background COLORprocedure
Set background color (framebuffer clear color).
- begin-scissor-mode X Y WIDTH HEIGHTprocedure
Begin scissor mode (define screen area for following drawing).
- end-scissor-modeprocedure
End scissor mode.
Timing-related functions
- set-target-fps FPSprocedure
Set target FPS (maximum).
- get-frame-timeprocedure
Get time in seconds for last frame drawn (delta time).
- get-timeprocedure
Get elapsed time in seconds since InitWindow().
- get-fpsprocedure
Get current FPS.
Input-related functions: keyboard
- key-pressed? KEYprocedure
Check if a key has been pressed once.
- key-pressed-repeat? KEYprocedure
Check if a key has been pressed again.
- key-down? KEYprocedure
Check if a key is being pressed.
- key-released? KEYprocedure
Check if a key has been released once.
- key-up? KEYprocedure
Check if a key is NOT being pressed.
- get-key-pressedprocedure
Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty.
- get-char-pressedprocedure
Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty.
Input-related functions: mouse
- mouse-button-pressed? MOUSEBUTTONprocedure
Check if a mouse button has been pressed once.
- mouse-button-down? MOUSEBUTTONprocedure
Check if a mouse button is being pressed.
- mouse-button-released? MOUSEBUTTONprocedure
Check if a mouse button has been released once.
- mouse-button-up? MOUSEBUTTONprocedure
Check if a mouse button is NOT being pressed.
- get-mouse-xprocedure
Get mouse position X.
- get-mouse-yprocedure
Get mouse position Y.
- get-mouse-positionprocedure
Get mouse position XY.
Misc. functions
- trace-log LOGLEVEL TEXTprocedure
Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...).
File system functions
- change-directory DIRprocedure
Change working directory, return true on success.
Texture loading functions
- load-texture FILENAMEprocedure
Load texture from file into GPU memory (VRAM).
- unload-texture TEXTUREprocedure
Basic shapes drawing functions
- draw-pixel POSX POSY COLORprocedure
Draw a pixel using geometry [Can be slow, use with care].
- draw-pixel-v POSITION COLORprocedure
Draw a pixel using geometry (Vector version) [Can be slow, use with care].
- draw-line STARTPOSX STARTPOSY ENDPOSX ENDPOSY COLORprocedure
Draw a line.
- draw-line-v STARTPOS ENDPOS COLORprocedure
Draw a line (using gl lines).
- draw-line-ex STARTPOS ENDPOS THICK COLORprocedure
Draw a line (using triangles/quads).
- draw-circle CENTERX CENTERY RADIUS COLORprocedure
Draw a color-filled circle.
- draw-circle-v CENTER RADIUS COLORprocedure
Draw a color-filled circle (Vector version).
- draw-circle-lines CENTERX CENTERY RADIUS COLORprocedure
Draw circle outline.
- draw-circle-lines-v CENTER RADIUS COLORprocedure
Draw circle outline (Vector version).
- draw-rectangle POSX POSY WIDTH HEIGHT COLORprocedure
Draw a color-filled rectangle.
- draw-rectangle-v POSITION SIZE COLORprocedure
Draw a color-filled rectangle (Vector version).
- draw-rectangle-rec RECT COLORprocedure
Draw a color-filled rectangle.
- draw-rectangle-pro RECT ORIGIN ROTATION COLORprocedure
Draw a color-filled rectangle with pro parameters.
- draw-rectangle-lines POSX POSY WIDTH HEIGHT COLORprocedure
Draw rectangle outline.
- draw-rectangle-lines-ex RECT LINETHICK COLORprocedure
Draw rectangle outline with extended parameters.
- draw-triangle V1 V2 V3 COLORprocedure
Draw a color-filled triangle (vertex in counter-clockwise order!).
- draw-triangle-lines V1 V2 V3 COLORprocedure
Draw triangle outline (vertex in counter-clockwise order!).
Texture drawing functions
- draw-texture TEXTURE POSX POSY TINTprocedure
Draw a Texture2D.
- draw-texture-v TEXTURE POSITION TINTprocedure
Draw a Texture2D with position defined as Vector2.
- draw-texture-ex TEXTURE POSITION ROTATION SCALE TINTprocedure
Draw a Texture2D with extended parameters.
- draw-texture-rec TEXTURE SOURCERECT POSITION TINTprocedure
Draw a part of a texture defined by a rectangle.
- draw-texture-pro TEXTURE SOURCERECT DESTRECT ORIGIN ROTATION TINTprocedure
Draw a part of a texture defined by a rectangle with 'pro' parameters.
Text drawing functions
- draw-text TEXT POSX POSY FONTSIZE TINTprocedure
Draw text (using default font).
- draw-text-ex FONT TEXT POSITION FONTSIZE SPACING TINTprocedure
Draw text using FONT and additional parameters.
- draw-text-pro FONT TEXT POSITION ORIGIN ROTATION FONTSIZE SPACING TINTprocedure
Draw text using FONT and pro parameters (rotation).
- draw-fps POSX POSYprocedure
Draw current FPS.
- set-text-line-spacing SPACINGprocedure
Set vertical line spacing when drawing with line-breaks.
- measure-text TEXT FONTSIZEprocedure
Measure string width for default font.
- measure-text-ex FONT TEXT FONTSIZE SPACINGprocedure
Measure string size for FONT.
- load-font FILENAMEprocedure
Load font from file into GPU memory (VRAM).
- load-font-ex FILENAME FONTSIZE CODEPOINTS CODEPOINTCOUNTprocedure
Load font from file with extended parameters, use s32vector for CODEPOINTS.
- unload-font FONTprocedure
Unload font from GPU memory (VRAM).
- font-valid? FONTprocedure
Check if a font is valid (font data loaded, WARNING: GPU texture not checked).
Basic geometric 3D shapes drawing functions
- draw-line-3d STARTPOS ENDPOS COLORprocedure
Draw a line in 3D world space.
- draw-point-3d POSITION COLORprocedure
Draw a point in 3D space, actually a small line.
- draw-circle-3d CENTER RADIUS ROTATIONAXIS ROTATIONANGLE COLORprocedure
Draw a circle in 3D world space.
- draw-triangle-3d V1 V2 V3 COLORprocedure
Draw a color-filled triangle (vertex in counter-clockwise order!).
- draw-cube POSITION WIDTH HEIGHT LENGTH COLORprocedure
Draw cube.
- draw-cube-v POSITION SIZE COLORprocedure
Draw cube (Vector version).
- draw-cube-wires POSITION WIDTH HEIGHT LENGTH COLORprocedure
Draw cube wires.
- draw-cube-wires-v POSITION SIZE COLORprocedure
Draw cube wires (Vector version).
- draw-sphere CENTERPOS RADIUS COLORprocedure
Draw sphere.
- draw-sphere-ex CENTERPOS RADIUS RINGS SLICES COLORprocedure
Draw sphere with extended parameters.
- draw-sphere-wires CENTERPOS RADIUS RINGS SLICES COLORprocedure
Draw sphere wires.
- draw-cylinder POSITION RADIUSTOP RADIUSBOTTOM HEIGHT SLICES COLORprocedure
Draw cylinder/cone.
- draw-cylinder-ex STARTPOS ENDPOS STARTRADIUS ENDRADIUS HEIGHT SIDES COLORprocedure
Draw cylinder with base at STARTPOS and top at ENDPOS.
- draw-cylinder-wires POSITION RADIUSTOP RADIUSBOTTOM HEIGHT SLICES COLORprocedure
Draw cylinder/cone wires.
- draw-cylinder-wires-ex STARTPOS ENDPOS STARTRADIUS ENDRADIUS HEIGHT SIDES COLORprocedure
Draw cylinder wires with base at STARTPOS and top at ENDPOS.
- draw-capsule STARTPOS ENDPOS RADIUS SLICES RINGS COLORprocedure
Draw a capsule with the center of its sphere caps at STARTPOS and ENDPOS.
- draw-capsule-wires STARTPOS ENDPOS RADIUS SLICES RINGS COLORprocedure
Draw a capsule wireframe with the center of its sphere caps at STARTPOS and ENDPOS.
- draw-plane CENTERPOS SIZE COLORprocedure
Draw plane XZ.
- draw-grid SLICES SPACINGprocedure
Draw a grid (centered at (0, 0, 0)).
Audio
- init-audio-deviceprocedure
- load-wave FILENAMEprocedure
- unload-wave WAVEprocedure
- load-sound-from-wave WAVEprocedure
- load-sound FILENAMEprocedure
- unload-sound SOUNDprocedure
- play-sound SOUNDprocedure
Quality of life
- with-window WIDTH HEIGHT TITLE THUNKprocedure
- with-drawing THUNKprocedure
- with-mode-2d CAMERA THUNKprocedure
- with-mode-3d CAMERA THUNKprocedure
- with-scissor-mode X Y W H THUNKprocedure
Example
(import raylib) (init-window 800 450 "raylib [core] example - basic window") (let loop () (with-drawing (lambda () (clear-background RAYWHITE) (draw-text "Congrats! You created your first window!" 190 200 20 LIGHTGRAY))) (unless (window-should-close?) (loop))) (close-window)
Source repository
https://github.com/meowstr/chicken-raylib
Feel free to open issues and PR's!
Authors
Meowster
License
MIT