diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.lonestar.org> | 2020-01-01 12:38:35 -0500 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.lonestar.org> | 2020-01-01 12:59:36 -0500 |
| commit | 4d42144c4dc35a8e7e7ce544e90b34eb440ed1c5 (patch) | |
| tree | 0e150434928c1fdf2446ad8cd8d77cdac5aef892 /sdl.glue.c | |
| parent | bf47e7499c649c55ef1045738b0ba5c163701500 (diff) | |
Add initial SDL bindings.
Diffstat (limited to 'sdl.glue.c')
| -rw-r--r-- | sdl.glue.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/sdl.glue.c b/sdl.glue.c new file mode 100644 index 0000000..18eceee --- /dev/null +++ b/sdl.glue.c @@ -0,0 +1,73 @@ +/* CFLAGS: -Wall -Wextra */ +/* LIBS: c SDL2 */ + +#include <stdint.h> + +#include <SDL2/SDL.h> + +int sdl$init(uint32_t flags) +{ + return SDL_Init(flags); +} + +void sdl$quit(void) +{ + SDL_Quit(); +} + +void *sdl$mkwin(const char *title, int x, int y, int w, int h, uint32_t flags) +{ + return (void *) SDL_CreateWindow(title, x, y, w, h, flags); +} + +void sdl$freewin(void *win) +{ + return SDL_DestroyWindow((SDL_Window *) win); +} + +void *sdl$mkrenderer(void *win, int index, uint32_t flags) +{ + return (void *) SDL_CreateRenderer((SDL_Window *) win, index, flags); +} + +int sdl$copy(void *r, void *tex) +{ + return SDL_RenderCopy((SDL_Renderer *) r, (SDL_Texture *) tex, NULL, NULL); +} + +void sdl$present(void *r) +{ + SDL_RenderPresent((SDL_Renderer *) r); +} + +void sdl$freerenderer(void *r) +{ + return SDL_DestroyRenderer((SDL_Renderer *) r); +} + +void *sdl$mktexture(void *r, uint32_t fmt, int access, int w, int h) +{ + return (void *) SDL_CreateTexture((SDL_Renderer *) r, fmt, access, w, h); +} + +int sdl$update(void *tex, void *pixels, int pitch) +{ + return SDL_UpdateTexture((SDL_Texture *) tex, NULL, pixels, pitch); +} +void sdl$freetexture(void *tex) +{ + return SDL_DestroyTexture((SDL_Texture *) tex); +} + +void sdl$delay(uint32_t ms) +{ + SDL_Delay(ms); +} + +// SDL_GetKeyboardState +// SDL_SCANCODE_{} + +// 1 2 3 C 1 2 3 4 +// 4 5 6 D This is emulated with these Q W E R +// 7 8 9 E keyboard keys --> A S D F +// A 0 B F Z X C V |