MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
Loading...
Searching...
No Matches
mx_sdl.h
Go to the documentation of this file.
1
6#ifndef __SDL2__H_
7#define __SDL2__H_
8
9#include <stdint.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
17
21int64_t init(void);
22
24void quit(void);
26
29
39int64_t create_window(const char *title, int64_t x, int64_t y, int64_t w, int64_t h, int64_t flags);
40
42void destroy_window(int64_t window_id);
43
45void set_window_title(int64_t window_id, const char *title);
46
48void set_window_position(int64_t window_id, int64_t x, int64_t y);
49
54void get_window_size(int64_t window_id, int64_t *w, int64_t *h);
55
57void set_window_fullscreen(int64_t window_id, int64_t fullscreen);
58
60void set_window_icon(uint64_t window_id, const char *path);
64
71int64_t create_renderer(int64_t window_id, int64_t index, int64_t flags);
72
74void destroy_renderer(int64_t renderer_id);
75
77void set_draw_color(int64_t renderer_id, int64_t r, int64_t g, int64_t b, int64_t a);
78
80void clear(int64_t renderer_id);
81
83void present(int64_t renderer_id);
84
89void get_renderer_output_size(int64_t renderer_id, int64_t *w, int64_t *h);
91
94
96void draw_point(int64_t renderer_id, int64_t x, int64_t y);
97
99void draw_line(int64_t renderer_id, int64_t x1, int64_t y1, int64_t x2, int64_t y2);
100
102void draw_rect(int64_t renderer_id, int64_t x, int64_t y, int64_t w, int64_t h);
103
105void fill_rect(int64_t renderer_id, int64_t x, int64_t y, int64_t w, int64_t h);
107
110
114int64_t poll_event(void);
115
117int64_t get_event_type(void);
118
120int64_t get_key_code(void);
121
123int64_t get_mouse_x(void);
124
126int64_t get_mouse_y(void);
127
129int64_t get_mouse_button(void);
131
134
138int64_t create_rgb_surface(int64_t width, int64_t height, int64_t depth);
139
141void free_surface(int64_t surf_ptr);
142
144int64_t blit_surface(int64_t src_ptr, int64_t dst_ptr, int64_t x, int64_t y);
146
149
155int64_t get_mouse_state(int64_t *x, int64_t *y);
156
162int64_t get_relative_mouse_state(int64_t *x, int64_t *y);
163
165int64_t get_mouse_buttons(void);
166
168int64_t get_relative_mouse_x(void);
169
171int64_t get_relative_mouse_y(void);
172
174int64_t get_relative_mouse_buttons(void);
176
179
184int64_t get_keyboard_state(int64_t *numkeys);
185
190int64_t is_key_pressed(int64_t scancode);
191
193int64_t get_num_keys(void);
195
198
200void set_clipboard_text(const char *text);
201
203const char *get_clipboard_text(void);
205
208
210void show_cursor(int64_t show);
212
215
224int64_t create_texture(int64_t renderer_id, int64_t format, int64_t access, int64_t w, int64_t h);
225
227void destroy_texture(int64_t texture_id);
228
234int64_t load_texture(int64_t renderer_id, const char *file_path);
235
237int64_t load_texture_color_key(int64_t renderer_id, const char *file_path);
238
240int64_t load_texture_color_key_rgb(int64_t renderer_id, const char *file_path, int64_t r, int64_t g, int64_t b);
241
243void render_texture(int64_t renderer_id, int64_t texture_id, int64_t src_x, int64_t src_y, int64_t src_w, int64_t src_h, int64_t dst_x, int64_t dst_y, int64_t dst_w, int64_t dst_h);
245
248
250int64_t get_ticks(void);
251
253void delay(int64_t ms);
255
265int64_t open_audio(int64_t freq, int64_t format, int64_t channels, int64_t samples);
266
268void close_audio(void);
269
271void pause_audio(int64_t pause_on);
272
280int64_t load_wav(const char *file_path, int64_t *audio_buf, int64_t *audio_len, int64_t *audio_spec);
281
283void free_wav(int64_t audio_buf);
284
286int64_t queue_audio(const void *data, int64_t len);
287
289int64_t get_queued_audio_size(void);
290
292void clear_queued_audio(void);
294
297
299int64_t update_texture(int64_t texture_id, const void *pixels, int64_t pitch);
300
305int64_t lock_texture(int64_t texture_id, void **pixels, int64_t *pitch);
306
308void unlock_texture(int64_t texture_id);
310
313
315int64_t init_text(void);
316
318void quit_text(void);
319
325int64_t load_font(const char *file, int64_t ptsize);
326
328void draw_text(int64_t renderer_id, int64_t font_id, const char *text, int64_t x, int64_t y, int64_t r, int64_t g, int64_t b, int64_t a);
330
333
335int64_t create_render_target(int64_t renderer_id, int64_t width, int64_t height);
336
338void set_render_target(int64_t renderer_id, int64_t target_id);
339
341void destroy_render_target(int64_t target_id);
342
344void present_scaled(int64_t renderer_id, int64_t target_id, int64_t scale_width, int64_t scale_height);
345
347void present_stretched(int64_t renderer_id, int64_t target_id, int64_t dst_width, int64_t dst_height);
349
350#ifdef __cplusplus
351}
352#endif
353
354#endif
int64_t poll_event(void)
Poll for a pending SDL event.
Definition sdl.c:182
void quit(void)
Shut down SDL2 and release all resources.
Definition sdl.c:34
void fill_rect(int64_t renderer_id, int64_t x, int64_t y, int64_t w, int64_t h)
Draw a filled rectangle.
Definition sdl.c:261
int64_t get_queued_audio_size(void)
Get the number of bytes of queued audio.
Definition sdl.c:506
void set_draw_color(int64_t renderer_id, int64_t r, int64_t g, int64_t b, int64_t a)
Set the current draw color (RGBA).
Definition sdl.c:206
void get_renderer_output_size(int64_t renderer_id, int64_t *w, int64_t *h)
Get the renderer output size.
Definition sdl.c:596
int64_t create_window(const char *title, int64_t x, int64_t y, int64_t w, int64_t h, int64_t flags)
Create an SDL window.
Definition sdl.c:86
int64_t get_relative_mouse_state(int64_t *x, int64_t *y)
Get the relative mouse state.
Definition sdl.c:703
int64_t open_audio(int64_t freq, int64_t format, int64_t channels, int64_t samples)
Open the audio device.
Definition sdl.c:458
void render_texture(int64_t renderer_id, int64_t texture_id, int64_t src_x, int64_t src_y, int64_t src_w, int64_t src_h, int64_t dst_x, int64_t dst_y, int64_t dst_w, int64_t dst_h)
Render a portion of a texture to a destination rectangle.
Definition sdl.c:397
void set_clipboard_text(const char *text)
Set the system clipboard text.
Definition sdl.c:557
const char * get_clipboard_text(void)
Get the system clipboard text.
Definition sdl.c:561
void set_window_title(int64_t window_id, const char *title)
Set the title of a window.
Definition sdl.c:569
int64_t get_num_keys(void)
Get the total number of keyboard keys.
Definition sdl.c:551
int64_t get_key_code(void)
Get the key code from the last keyboard event.
Definition sdl.c:190
void set_render_target(int64_t renderer_id, int64_t target_id)
Set the current render target (0 to render to the window).
Definition sdl.c:173
int64_t get_mouse_state(int64_t *x, int64_t *y)
Get the current mouse state with pointer coordinates.
Definition sdl.c:693
void free_surface(int64_t surf_ptr)
Free a surface.
Definition sdl.c:679
int64_t get_mouse_button(void)
Get the mouse button from the last mouse event.
Definition sdl.c:202
int64_t update_texture(int64_t texture_id, const void *pixels, int64_t pitch)
Update a texture with new pixel data.
Definition sdl.c:427
int64_t load_wav(const char *file_path, int64_t *audio_buf, int64_t *audio_len, int64_t *audio_spec)
Load a WAV file.
Definition sdl.c:478
int64_t get_mouse_buttons(void)
Get the current mouse button bitmask (pointerless variant).
Definition sdl.c:514
int64_t create_rgb_surface(int64_t width, int64_t height, int64_t depth)
Create an RGB surface.
Definition sdl.c:663
void quit_text(void)
Shut down the SDL_ttf subsystem.
Definition sdl.c:613
void set_window_position(int64_t window_id, int64_t x, int64_t y)
Set the position of a window.
Definition sdl.c:575
int64_t get_relative_mouse_y(void)
Get the relative mouse y delta (pointerless variant).
Definition sdl.c:525
int64_t create_renderer(int64_t window_id, int64_t index, int64_t flags)
Create a hardware-accelerated renderer for a window.
Definition sdl.c:121
void destroy_renderer(int64_t renderer_id)
Destroy a renderer by ID.
Definition sdl.c:139
void delay(int64_t ms)
Pause execution for the given number of milliseconds.
Definition sdl.c:454
int64_t get_keyboard_state(int64_t *numkeys)
Get the keyboard state array.
Definition sdl.c:536
void get_window_size(int64_t window_id, int64_t *w, int64_t *h)
Get the size of a window.
Definition sdl.c:581
void clear_queued_audio(void)
Clear all queued audio data.
Definition sdl.c:510
int64_t get_event_type(void)
Get the type of the last polled event.
Definition sdl.c:186
int64_t init(void)
Initialize SDL2 subsystems.
Definition sdl.c:26
int64_t load_texture_color_key_rgb(int64_t renderer_id, const char *file_path, int64_t r, int64_t g, int64_t b)
Load a BMP file as a texture with a custom RGB color-key transparency.
Definition sdl.c:371
void draw_rect(int64_t renderer_id, int64_t x, int64_t y, int64_t w, int64_t h)
Draw a rectangle outline.
Definition sdl.c:254
int64_t get_relative_mouse_x(void)
Get the relative mouse x delta (pointerless variant).
Definition sdl.c:519
int64_t get_mouse_y(void)
Get the mouse y coordinate from the last mouse event.
Definition sdl.c:198
void show_cursor(int64_t show)
Show or hide the mouse cursor.
Definition sdl.c:605
void clear(int64_t renderer_id)
Clear the renderer with the current draw color.
Definition sdl.c:212
void pause_audio(int64_t pause_on)
Pause or unpause audio playback.
Definition sdl.c:474
void draw_text(int64_t renderer_id, int64_t font_id, const char *text, int64_t x, int64_t y, int64_t r, int64_t g, int64_t b, int64_t a)
Draw text with a font at the given position and color.
Definition sdl.c:640
void destroy_window(int64_t window_id)
Destroy a window by ID.
Definition sdl.c:106
void free_wav(int64_t audio_buf)
Free a loaded WAV buffer.
Definition sdl.c:496
int64_t get_relative_mouse_buttons(void)
Get the relative mouse button bitmask (pointerless variant).
Definition sdl.c:531
int64_t load_texture_color_key(int64_t renderer_id, const char *file_path)
Load a BMP file as a texture with black color-key transparency.
Definition sdl.c:330
void destroy_render_target(int64_t target_id)
Destroy a render target texture.
Definition sdl.c:178
int64_t is_key_pressed(int64_t scancode)
Check whether a specific key is currently pressed.
Definition sdl.c:543
int64_t get_mouse_x(void)
Get the mouse x coordinate from the last mouse event.
Definition sdl.c:194
int64_t create_texture(int64_t renderer_id, int64_t format, int64_t access, int64_t w, int64_t h)
Create a blank texture.
Definition sdl.c:268
void draw_line(int64_t renderer_id, int64_t x1, int64_t y1, int64_t x2, int64_t y2)
Draw a line between two points.
Definition sdl.c:248
void present_stretched(int64_t renderer_id, int64_t target_id, int64_t dst_width, int64_t dst_height)
Present a render target stretched to the given dimensions.
Definition sdl.c:233
void set_window_icon(uint64_t window_id, const char *path)
Set the window icon from an image file.
Definition sdl.c:113
int64_t queue_audio(const void *data, int64_t len)
Queue audio data for playback.
Definition sdl.c:502
void set_window_fullscreen(int64_t window_id, int64_t fullscreen)
Set or clear fullscreen mode for a window.
Definition sdl.c:590
void close_audio(void)
Close the audio device.
Definition sdl.c:470
int64_t load_font(const char *file, int64_t ptsize)
Load a TrueType font.
Definition sdl.c:626
int64_t create_render_target(int64_t renderer_id, int64_t width, int64_t height)
Create an off-screen render target texture.
Definition sdl.c:146
void present_scaled(int64_t renderer_id, int64_t target_id, int64_t scale_width, int64_t scale_height)
Present a render target scaled to the given dimensions.
Definition sdl.c:224
int64_t load_texture(int64_t renderer_id, const char *file_path)
Load a texture from an image file.
Definition sdl.c:306
void unlock_texture(int64_t texture_id)
Unlock a previously locked texture.
Definition sdl.c:444
void present(int64_t renderer_id)
Present the renderer's back buffer to the screen.
Definition sdl.c:218
int64_t get_ticks(void)
Get the number of milliseconds since SDL initialization.
Definition sdl.c:450
int64_t init_text(void)
Initialize the SDL_ttf text rendering subsystem.
Definition sdl.c:609
int64_t blit_surface(int64_t src_ptr, int64_t dst_ptr, int64_t x, int64_t y)
Blit a source surface onto a destination surface at (x, y).
Definition sdl.c:684
int64_t lock_texture(int64_t texture_id, void **pixels, int64_t *pitch)
Lock a texture for direct pixel access.
Definition sdl.c:434
void draw_point(int64_t renderer_id, int64_t x, int64_t y)
Draw a single pixel.
Definition sdl.c:242
void destroy_texture(int64_t texture_id)
Destroy a texture.
Definition sdl.c:286