-
Notifications
You must be signed in to change notification settings - Fork 1
/
raylib-core.scm
136 lines (93 loc) · 3.7 KB
/
raylib-core.scm
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
;;; Window and Graphics Device Functions (Module: core)
;; Window-related functions
(define init-window
(foreign-lambda void "InitWindow" int int c-string))
(foreign-predicate window-should-close? "WindowShouldClose" int ())
(define close-window
(foreign-lambda void "CloseWindow"))
;; Drawing-related functions
(foreign-define-with-struct clear-background
"ClearBackground"
void
(((c-pointer (struct Color)) color)))
(define begin-drawing
(foreign-lambda void "BeginDrawing"))
(define end-drawing
(foreign-lambda void "EndDrawing"))
(foreign-define-with-struct begin-mode-3d
"BeginMode3D"
void
(((c-pointer (struct Camera3D)) cameraP)))
(define end-mode-3d
(foreign-lambda void "EndMode3D"))
(foreign-define-with-struct begin-texture-mode
"BeginTextureMode"
void
(((c-pointer (struct RenderTexture2D)) target)))
(define end-texture-mode
(foreign-lambda void "EndTextureMode"))
;; Screen-space-related functions
(foreign-constructor get-mouse-ray
"GetMouseRay"
ray
(c-pointer (struct Ray))
(((c-pointer (struct Vector2)) mousePosition)
((c-pointer (struct Camera3D)) curCamera)))
;; timing-related functions
(define set-target-fps
(foreign-lambda void "SetTargetFPS" int))
(define get-frame-time
(foreign-lambda float "GetFrameTime"))
;; Color-related functions
(foreign-constructor fade
"Fade"
color
(c-pointer (struct Color))
(((c-pointer (struct Color)) baseColor)
(float alpha)))
;; Misc. functions
(define set-config-flags
(foreign-lambda void "SetConfigFlags" unsigned-short))
(define set-trace-log-level
(foreign-lambda void "SetTraceLogLevel" unsigned-short))
(define get-random-value
(foreign-lambda int "GetRandomValue" int int))
;; Files management functions
(foreign-predicate is-file-dropped "IsFileDropped" int ())
(define get-dropped-files
(foreign-safe-lambda* scheme-object ()
"int count = 0;
C_word lst = C_SCHEME_END_OF_LIST;
C_word str_len, str;
C_word* p;
char** droppedFiles = GetDroppedFiles(&count);
if (count == 0) {
C_return(C_SCHEME_FALSE);
}
for (int i=0; i<count; i++) {
str_len = strlen(droppedFiles[i]);
p = C_alloc(C_SIZEOF_PAIR + C_SIZEOF_STRING(str_len));
str = C_string(&p, str_len, droppedFiles[i]);
lst = C_a_pair(&p, str, lst);
}
C_return(lst);"))
(define clear-dropped-files
(foreign-lambda void "ClearDroppedFiles"))
;; Persistent storage management
;;; Input Handling Functions (Module: core)
(foreign-predicate is-key-pressed? "IsKeyPressed" int ((int keyCode)))
(foreign-predicate is-key-down? "IsKeyDown" int ((int keyCode)))
(foreign-predicate is-mouse-button-pressed? "IsMouseButtonPressed" int ((int mouseButton)))
(foreign-predicate is-mouse-button-down? "IsMouseButtonDown" int ((int mouseButton)))
(foreign-predicate is-mouse-button-released? "IsMouseButtonReleased" int ((int mouseButton)))
(foreign-predicate is-mouse-button-up? "IsMouseButtonUp" int ((int mouseButton)))
(define get-mouse-x
(foreign-lambda int "GetMouseX"))
(define get-mouse-y
(foreign-lambda int "GetMouseY"))
(foreign-constructor get-mouse-position
"GetMousePosition"
vector-2
(c-pointer (struct Vector2)))
(define get-mouse-wheel-move
(foreign-lambda int "GetMouseWheelMove"))