(define-library (raylib) (export init-window close-window) (export with-drawing begin-drawing end-drawing) (export in-scissor-mode begin-scissor-mode end-scissor-mode) (export in-texture-mode begin-texture-mode end-texture-mode) (import (gambit)) (pkg-config "gl" "raylib") ;;; ------- ;;; structs ;;; ------- (include "structs.scm") ;;; ------------------------- ;;; Drawing-related functions ;;; ------------------------- (include "drawing.scm") ;;; ------------------------ ;;; Timing-related functions ;;; ------------------------ (include "timing.scm") ;;; ----------------------------------------- ;;; Input-related functions: keyboard & mouse ;;; ----------------------------------------- (include "input.scm") ;;; -------------- ;;; rshapes module ;;; -------------- (include "shapes.scm") ;;; --------------- ;;; textures module ;;; --------------- (include "texture.scm") (begin (c-declare "#include \"raylib.h\"") ;;; ------------------------ ;;; Window-related functions ;;; ------------------------ ;; Initialize window and OpenGL context ;; void InitWindow(int width, int height, const char *title); (define init-window (c-lambda (int int char-string) void "InitWindow")) ;; Close window and unload OpenGL context ;; void CloseWindow(void); (define close-window (c-lambda () void "CloseWindow")) (define window-sould-close (c-lambda () bool "WindowShouldClose")) (define draw-fps (c-lambda (int int) void "DrawFPS")) ;;; MACROS ;;; hygienic drawing context (r7rs only!) (define-syntax with-drawing (syntax-rules () ((with-drawing body ...) (dynamic-wind begin-drawing (lambda () (begin body ...)) end-drawing)))) (define-syntax in-texture-mode (syntax-rules () ((with-drawing-to-texture (texture) body ...) (dynamic-wind (lambda () (begin-texture-mode texture)) (lambda () (begin body ...)) end-texture-mode)))) ;;; less hygienic drawing context for R5RS ;; (define-macro (with-drawing . body) ;; `(dynamic-wind ;; begin-drawing ;; (lambda () (begin ,@body)) ;; end-drawing)) ;;; hygienic scissor-mode (r7rs only!) (define-syntax in-scissor-mode (syntax-rules () ((in-scissor-mode (x y width height) body ...) (dynamic-wind (lambda () (begin-scissor-mode x y width height)) (lambda () (begin body ...)) end-scissor-mode)))) ))