-
-
Notifications
You must be signed in to change notification settings - Fork 56
/
lib.dyon
191 lines (136 loc) · 5.53 KB
/
lib.dyon
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/// Returns the source code of render module.
/// The render module is imported from source by default in the top module.
///
/// In loader scripts, to import the render module in loaded modules:
/// ```
/// render := unwrap(module(in: "render.dyon", string: render_source(), imports: []))
/// source := "snake.dyon"
/// m := unwrap(load(source: source, imports: [render]))
/// ```
fn render_source() -> str { ... }
/// Draws draw list.
fn draw(draw_list: [any]) { ... }
/// Returns the window size without border in points.
fn window_size() -> vec4 { ... }
/// Returns the frame buffer size in pixels.
fn window_draw_size() -> vec4 { ... }
/// Gets window position.
fn window_position() -> vec4 { ... }
/// Sets window position.
fn set_window__position(pos: vec4) { ... }
/// Sets window size.
fn set_window__size(size: vec4) { ... }
/// Gets title of window.
fn window_title() -> str { ... }
/// Sets title of window.
fn set_window__title(text: str) { ... }
/// The number of updates per second.
fn event_loop_ups() -> f64 { ... }
/// The number of updates per second.
fn set_event_loop__ups(frames: f64) { ... }
/// The number of delayed updates before skipping them to catch up.
/// When set to 0, it will always try to catch up.
fn event_loop_upsreset() -> f64 { ... }
/// The number of delayed updates before skipping them to catch up.
/// When set to 0, it will always try to catch up.
fn set_event_loop__upsreset(frames: f64) { ... }
/// The maximum number of frames per second.
fn event_loop_maxfps() -> f64 { ... }
/// Sets maximum number of frames per second.
fn set_event_loop__maxfps(maxfps: f64) { ... }
/// Gets whether the event loop automatically swaps buffers.
fn event_loop_swapbuffers() -> bool { ... }
/// Swaps render buffers manually.
/// Do not use unless `event_loop_swapbuffers` is disabled.
fn swap_buffers() { ... }
/// Enable or disable automatic swapping of buffers.
fn set_event_loop__swapbuffers(swapbuffers: bool) { ... }
/// Gets whether the event loop runs in benchmark mode.
fn event_loop_benchmode() -> bool { ... }
/// Enable or disable benchmark mode in event loop.
fn set_event_loop__benchmode(benchmode: bool) { ... }
/// Gets whether the event loop renders only when receiving input.
fn event_loop_lazy() -> bool { ... }
/// Enable or disable rendering only when receiving input.
/// When enabled, update and idle events are disabled.
fn set_event_loop__lazy(lazy: bool) { ... }
/// Returns `true` when time to render.
fn render() -> bool { ... }
/// Returns `true` when rendering is done.
fn after_render() -> bool { ... }
/// Returns `true` when time to update.
fn update() -> bool { ... }
/// Returns `true` when event loop got nothing to do for a while.
fn idle() -> bool { ... }
/// Returns `true` when pressing a button.
fn press() -> bool { ... }
/// Returns `true` when releasing a button.
fn release() -> bool { ... }
/// Returns `true` when window is resized.
fn resize() -> bool { ... }
/// Returns `true` when window receives or loses focus.
fn focus() -> bool { ... }
/// Returns `true` when window gained or lost cursor.
fn cursor() -> bool { ... }
/// Returns `true` when window received text.
fn text() -> bool { ... }
/// Returns `true` when there is a mouse cursor event.
fn mouse_cursor() -> bool { ... }
/// Returns:
/// - `some(true)` when window received focus.
/// - `some(false)` when window looses focus.
/// - `none()` when there is no focus event.
fn focus_arg() -> opt[bool] { ... }
/// Returns:
/// - `some(true)` when window gained cursor.
/// - `some(false)` when window lost cursor.
/// - `none()` when there is no cursor event.
fn cursor_arg() -> opt[bool] { ... }
/// Returns the text input for text event.
fn text_arg() -> opt[str] { ... }
/// Returns the position for mouse cursor event.
fn mouse_cursor_pos() -> opt[vec4] { ... }
/// Extrapolated time in seconds, used to do smooth animation.
fn render_ext_dt() -> opt[f64] { ... }
/// Returns the delta time in seconds for update event.
fn update_dt() -> opt[f64] { ... }
/// Returns the expected idle time in seconds for idle event.
fn idle_dt() -> opt[f64] { ... }
/// Returns the keyboard key for press event.
fn press_keyboard_key() -> opt[f64] { ... }
/// Returns the keyboard key for release event.
fn release_keyboard_key() -> opt[f64] { ... }
/// Returns the mouse button for press event.
fn press_mouse_button() -> opt[f64] { ... }
/// Returns the mouse button for release event.
fn release_mouse_button() -> opt[f64] { ... }
/// Returns the width of rendered text for a given font.
fn width__font_size_string(font: f64, size: f64, text: str) -> f64 { ... }
/// Returns list of font names.
fn font_names() -> [str] { ... }
/// Loads font from file.
///
/// Returns `ok(id)` when successful.
fn load_font(file: str) -> res[f64] { ... }
/// Returns list of image names.
fn image_names() -> [str] { ... }
/// Loads image from file.
///
/// Returns `ok(id)` when successful.
fn load_image(file: str) -> res[f64] { ... }
/// Saves image to file.
fn save__image_file(image: f64, file: str) -> res[str] { ... }
/// Creates empty image.
fn create_image__name_size(name: str, size: vec4) -> f64 { ... }
/// Returns image size.
fn image_size(image: f64) -> vec4 { ... }
/// Sets pixel color in image.
fn pxl__image_pos_color(image: f64, pos: vec4, color: vec4) { ... }
/// Gets pixel color from image.
fn pxl__image_pos(image: f64, pos: vec4) -> vec4 { ... }
/// Creates texture from image.
///
/// Takes an image id and returns a texture id.
fn create_texture(image: f64) -> f64 { ... }
/// Updates texture with image.
fn update__texture_image(image: f64, texture: f64) { ... }