garden/SDL.fnl

21 lines
1.0 KiB
Plaintext
Raw Normal View History

; todo: can we implement portable logic for finding dynamic libraries?
(terralib.linklibrary "/usr/lib64/libSDL2.so")
(fn load-sdl-headers [headers]
(let [includes (table.concat (icollect [_ h (ipairs headers)]
(.. "#include <SDL2/" h ".h>\n")))
env (terralib.includecstring includes)
SDL (collect [k v (pairs env)] (k:gsub "^SDL_" "") v)]
(set SDL.INIT_EVERYTHING (bit.bor SDL.INIT_TIMER SDL.INIT_AUDIO SDL.INIT_VIDEO
SDL.INIT_JOYSTICK SDL.INIT_HAPTIC
SDL.INIT_GAMECONTROLLER SDL.INIT_EVENTS))
SDL))
(load-sdl-headers [:SDL :SDL_hints :SDL_error :SDL_video :SDL_render
:SDL_pixels :SDL_rect :SDL_surface :SDL_clipboard
:SDL_events :SDL_keyboard :SDL_keycode :SDL_scancode
:SDL_mouse :SDL_joystick :SDL_gamecontroller :SDL_sensor
:SDL_haptic :SDL_audio :SDL_timer :SDL_filesystem
:SDL_rwops :SDL_messagebox])