aboutsummaryrefslogtreecommitdiffstats
path: root/raylib.sld
blob: 21746c763c0f53b25c5a658e4a6381df7f51c693 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(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))))
  ))