├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ └── bug-report.md └── workflows │ ├── test-build.yml │ └── test-old-versions-build.yml ├── .gitignore ├── .gitmodules ├── BREAKING.md ├── BSDmakefile ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── GNUmakefile ├── LICENSE ├── MAINTAINING.md ├── README.md ├── _libs ├── dummy.go ├── include │ └── SDL2 │ │ ├── SDL.h │ │ ├── SDL2_framerate.h │ │ ├── SDL2_gfxPrimitives.h │ │ ├── SDL2_gfxPrimitives_font.h │ │ ├── SDL2_imageFilter.h │ │ ├── SDL2_rotozoom.h │ │ ├── SDL_assert.h │ │ ├── SDL_atomic.h │ │ ├── SDL_audio.h │ │ ├── SDL_bits.h │ │ ├── SDL_blendmode.h │ │ ├── SDL_clipboard.h │ │ ├── SDL_config.h │ │ ├── SDL_config_android.h │ │ ├── SDL_config_android_arm.h │ │ ├── SDL_config_darwin_amd64.h │ │ ├── SDL_config_darwin_arm64.h │ │ ├── SDL_config_emscripten.h │ │ ├── SDL_config_iphoneos.h │ │ ├── SDL_config_linux_386.h │ │ ├── SDL_config_linux_amd64.h │ │ ├── SDL_config_linux_arm.h │ │ ├── SDL_config_linux_mipsle.h │ │ ├── SDL_config_macosx.h │ │ ├── SDL_config_minimal.h │ │ ├── SDL_config_os2.h │ │ ├── SDL_config_pandora.h │ │ ├── SDL_config_psp.h │ │ ├── SDL_config_windows.h │ │ ├── SDL_config_windows_386.h │ │ ├── SDL_config_windows_amd64.h │ │ ├── SDL_config_winrt.h │ │ ├── SDL_config_wiz.h │ │ ├── SDL_copying.h │ │ ├── SDL_cpuinfo.h │ │ ├── SDL_egl.h │ │ ├── SDL_endian.h │ │ ├── SDL_error.h │ │ ├── SDL_events.h │ │ ├── SDL_filesystem.h │ │ ├── SDL_gamecontroller.h │ │ ├── SDL_gesture.h │ │ ├── SDL_haptic.h │ │ ├── SDL_hidapi.h │ │ ├── SDL_hints.h │ │ ├── SDL_image.h │ │ ├── SDL_joystick.h │ │ ├── SDL_keyboard.h │ │ ├── SDL_keycode.h │ │ ├── SDL_loadso.h │ │ ├── SDL_locale.h │ │ ├── SDL_log.h │ │ ├── SDL_main.h │ │ ├── SDL_messagebox.h │ │ ├── SDL_metal.h │ │ ├── SDL_misc.h │ │ ├── SDL_mixer.h │ │ ├── SDL_mouse.h │ │ ├── SDL_mutex.h │ │ ├── SDL_name.h │ │ ├── SDL_opengl.h │ │ ├── SDL_opengl_glext.h │ │ ├── SDL_opengles.h │ │ ├── SDL_opengles2.h │ │ ├── SDL_opengles2_gl2.h │ │ ├── SDL_opengles2_gl2ext.h │ │ ├── SDL_opengles2_gl2platform.h │ │ ├── SDL_opengles2_khrplatform.h │ │ ├── SDL_pixels.h │ │ ├── SDL_platform.h │ │ ├── SDL_power.h │ │ ├── SDL_quit.h │ │ ├── SDL_rect.h │ │ ├── SDL_render.h │ │ ├── SDL_revision.h │ │ ├── SDL_rwops.h │ │ ├── SDL_scancode.h │ │ ├── SDL_sensor.h │ │ ├── SDL_shape.h │ │ ├── SDL_stdinc.h │ │ ├── SDL_surface.h │ │ ├── SDL_system.h │ │ ├── SDL_syswm.h │ │ ├── SDL_test.h │ │ ├── SDL_test_assert.h │ │ ├── SDL_test_common.h │ │ ├── SDL_test_compare.h │ │ ├── SDL_test_crc32.h │ │ ├── SDL_test_font.h │ │ ├── SDL_test_fuzzer.h │ │ ├── SDL_test_harness.h │ │ ├── SDL_test_images.h │ │ ├── SDL_test_log.h │ │ ├── SDL_test_md5.h │ │ ├── SDL_test_memory.h │ │ ├── SDL_test_random.h │ │ ├── SDL_thread.h │ │ ├── SDL_timer.h │ │ ├── SDL_touch.h │ │ ├── SDL_ttf.h │ │ ├── SDL_types.h │ │ ├── SDL_version.h │ │ ├── SDL_video.h │ │ ├── SDL_vulkan.h │ │ ├── begin_code.h │ │ ├── close_code.h │ │ ├── dummy.go │ │ ├── effects_internal.h │ │ ├── load_aiff.h │ │ ├── load_voc.h │ │ ├── miniz.h │ │ ├── mixer.h │ │ ├── music.h │ │ ├── music_cmd.h │ │ ├── music_flac.h │ │ ├── music_fluidsynth.h │ │ ├── music_mad.h │ │ ├── music_mikmod.h │ │ ├── music_modplug.h │ │ ├── music_mpg123.h │ │ ├── music_nativemidi.h │ │ ├── music_ogg.h │ │ ├── music_opus.h │ │ ├── music_timidity.h │ │ ├── music_wav.h │ │ ├── nanosvg.h │ │ └── nanosvgrast.h ├── libSDL2_android_arm.a ├── libSDL2_darwin_amd64.a ├── libSDL2_darwin_arm64.a ├── libSDL2_gfx_android_arm.a ├── libSDL2_gfx_darwin_amd64.a ├── libSDL2_gfx_linux_386.a ├── libSDL2_gfx_linux_amd64.a ├── libSDL2_gfx_linux_arm.a ├── libSDL2_gfx_windows_386.a ├── libSDL2_gfx_windows_amd64.a ├── libSDL2_image_android_arm.a ├── libSDL2_image_darwin_amd64.a ├── libSDL2_image_linux_386.a ├── libSDL2_image_linux_amd64.a ├── libSDL2_image_linux_arm.a ├── libSDL2_image_linux_arm_rpi.a ├── libSDL2_image_linux_arm_vivante.a ├── libSDL2_image_linux_mipsel.a ├── libSDL2_image_linux_mipsle.a ├── libSDL2_image_windows_386.a ├── libSDL2_image_windows_amd64.a ├── libSDL2_linux_386.a ├── libSDL2_linux_amd64.a ├── libSDL2_linux_arm.a ├── libSDL2_linux_arm_rpi.a ├── libSDL2_linux_arm_vivante.a ├── libSDL2_linux_mipsel.a ├── libSDL2_linux_mipsle.a ├── libSDL2_mixer_android_arm.a ├── libSDL2_mixer_darwin_amd64.a ├── libSDL2_mixer_linux_386.a ├── libSDL2_mixer_linux_amd64.a ├── libSDL2_mixer_linux_arm.a ├── libSDL2_mixer_linux_mipsle.a ├── libSDL2_mixer_windows_386.a ├── libSDL2_mixer_windows_amd64.a ├── libSDL2_ttf_android_arm.a ├── libSDL2_ttf_darwin_amd64.a ├── libSDL2_ttf_linux_386.a ├── libSDL2_ttf_linux_amd64.a ├── libSDL2_ttf_linux_arm.a ├── libSDL2_ttf_linux_arm_rpi.a ├── libSDL2_ttf_linux_arm_vivante.a ├── libSDL2_ttf_linux_mipsel.a ├── libSDL2_ttf_linux_mipsle.a ├── libSDL2_ttf_windows_386.a ├── libSDL2_ttf_windows_amd64.a ├── libSDL2_windows_386.a ├── libSDL2_windows_amd64.a ├── libSDL2main_android_arm.a ├── libSDL2main_darwin_amd64.a ├── libSDL2main_linux_386.a ├── libSDL2main_linux_amd64.a ├── libSDL2main_linux_arm.a ├── libSDL2main_linux_mipsle.a ├── libSDL2main_windows_386.a ├── libSDL2main_windows_amd64.a ├── libfreetype_android_arm.a ├── libfreetype_darwin_amd64.a ├── libfreetype_linux_386.a ├── libfreetype_linux_amd64.a ├── libfreetype_linux_arm.a ├── libfreetype_linux_mipsle.a ├── libfreetype_windows_386.a ├── libfreetype_windows_amd64.a ├── libjpeg_android_arm.a ├── libjpeg_darwin_amd64.a ├── libjpeg_linux_386.a ├── libjpeg_linux_amd64.a ├── libjpeg_linux_arm.a ├── libjpeg_linux_mipsle.a ├── libjpeg_windows_386.a ├── libjpeg_windows_amd64.a ├── libmpg123_android_arm.a ├── libmpg123_darwin_amd64.a ├── libmpg123_linux_386.a ├── libmpg123_linux_amd64.a ├── libmpg123_linux_arm.a ├── libmpg123_linux_mipsle.a ├── libmpg123_windows_386.a ├── libmpg123_windows_amd64.a ├── libogg_android_arm.a ├── libogg_darwin_amd64.a ├── libogg_linux_386.a ├── libogg_linux_amd64.a ├── libogg_linux_arm.a ├── libogg_linux_mipsle.a ├── libogg_windows_386.a ├── libogg_windows_amd64.a ├── libpng_android_arm.a ├── libpng_darwin_amd64.a ├── libpng_linux_386.a ├── libpng_linux_amd64.a ├── libpng_linux_arm.a ├── libpng_linux_mipsle.a ├── libpng_windows_386.a ├── libpng_windows_amd64.a ├── libvorbis_android_arm.a ├── libvorbis_darwin_amd64.a ├── libvorbis_linux_386.a ├── libvorbis_linux_amd64.a ├── libvorbis_linux_arm.a ├── libvorbis_linux_mipsle.a ├── libvorbis_windows_386.a ├── libvorbis_windows_amd64.a ├── libvorbisfile_android_arm.a ├── libvorbisfile_darwin_amd64.a ├── libvorbisfile_linux_386.a ├── libvorbisfile_linux_amd64.a ├── libvorbisfile_linux_arm.a ├── libvorbisfile_linux_mipsle.a ├── libvorbisfile_windows_386.a ├── libvorbisfile_windows_amd64.a ├── libz_darwin_amd64.a ├── libz_linux_386.a ├── libz_linux_amd64.a ├── libz_linux_mipsle.a ├── libz_windows_386.a └── libz_windows_amd64.a ├── gfx ├── sdl_gfx.go ├── sdl_gfx_cgo.go ├── sdl_gfx_cgo_static.go ├── sdl_gfx_test.go └── sdl_gfx_wrapper.h ├── go.mod ├── img ├── sdl_image.go ├── sdl_image_cgo.go ├── sdl_image_cgo_static.go ├── sdl_image_test.go └── sdl_image_wrapper.h ├── make.bat ├── mix ├── TODO.md ├── midi.go ├── sdl_mixer.go ├── sdl_mixer_cgo.go ├── sdl_mixer_cgo_static.go └── sdl_mixer_wrapper.h ├── raster ├── painter.go └── painter_test.go ├── sdl ├── TODO.md ├── audio.go ├── audio_test.go ├── blendmode.go ├── clipboard.go ├── clipboard_test.go ├── cpuinfo.go ├── cpuinfo_test.go ├── endian.go ├── error.go ├── events.c ├── events.go ├── events.h ├── events_test.go ├── filesystem.go ├── filesystem_test.go ├── gamecontroller.go ├── gesture.go ├── guid.go ├── haptic.go ├── helpers.go ├── hidapi.go ├── hints.c ├── hints.go ├── hints.h ├── hints_test.go ├── joystick.go ├── keyboard.go ├── keycode.go ├── loadso.go ├── locale.go ├── log.c ├── log.go ├── log.h ├── log_test.go ├── metal.go ├── misc.go ├── mouse.go ├── mutex.go ├── pixelformatconstant_string.go ├── pixels.go ├── pixels_test.go ├── power.go ├── power_test.go ├── rect.go ├── rect_test.go ├── render.go ├── render_test.go ├── rwops.go ├── scancode.go ├── sdl.go ├── sdl_cgo.go ├── sdl_cgo_static.go ├── sdl_test.go ├── sdl_wrapper.h ├── sensor.go ├── shape.go ├── struct_test.go ├── surface.go ├── surface_test.go ├── sysrender.go ├── system.c ├── system.go ├── system.h ├── system_android.go ├── system_linux.go ├── system_windows.go ├── syswm.go ├── syswm_cocoa.go ├── syswm_dfb.go ├── syswm_uikit.go ├── syswm_vivante.go ├── syswm_windows.go ├── syswm_x11.go ├── thread.go ├── timer.go ├── timer_test.go ├── touch.go ├── version.go ├── video.go ├── video_test.go └── vulkan.go └── ttf ├── sdl_ttf.go ├── sdl_ttf_cgo.go ├── sdl_ttf_cgo_static.go ├── sdl_ttf_test.go └── sdl_ttf_wrapper.h /.gitattributes: -------------------------------------------------------------------------------- 1 | *.bmp 2 | *.png 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: veandco 5 | open_collective: veandco 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Template for creating bug report issues on GitHub 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Go version: 11 | Go-SDL2 version: 12 | SDL2 version: 13 | OS: 14 | Architecture: 15 | -------------------------------------------------------------------------------- /.github/workflows/test-build.yml: -------------------------------------------------------------------------------- 1 | name: test-build 2 | on: [push, pull_request] 3 | jobs: 4 | test-build: 5 | runs-on: ubuntu-latest 6 | env: 7 | SDL_VERSION: 2.30.0 8 | IMG_VERSION: 2.8.0 9 | MIX_VERSION: 2.8.0 10 | TTF_VERSION: 2.22.0 11 | steps: 12 | - uses: actions/checkout@v3 13 | - uses: actions/setup-go@v3 14 | with: 15 | go-version: '1.13.15' 16 | - run: go version 17 | 18 | - name: Cache SDL2 19 | id: cache-sdl2 20 | uses: actions/cache@v3 21 | with: 22 | path: | 23 | SDL2-$SDL_VERSION 24 | IMG-$IMG_VERSION 25 | MIX-$MIX_VERSION 26 | TTF-$TTF_VERSION 27 | key: ${{ runner.os }}-sdl2-${{ hashFiles('**/*.h') }} 28 | restore-keys: | 29 | ${{ runner.os }}-sdl2- 30 | 31 | - name: Cache Go 32 | id: cache-go 33 | uses: actions/cache@v3 34 | with: 35 | path: | 36 | ~/.cache/go-build 37 | ~/go/pkg/mod 38 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} 39 | restore-keys: | 40 | ${{ runner.os }}-go- 41 | 42 | - name: set PKG_CONFIG_PATH environment variable 43 | run: | 44 | echo "PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV 45 | 46 | - name: Download, build, and install SDL2 packages 47 | run: | 48 | wget https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION.tar.gz 49 | tar xf SDL2-$SDL_VERSION.tar.gz 50 | cd SDL2-$SDL_VERSION 51 | ./configure --prefix=$HOME/.local 52 | make install 53 | cd .. 54 | wget https://github.com/libsdl-org/SDL_image/releases/download/release-$IMG_VERSION/SDL2_image-$IMG_VERSION.tar.gz 55 | tar xf SDL2_image-$IMG_VERSION.tar.gz 56 | cd SDL2_image-$IMG_VERSION 57 | ./configure --prefix=$HOME/.local 58 | make install 59 | cd .. 60 | wget https://github.com/libsdl-org/SDL_mixer/releases/download/release-$MIX_VERSION/SDL2_mixer-$MIX_VERSION.tar.gz 61 | tar xf SDL2_mixer-$MIX_VERSION.tar.gz 62 | cd SDL2_mixer-$MIX_VERSION 63 | ./configure --prefix=$HOME/.local 64 | make install 65 | cd .. 66 | wget https://github.com/libsdl-org/SDL_ttf/releases/download/release-$TTF_VERSION/SDL2_ttf-$TTF_VERSION.tar.gz 67 | tar xf SDL2_ttf-$TTF_VERSION.tar.gz 68 | cd SDL2_ttf-$TTF_VERSION 69 | ./configure --prefix=$HOME/.local 70 | make install 71 | cd .. 72 | 73 | - name: Test if Go-SDL2 works with the SDL2 packages 74 | run: | 75 | go build ./{sdl,img,mix,ttf} 76 | -------------------------------------------------------------------------------- /.github/workflows/test-old-versions-build.yml: -------------------------------------------------------------------------------- 1 | name: test-older-versions-build 2 | on: [push] 3 | jobs: 4 | test-older-versions-build: 5 | strategy: 6 | matrix: 7 | SDL_VERSION: [2.0.8, 2.0.9, 2.0.10, 2.0.12, 2.0.14, 2.0.16, 2.0.18, 2.0.20, 2.0.22] 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: actions/setup-go@v3 12 | with: 13 | go-version: '1.13.15' 14 | - run: go version 15 | 16 | - name: Cache Go 17 | id: cache-go 18 | uses: actions/cache@v3 19 | with: 20 | path: | 21 | ~/.cache/go-build 22 | ~/go/pkg/mod 23 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} 24 | restore-keys: | 25 | ${{ runner.os }}-go- 26 | 27 | - name: set PKG_CONFIG_PATH environment variable 28 | run: | 29 | echo "PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV 30 | 31 | - name: Download, build, and install SDL2 packages 32 | run: | 33 | wget https://www.libsdl.org/release/SDL2-${{ matrix.SDL_VERSION }}.tar.gz 34 | tar xf SDL2-${{ matrix.SDL_VERSION }}.tar.gz 35 | cd SDL2-${{ matrix.SDL_VERSION }} 36 | ./configure --prefix=$HOME/.local 37 | make install 38 | cd .. 39 | 40 | - name: Test if Go-SDL2 works with the SDL2 package 41 | run: | 42 | go build ./sdl 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *~ 3 | go-sdl2 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule ".go-sdl2-examples"] 2 | path = .go-sdl2-examples 3 | url = https://github.com/veandco/go-sdl2-examples 4 | -------------------------------------------------------------------------------- /BSDmakefile: -------------------------------------------------------------------------------- 1 | # Directories 2 | SRCDIR= ${.CURDIR} 3 | ALLDIRS!= find ${SRCDIR} -type d -not -path "./.git*" 4 | # Packages 5 | ROOTPKG= ${SRCDIR:S/${GOPATH}\/src\///} 6 | PACKAGES= sdl img mix ttf 7 | # Some cleanups 8 | CLEANUP= *.cache *.core *~ *.orig 9 | 10 | GO?= go 11 | 12 | all: clean packages 13 | 14 | clean: 15 | @echo "Cleaning up..." 16 | @for dir in ${ALLDIRS}; do \ 17 | cd $$dir && rm -f ${CLEANUP} && cd ${SRCDIR}; \ 18 | done 19 | 20 | packages: 21 | @for pkg in ${PACKAGES}; do \ 22 | echo "Building package ${ROOTPKG}/$$pkg..."; \ 23 | ${GO} build ${ROOTPKG}/$$pkg; \ 24 | done 25 | 26 | test: 27 | @for pkg in ${PACKAGES}; do \ 28 | echo "Testing ${ROOTPKG}/$$pkg..."; \ 29 | ${GO} test -v ${ROOTPKG}/$$pkg; \ 30 | done 31 | 32 | coverage: 33 | @for pkg in ${PACKAGES}; do \ 34 | echo "Coverage for ${ROOTPKG}/$$pkg..."; \ 35 | ${GO} test -cover ${ROOTPKG}/$$pkg; \ 36 | done 37 | 38 | bench: 39 | @for pkg in ${PACKAGES}; do \ 40 | echo "Benchmarking ${ROOTPKG}/$$pkg..."; \ 41 | ${GO} test -bench=. -cpu 1,2,3,4 ${ROOTPKG}/$$pkg; \ 42 | done 43 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. 4 | 5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of the level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion. 6 | 7 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. 8 | 9 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. 10 | 11 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. 12 | 13 | This Code of Conduct is taken from [Vue.js](https://vuejs.org) which is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guide 2 | 3 | ## Checklist 4 | These are loose checklist for contributors to follow when submitting patches. 5 | 6 | 1. Small commits 7 | 8 | You can contribute by a lot of ways from improving README, fixing typos, coding style, specific bugs, performance optimizations. However, it is preferred that you break up your commits to single logical change using `git add -p` so it is easier to review the patch. The larger the change, the more necessary it is for the commit to be broken up to tiny little pieces. If your change is large but consistent throughout (e.g. fixing a specific coding style that happens on almost every file), that can be counted as single logical change. 9 | 10 | 2. File and directory-based commit message 11 | 12 | We're starting to use commit messages that looks like this: `sdl: fixed some typos in render.go` or `examples/render_goroutine: fixed a dereferenced nil pointer` where it starts with folder hierarchy. It's not something strictly required but we would prefer it to be followed. 13 | 14 | 3. Compatibility with SDL 2.0.0 15 | 16 | The binding should compile with the oldest version SDL2. If there's a function added to the binding but is not supported by the older SDL2 version, a stub function must be provided. See `sdl/filesystem.go` for an example. 17 | 18 | ## How to contribute 19 | You can start by forking the repository, modify the fork, push the change to your fork, and then send pull requests. [Here](http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html) are some instructions on how you can work with your own fork. 20 | 21 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | Contributors 2 | ============ 3 | Here's the list of contributors with their respective Github URLs. 4 | * [Jacky Boen](https://github.com/jackyb) 5 | * [HardWareGuy](https://github.com/HardWareGuy) 6 | * [akovaski](https://github.com/akovaski) 7 | * [Jeromy Johnson](https://github.com/whyrusleeping) 8 | * [Cai Lei](https://github.com/ccll) 9 | * [Arne Döring](https://github.com/krux02) 10 | * [Marcus von Appen](https://github.com/marcusva) 11 | * [Tom Murray](https://github.com/TomMurray) 12 | * [Ian Davis](https://github.com/iand) 13 | * [hschendel](https://github.com/hschendel) 14 | * [Ingo Oeser](https://github.com/nightlyone) 15 | * [nlordell](https://github.com/nlordell) 16 | * [Ben Davies](https://github.com/JalfResi) 17 | * [Bastien Dejean](https://github.com/baskerville) 18 | * [Pirmin Tapken](https://github.com/PirminTapken) 19 | * [Robert Lillack](https://github.com/roblillack) 20 | * [Marcell Jusztin](https://github.com/morcmarc) 21 | * [Stan Schwertly](https://github.com/Stantheman) 22 | * [Michael Vetter](https://github.com/jubalh) 23 | * [Tom Fogal](https://github.com/tfogal) 24 | * [Philipp Meinen](https://github.com/PhiCode) 25 | * [Thomas McGrew](https://github.com/mcgrew) 26 | * [Geoff Catlin](https://github.com/gcatlin) 27 | * [Schobers](https://github.com/Schobers) 28 | * [Jan Tuitman](https://github.com/jantuitman) 29 | * [Nick Powell](https://github.com/THUNDERGROOVE) 30 | * [Steven R. Wiley](https://github.com/srwiley) 31 | * [Franco Lazzarino](https://github.com/flazz) 32 | * [Jason Alan Palmer](https://github.com/jalan) 33 | * [Seuk Won Kang](https://github.com/kasworld) 34 | * [Brandon Mulcahy](https://github.com/jangler) 35 | * [Tim Anema](https://github.com/tanema) 36 | * [Tyler Compton](https://github.com/velovix) 37 | * [Nicolas Hess](https://github.com/n0dev) 38 | * [Stephen Noonan](https://github.com/tycho) 39 | * [Guilherme Freitas Nemeth](https://github.com/glhrmfrts) 40 | * [Charney Kaye](https://github.com/charneykaye) 41 | * [Lars Scheme](https://github.com/gonutz) 42 | * [Emil Laine](https://github.com/emlai) 43 | * [Sergey Parshukov](https://github.com/jBugman) 44 | * [Casey DeLorme](https://github.com/cdelorme) 45 | * [Andreas T. Jonsson](https://github.com/andreas-jonsson) 46 | * [Milan Nikolic](https://github.com/gen2brain) 47 | * [Mike Gerow](https://github.com/gerow) 48 | * [Lilis Iskandar](https://github.com/veeableful) 49 | * [tfriedel6](https://github.com/tfriedel6) 50 | * [Eric Bronner](https://github.com/MoonWatcher582) 51 | * [Julien Castelain](https://github.com/julien) 52 | * [Robert Wallis](https://github.com/robert-wallis) 53 | * [Chae-Young Song](https://github.com/chaeyoungsong) 54 | * [Robert Wallis](https://github.com/robert-wallis) 55 | * [Lennart Buhl](https://github.com/r41d) 56 | * [Giovanni Bajo](https://github.com/rasky) 57 | * [Laurent Vaucher](https://github.com/slowfrog) 58 | * [Mike](https://github.com/barbeque) 59 | * [Tomas Virgl](https://github.com/tvi) 60 | * [Aye Aye Maung](https://github.com/ZeroXLR) 61 | * [Anton Malashin](https://github.com/malashin) 62 | * [John Perkins](https://github.com/mpath) 63 | * [jclc](https://github.com/jclc) 64 | * [flga](https://github.com/flga) 65 | 66 | _if anyone is missing, let me know!.. or you can add yourself in :)_ 67 | -------------------------------------------------------------------------------- /GNUmakefile: -------------------------------------------------------------------------------- 1 | # Directories 2 | SRCDIR= ${CURDIR} 3 | ALLDIRS!= find ${SRCDIR} -type d -not -path "./.git*" 4 | # Packages 5 | ROOTPKG= $(subst ${GOPATH}/src/,,${SRCDIR}) 6 | PACKAGES= sdl img mix ttf gfx 7 | # Some cleanups 8 | CLEANUP= *.cache *.core *~ *.orig 9 | 10 | GO?= go 11 | 12 | all: clean packages 13 | 14 | clean: 15 | @echo "Cleaning up..." 16 | @for dir in ${ALLDIRS}; do \ 17 | cd $$dir && rm -f ${CLEANUP} && cd ${SRCDIR}; \ 18 | done 19 | 20 | packages: 21 | @for pkg in ${PACKAGES}; do \ 22 | echo "Building package ${ROOTPKG}/$$pkg..."; \ 23 | ${GO} build ${ROOTPKG}/$$pkg; \ 24 | done 25 | 26 | test: 27 | @for pkg in ${PACKAGES}; do \ 28 | echo "Testing ${ROOTPKG}/$$pkg..."; \ 29 | ${GO} test -v ${ROOTPKG}/$$pkg; \ 30 | done 31 | 32 | coverage: 33 | @for pkg in ${PACKAGES}; do \ 34 | echo "Coverage for ${ROOTPKG}/$$pkg..."; \ 35 | ${GO} test -cover ${ROOTPKG}/$$pkg; \ 36 | done 37 | 38 | bench: 39 | @for pkg in ${PACKAGES}; do \ 40 | echo "Benchmarking ${ROOTPKG}/$$pkg..."; \ 41 | ${GO} test -bench=. -cpu 1,2,3,4 ${ROOTPKG}/$$pkg; \ 42 | done 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Go-SDL2 Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of Go-SDL2 nor the names of its contributors may be 13 | used to endorse or promote products derived from this software without specific 14 | prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 23 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /_libs/dummy.go: -------------------------------------------------------------------------------- 1 | package dummy 2 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL2_framerate.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SDL2_framerate.h: framerate manager 4 | 5 | Copyright (C) 2012-2014 Andreas Schiffler 6 | 7 | This software is provided 'as-is', without any express or implied 8 | warranty. In no event will the authors be held liable for any damages 9 | arising from the use of this software. 10 | 11 | Permission is granted to anyone to use this software for any purpose, 12 | including commercial applications, and to alter it and redistribute it 13 | freely, subject to the following restrictions: 14 | 15 | 1. The origin of this software must not be misrepresented; you must not 16 | claim that you wrote the original software. If you use this software 17 | in a product, an acknowledgment in the product documentation would be 18 | appreciated but is not required. 19 | 20 | 2. Altered source versions must be plainly marked as such, and must not be 21 | misrepresented as being the original software. 22 | 23 | 3. This notice may not be removed or altered from any source 24 | distribution. 25 | 26 | Andreas Schiffler -- aschiffler at ferzkopp dot net 27 | 28 | */ 29 | 30 | #ifndef _SDL2_framerate_h 31 | #define _SDL2_framerate_h 32 | 33 | /* Set up for C function definitions, even when using C++ */ 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* --- */ 39 | 40 | #include "SDL.h" 41 | 42 | /* --------- Definitions */ 43 | 44 | /*! 45 | \brief Highest possible rate supported by framerate controller in Hz (1/s). 46 | */ 47 | #define FPS_UPPER_LIMIT 200 48 | 49 | /*! 50 | \brief Lowest possible rate supported by framerate controller in Hz (1/s). 51 | */ 52 | #define FPS_LOWER_LIMIT 1 53 | 54 | /*! 55 | \brief Default rate of framerate controller in Hz (1/s). 56 | */ 57 | #define FPS_DEFAULT 30 58 | 59 | /*! 60 | \brief Structure holding the state and timing information of the framerate controller. 61 | */ 62 | typedef struct { 63 | Uint32 framecount; 64 | float rateticks; 65 | Uint32 baseticks; 66 | Uint32 lastticks; 67 | Uint32 rate; 68 | } FPSmanager; 69 | 70 | /* ---- Function Prototypes */ 71 | 72 | #ifdef _MSC_VER 73 | # if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT) 74 | # define SDL2_FRAMERATE_SCOPE __declspec(dllexport) 75 | # else 76 | # ifdef LIBSDL2_GFX_DLL_IMPORT 77 | # define SDL2_FRAMERATE_SCOPE __declspec(dllimport) 78 | # endif 79 | # endif 80 | #endif 81 | #ifndef SDL2_FRAMERATE_SCOPE 82 | # define SDL2_FRAMERATE_SCOPE extern 83 | #endif 84 | 85 | /* Functions return 0 or value for sucess and -1 for error */ 86 | 87 | SDL2_FRAMERATE_SCOPE void SDL_initFramerate(FPSmanager * manager); 88 | SDL2_FRAMERATE_SCOPE int SDL_setFramerate(FPSmanager * manager, Uint32 rate); 89 | SDL2_FRAMERATE_SCOPE int SDL_getFramerate(FPSmanager * manager); 90 | SDL2_FRAMERATE_SCOPE int SDL_getFramecount(FPSmanager * manager); 91 | SDL2_FRAMERATE_SCOPE Uint32 SDL_framerateDelay(FPSmanager * manager); 92 | 93 | /* --- */ 94 | 95 | /* Ends C function definitions when using C++ */ 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* _SDL2_framerate_h */ 101 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL2_gfxPrimitives_font.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/include/SDL2/SDL2_gfxPrimitives_font.h -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL2_rotozoom.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | SDL2_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces 4 | 5 | Copyright (C) 2012-2014 Andreas Schiffler 6 | 7 | This software is provided 'as-is', without any express or implied 8 | warranty. In no event will the authors be held liable for any damages 9 | arising from the use of this software. 10 | 11 | Permission is granted to anyone to use this software for any purpose, 12 | including commercial applications, and to alter it and redistribute it 13 | freely, subject to the following restrictions: 14 | 15 | 1. The origin of this software must not be misrepresented; you must not 16 | claim that you wrote the original software. If you use this software 17 | in a product, an acknowledgment in the product documentation would be 18 | appreciated but is not required. 19 | 20 | 2. Altered source versions must be plainly marked as such, and must not be 21 | misrepresented as being the original software. 22 | 23 | 3. This notice may not be removed or altered from any source 24 | distribution. 25 | 26 | Andreas Schiffler -- aschiffler at ferzkopp dot net 27 | 28 | */ 29 | 30 | #ifndef _SDL2_rotozoom_h 31 | #define _SDL2_rotozoom_h 32 | 33 | #include 34 | 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | #ifndef M_PI 41 | #define M_PI 3.1415926535897932384626433832795 42 | #endif 43 | 44 | #include "SDL.h" 45 | 46 | /* ---- Defines */ 47 | 48 | /*! 49 | \brief Disable anti-aliasing (no smoothing). 50 | */ 51 | #define SMOOTHING_OFF 0 52 | 53 | /*! 54 | \brief Enable anti-aliasing (smoothing). 55 | */ 56 | #define SMOOTHING_ON 1 57 | 58 | /* ---- Function Prototypes */ 59 | 60 | #ifdef _MSC_VER 61 | # if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT) 62 | # define SDL2_ROTOZOOM_SCOPE __declspec(dllexport) 63 | # else 64 | # ifdef LIBSDL2_GFX_DLL_IMPORT 65 | # define SDL2_ROTOZOOM_SCOPE __declspec(dllimport) 66 | # endif 67 | # endif 68 | #endif 69 | #ifndef SDL2_ROTOZOOM_SCOPE 70 | # define SDL2_ROTOZOOM_SCOPE extern 71 | #endif 72 | 73 | /* 74 | 75 | Rotozoom functions 76 | 77 | */ 78 | 79 | SDL2_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth); 80 | 81 | SDL2_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurfaceXY 82 | (SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth); 83 | 84 | 85 | SDL2_ROTOZOOM_SCOPE void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth, 86 | int *dstheight); 87 | 88 | SDL2_ROTOZOOM_SCOPE void rotozoomSurfaceSizeXY 89 | (int width, int height, double angle, double zoomx, double zoomy, 90 | int *dstwidth, int *dstheight); 91 | 92 | /* 93 | 94 | Zooming functions 95 | 96 | */ 97 | 98 | SDL2_ROTOZOOM_SCOPE SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth); 99 | 100 | SDL2_ROTOZOOM_SCOPE void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight); 101 | 102 | /* 103 | 104 | Shrinking functions 105 | 106 | */ 107 | 108 | SDL2_ROTOZOOM_SCOPE SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory); 109 | 110 | /* 111 | 112 | Specialized rotation functions 113 | 114 | */ 115 | 116 | SDL2_ROTOZOOM_SCOPE SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns); 117 | 118 | /* Ends C function definitions when using C++ */ 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | 123 | #endif /* _SDL2_rotozoom_h */ 124 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_bits.h 24 | * 25 | * Functions for fiddling with bits and bitmasks. 26 | */ 27 | 28 | #ifndef SDL_bits_h_ 29 | #define SDL_bits_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \file SDL_bits.h 41 | */ 42 | 43 | /** 44 | * Get the index of the most significant bit. Result is undefined when called 45 | * with 0. This operation can also be stated as "count leading zeroes" and 46 | * "log base 2". 47 | * 48 | * \return the index of the most significant bit, or -1 if the value is 0. 49 | */ 50 | #if defined(__WATCOMC__) && defined(__386__) 51 | extern __inline int _SDL_bsr_watcom(Uint32); 52 | #pragma aux _SDL_bsr_watcom = \ 53 | "bsr eax, eax" \ 54 | parm [eax] nomemory \ 55 | value [eax] \ 56 | modify exact [eax] nomemory; 57 | #endif 58 | 59 | SDL_FORCE_INLINE int 60 | SDL_MostSignificantBitIndex32(Uint32 x) 61 | { 62 | #if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) 63 | /* Count Leading Zeroes builtin in GCC. 64 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html 65 | */ 66 | if (x == 0) { 67 | return -1; 68 | } 69 | return 31 - __builtin_clz(x); 70 | #elif defined(__WATCOMC__) && defined(__386__) 71 | if (x == 0) { 72 | return -1; 73 | } 74 | return _SDL_bsr_watcom(x); 75 | #elif defined(_MSC_VER) 76 | unsigned long index; 77 | if (_BitScanReverse(&index, x)) { 78 | return index; 79 | } 80 | return -1; 81 | #else 82 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson 83 | * , released in the public domain. 84 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog 85 | */ 86 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 87 | const int S[] = {1, 2, 4, 8, 16}; 88 | 89 | int msbIndex = 0; 90 | int i; 91 | 92 | if (x == 0) { 93 | return -1; 94 | } 95 | 96 | for (i = 4; i >= 0; i--) 97 | { 98 | if (x & b[i]) 99 | { 100 | x >>= S[i]; 101 | msbIndex |= S[i]; 102 | } 103 | } 104 | 105 | return msbIndex; 106 | #endif 107 | } 108 | 109 | SDL_FORCE_INLINE SDL_bool 110 | SDL_HasExactlyOneBitSet32(Uint32 x) 111 | { 112 | if (x && !(x & (x - 1))) { 113 | return SDL_TRUE; 114 | } 115 | return SDL_FALSE; 116 | } 117 | 118 | /* Ends C function definitions when using C++ */ 119 | #ifdef __cplusplus 120 | } 121 | #endif 122 | #include "close_code.h" 123 | 124 | #endif /* SDL_bits_h_ */ 125 | 126 | /* vi: set ts=4 sw=4 expandtab: */ 127 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_clipboard.h 24 | * 25 | * Include file for SDL clipboard handling 26 | */ 27 | 28 | #ifndef SDL_clipboard_h_ 29 | #define SDL_clipboard_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | /** 42 | * Put UTF-8 text into the clipboard. 43 | * 44 | * \param text the text to store in the clipboard 45 | * \returns 0 on success or a negative error code on failure; call 46 | * SDL_GetError() for more information. 47 | * 48 | * \since This function is available since SDL 2.0.0. 49 | * 50 | * \sa SDL_GetClipboardText 51 | * \sa SDL_HasClipboardText 52 | */ 53 | extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); 54 | 55 | /** 56 | * Get UTF-8 text from the clipboard, which must be freed with SDL_free(). 57 | * 58 | * This functions returns empty string if there was not enough memory left for 59 | * a copy of the clipboard's content. 60 | * 61 | * \returns the clipboard text on success or an empty string on failure; call 62 | * SDL_GetError() for more information. Caller must call SDL_free() 63 | * on the returned pointer when done with it (even if there was an 64 | * error). 65 | * 66 | * \since This function is available since SDL 2.0.0. 67 | * 68 | * \sa SDL_HasClipboardText 69 | * \sa SDL_SetClipboardText 70 | */ 71 | extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); 72 | 73 | /** 74 | * Query whether the clipboard exists and contains a non-empty text string. 75 | * 76 | * \returns SDL_TRUE if the clipboard has text, or SDL_FALSE if it does not. 77 | * 78 | * \since This function is available since SDL 2.0.0. 79 | * 80 | * \sa SDL_GetClipboardText 81 | * \sa SDL_SetClipboardText 82 | */ 83 | extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); 84 | 85 | 86 | /* Ends C function definitions when using C++ */ 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | #include "close_code.h" 91 | 92 | #endif /* SDL_clipboard_h_ */ 93 | 94 | /* vi: set ts=4 sw=4 expandtab: */ 95 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_h_ 23 | #define SDL_config_h_ 24 | 25 | #include "SDL_platform.h" 26 | 27 | /** 28 | * \file SDL_config.h 29 | */ 30 | 31 | /* Add any platform that doesn't build using the configure system. */ 32 | #if defined(__WIN32__) 33 | #include "SDL_config_windows.h" 34 | #elif defined(__WINRT__) 35 | #include "SDL_config_winrt.h" 36 | #elif defined(__MACOSX__) 37 | #include "SDL_config_macosx.h" 38 | #elif defined(__IPHONEOS__) 39 | #include "SDL_config_iphoneos.h" 40 | #elif defined(__ANDROID__) 41 | #include "SDL_config_android.h" 42 | #elif defined(__PSP__) 43 | #include "SDL_config_psp.h" 44 | #elif defined(__OS2__) 45 | #include "SDL_config_os2.h" 46 | #elif defined(__EMSCRIPTEN__) 47 | #include "SDL_config_emscripten.h" 48 | #else 49 | /* This is a minimal configuration just to get SDL running on new platforms. */ 50 | #include "SDL_config_minimal.h" 51 | #endif /* platform config */ 52 | 53 | #ifdef USING_GENERATED_CONFIG_H 54 | #error Wrong SDL_config.h, check your include path? 55 | #endif 56 | 57 | #endif /* SDL_config_h_ */ 58 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_config_minimal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_config_minimal_h_ 23 | #define SDL_config_minimal_h_ 24 | #define SDL_config_h_ 25 | 26 | #include "SDL_platform.h" 27 | 28 | /** 29 | * \file SDL_config_minimal.h 30 | * 31 | * This is the minimal configuration that can be used to build SDL. 32 | */ 33 | 34 | #define HAVE_STDARG_H 1 35 | #define HAVE_STDDEF_H 1 36 | 37 | /* Most everything except Visual Studio 2008 and earlier has stdint.h now */ 38 | #if defined(_MSC_VER) && (_MSC_VER < 1600) 39 | /* Here are some reasonable defaults */ 40 | typedef unsigned int size_t; 41 | typedef signed char int8_t; 42 | typedef unsigned char uint8_t; 43 | typedef signed short int16_t; 44 | typedef unsigned short uint16_t; 45 | typedef signed int int32_t; 46 | typedef unsigned int uint32_t; 47 | typedef signed long long int64_t; 48 | typedef unsigned long long uint64_t; 49 | typedef unsigned long uintptr_t; 50 | #else 51 | #define HAVE_STDINT_H 1 52 | #endif /* Visual Studio 2008 */ 53 | 54 | #ifdef __GNUC__ 55 | #define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 56 | #endif 57 | 58 | /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ 59 | #define SDL_AUDIO_DRIVER_DUMMY 1 60 | 61 | /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ 62 | #define SDL_JOYSTICK_DISABLED 1 63 | 64 | /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ 65 | #define SDL_HAPTIC_DISABLED 1 66 | 67 | /* Enable the stub HIDAPI */ 68 | #define SDL_HIDAPI_DISABLED 1 69 | 70 | /* Enable the stub sensor driver (src/sensor/dummy/\*.c) */ 71 | #define SDL_SENSOR_DISABLED 1 72 | 73 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 74 | #define SDL_LOADSO_DISABLED 1 75 | 76 | /* Enable the stub thread support (src/thread/generic/\*.c) */ 77 | #define SDL_THREADS_DISABLED 1 78 | 79 | /* Enable the stub timer support (src/timer/dummy/\*.c) */ 80 | #define SDL_TIMERS_DISABLED 1 81 | 82 | /* Enable the dummy video driver (src/video/dummy/\*.c) */ 83 | #define SDL_VIDEO_DRIVER_DUMMY 1 84 | 85 | /* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ 86 | #define SDL_FILESYSTEM_DUMMY 1 87 | 88 | #endif /* SDL_config_minimal_h_ */ 89 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_copying.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_gesture.h 24 | * 25 | * Include file for SDL gesture event handling. 26 | */ 27 | 28 | #ifndef SDL_gesture_h_ 29 | #define SDL_gesture_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "SDL_touch.h" 36 | 37 | 38 | #include "begin_code.h" 39 | /* Set up for C function definitions, even when using C++ */ 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef Sint64 SDL_GestureID; 45 | 46 | /* Function prototypes */ 47 | 48 | /** 49 | * Begin recording a gesture on a specified touch device or all touch devices. 50 | * 51 | * If the parameter `touchId` is -1 (i.e., all devices), this function will 52 | * always return 1, regardless of whether there actually are any devices. 53 | * 54 | * \param touchId the touch device id, or -1 for all touch devices 55 | * \returns 1 on success or 0 if the specified device could not be found. 56 | * 57 | * \since This function is available since SDL 2.0.0. 58 | * 59 | * \sa SDL_GetTouchDevice 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); 62 | 63 | 64 | /** 65 | * Save all currently loaded Dollar Gesture templates. 66 | * 67 | * \param dst a SDL_RWops to save to 68 | * \returns the number of saved templates on success or 0 on failure; call 69 | * SDL_GetError() for more information. 70 | * 71 | * \since This function is available since SDL 2.0.0. 72 | * 73 | * \sa SDL_LoadDollarTemplates 74 | * \sa SDL_SaveDollarTemplate 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); 77 | 78 | /** 79 | * Save a currently loaded Dollar Gesture template. 80 | * 81 | * \param gestureId a gesture id 82 | * \param dst a SDL_RWops to save to 83 | * \returns 1 on success or 0 on failure; call SDL_GetError() for more 84 | * information. 85 | * 86 | * \since This function is available since SDL 2.0.0. 87 | * 88 | * \sa SDL_LoadDollarTemplates 89 | * \sa SDL_SaveAllDollarTemplates 90 | */ 91 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); 92 | 93 | 94 | /** 95 | * Load Dollar Gesture templates from a file. 96 | * 97 | * \param touchId a touch id 98 | * \param src a SDL_RWops to load from 99 | * \returns the number of loaded templates on success or a negative error code 100 | * (or 0) on failure; call SDL_GetError() for more information. 101 | * 102 | * \since This function is available since SDL 2.0.0. 103 | * 104 | * \sa SDL_SaveAllDollarTemplates 105 | * \sa SDL_SaveDollarTemplate 106 | */ 107 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); 108 | 109 | /* Ends C function definitions when using C++ */ 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | #include "close_code.h" 114 | 115 | #endif /* SDL_gesture_h_ */ 116 | 117 | /* vi: set ts=4 sw=4 expandtab: */ 118 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_metal.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_metal.h 24 | * 25 | * Header file for functions to creating Metal layers and views on SDL windows. 26 | */ 27 | 28 | #ifndef SDL_metal_h_ 29 | #define SDL_metal_h_ 30 | 31 | #include "SDL_video.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * \brief A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). 41 | * 42 | * \note This can be cast directly to an NSView or UIView. 43 | */ 44 | typedef void *SDL_MetalView; 45 | 46 | /** 47 | * \name Metal support functions 48 | */ 49 | /* @{ */ 50 | 51 | /** 52 | * Create a CAMetalLayer-backed NSView/UIView and attach it to the specified 53 | * window. 54 | * 55 | * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on 56 | * its own. It is up to user code to do that. 57 | * 58 | * The returned handle can be casted directly to a NSView or UIView. To access 59 | * the backing CAMetalLayer, call SDL_Metal_GetLayer(). 60 | * 61 | * \since This function is available since SDL 2.0.12. 62 | * 63 | * \sa SDL_Metal_DestroyView 64 | * \sa SDL_Metal_GetLayer 65 | */ 66 | extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window); 67 | 68 | /** 69 | * Destroy an existing SDL_MetalView object. 70 | * 71 | * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was 72 | * called after SDL_CreateWindow. 73 | * 74 | * \since This function is available since SDL 2.0.12. 75 | * 76 | * \sa SDL_Metal_CreateView 77 | */ 78 | extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view); 79 | 80 | /** 81 | * Get a pointer to the backing CAMetalLayer for the given view. 82 | * 83 | * \since This function is available since SDL 2.0.14. 84 | * 85 | * \sa SDL_MetalCreateView 86 | */ 87 | extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view); 88 | 89 | /** 90 | * Get the size of a window's underlying drawable in pixels (for use with 91 | * setting viewport, scissor & etc). 92 | * 93 | * \param window SDL_Window from which the drawable size should be queried 94 | * \param w Pointer to variable for storing the width in pixels, may be NULL 95 | * 96 | * \since This function is available since SDL 2.0.14. 97 | * 98 | * \sa SDL_GetWindowSize 99 | * \sa SDL_CreateWindow 100 | */ 101 | extern DECLSPEC void SDLCALL SDL_Metal_GetDrawableSize(SDL_Window* window, int *w, 102 | int *h); 103 | 104 | /* @} *//* Metal support functions */ 105 | 106 | /* Ends C function definitions when using C++ */ 107 | #ifdef __cplusplus 108 | } 109 | #endif 110 | #include "close_code.h" 111 | 112 | #endif /* SDL_metal_h_ */ 113 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_misc.h 24 | * 25 | * \brief Include file for SDL API functions that don't fit elsewhere. 26 | */ 27 | 28 | #ifndef SDL_misc_h_ 29 | #define SDL_misc_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * Open a URL/URI in the browser or other appropriate external application. 42 | * 43 | * Open a URL in a separate, system-provided application. How this works will 44 | * vary wildly depending on the platform. This will likely launch what makes 45 | * sense to handle a specific URL's protocol (a web browser for `http://`, 46 | * etc), but it might also be able to launch file managers for directories and 47 | * other things. 48 | * 49 | * What happens when you open a URL varies wildly as well: your game window 50 | * may lose focus (and may or may not lose focus if your game was fullscreen 51 | * or grabbing input at the time). On mobile devices, your app will likely 52 | * move to the background or your process might be paused. Any given platform 53 | * may or may not handle a given URL. 54 | * 55 | * If this is unimplemented (or simply unavailable) for a platform, this will 56 | * fail with an error. A successful result does not mean the URL loaded, just 57 | * that we launched _something_ to handle it (or at least believe we did). 58 | * 59 | * All this to say: this function can be useful, but you should definitely 60 | * test it on every platform you target. 61 | * 62 | * \param url A valid URL/URI to open. Use `file:///full/path/to/file` for 63 | * local files, if supported. 64 | * \returns 0 on success, or -1 on error; call SDL_GetError() for more 65 | * information. 66 | * 67 | * \since This function is available since SDL 2.0.14. 68 | */ 69 | extern DECLSPEC int SDLCALL SDL_OpenURL(const char *url); 70 | 71 | /* Ends C function definitions when using C++ */ 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | #include "close_code.h" 76 | 77 | #endif /* SDL_misc_h_ */ 78 | 79 | /* vi: set ts=4 sw=4 expandtab: */ 80 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDLname_h_ 23 | #define SDLname_h_ 24 | 25 | #if defined(__STDC__) || defined(__cplusplus) 26 | #define NeedFunctionPrototypes 1 27 | #endif 28 | 29 | #define SDL_NAME(X) SDL_##X 30 | 31 | #endif /* SDLname_h_ */ 32 | 33 | /* vi: set ts=4 sw=4 expandtab: */ 34 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers. 26 | */ 27 | #include "SDL_config.h" 28 | 29 | #ifdef __IPHONEOS__ 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #endif 36 | 37 | #ifndef APIENTRY 38 | #define APIENTRY 39 | #endif 40 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_opengles2.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. 26 | */ 27 | #include "SDL_config.h" 28 | 29 | #if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) 30 | 31 | #ifdef __IPHONEOS__ 32 | #include 33 | #include 34 | #else 35 | #include 36 | #include 37 | #include 38 | #endif 39 | 40 | #else /* _MSC_VER */ 41 | 42 | /* OpenGL ES2 headers for Visual Studio */ 43 | #include "SDL_opengles2_khrplatform.h" 44 | #include "SDL_opengles2_gl2platform.h" 45 | #include "SDL_opengles2_gl2.h" 46 | #include "SDL_opengles2_gl2ext.h" 47 | 48 | #endif /* _MSC_VER */ 49 | 50 | #ifndef APIENTRY 51 | #define APIENTRY GL_APIENTRY 52 | #endif 53 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_opengles2_gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ 5 | 6 | /* 7 | * This document is licensed under the SGI Free Software B License Version 8 | * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . 9 | */ 10 | 11 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 12 | * 13 | * Adopters may modify khrplatform.h and this file to suit their platform. 14 | * You are encouraged to submit all modifications to the Khronos group so that 15 | * they can be included in future versions of this file. Please submit changes 16 | * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) 17 | * by filing a bug against product "OpenGL-ES" component "Registry". 18 | */ 19 | 20 | /*#include */ 21 | 22 | #ifndef GL_APICALL 23 | #define GL_APICALL KHRONOS_APICALL 24 | #endif 25 | 26 | #ifndef GL_APIENTRY 27 | #define GL_APIENTRY KHRONOS_APIENTRY 28 | #endif 29 | 30 | #endif /* __gl2platform_h_ */ 31 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #ifndef SDL_power_h_ 23 | #define SDL_power_h_ 24 | 25 | /** 26 | * \file SDL_power.h 27 | * 28 | * Header for the SDL power management routines. 29 | */ 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * The basic state for the system's power supply. 41 | */ 42 | typedef enum 43 | { 44 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ 45 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ 46 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ 47 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ 48 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ 49 | } SDL_PowerState; 50 | 51 | 52 | /** 53 | * Get the current power supply details. 54 | * 55 | * You should never take a battery status as absolute truth. Batteries 56 | * (especially failing batteries) are delicate hardware, and the values 57 | * reported here are best estimates based on what that hardware reports. It's 58 | * not uncommon for older batteries to lose stored power much faster than it 59 | * reports, or completely drain when reporting it has 20 percent left, etc. 60 | * 61 | * Battery status can change at any time; if you are concerned with power 62 | * state, you should call this function frequently, and perhaps ignore changes 63 | * until they seem to be stable for a few seconds. 64 | * 65 | * It's possible a platform can only report battery percentage or time left 66 | * but not both. 67 | * 68 | * \param secs seconds of battery life left, you can pass a NULL here if you 69 | * don't care, will return -1 if we can't determine a value, or 70 | * we're not running on a battery 71 | * \param pct percentage of battery life left, between 0 and 100, you can pass 72 | * a NULL here if you don't care, will return -1 if we can't 73 | * determine a value, or we're not running on a battery 74 | * \returns an SDL_PowerState enum representing the current battery state. 75 | * 76 | * \since This function is available since SDL 2.0.0. 77 | */ 78 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); 79 | 80 | /* Ends C function definitions when using C++ */ 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | #include "close_code.h" 85 | 86 | #endif /* SDL_power_h_ */ 87 | 88 | /* vi: set ts=4 sw=4 expandtab: */ 89 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_quit.h 24 | * 25 | * Include file for SDL quit event handling. 26 | */ 27 | 28 | #ifndef SDL_quit_h_ 29 | #define SDL_quit_h_ 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | /** 35 | * \file SDL_quit.h 36 | * 37 | * An ::SDL_QUIT event is generated when the user tries to close the application 38 | * window. If it is ignored or filtered out, the window will remain open. 39 | * If it is not ignored or filtered, it is queued normally and the window 40 | * is allowed to close. When the window is closed, screen updates will 41 | * complete, but have no effect. 42 | * 43 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 44 | * and SIGTERM (system termination request), if handlers do not already 45 | * exist, that generate ::SDL_QUIT events as well. There is no way 46 | * to determine the cause of an ::SDL_QUIT event, but setting a signal 47 | * handler in your application will override the default generation of 48 | * quit events for that signal. 49 | * 50 | * \sa SDL_Quit() 51 | */ 52 | 53 | /* There are no functions directly affecting the quit event */ 54 | 55 | #define SDL_QuitRequested() \ 56 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) 57 | 58 | #endif /* SDL_quit_h_ */ 59 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_revision.h: -------------------------------------------------------------------------------- 1 | #define SDL_REVISION "https://github.com/libsdl-org/SDL.git@b424665e0899769b200231ba943353a5fee1b6b6" 2 | #define SDL_REVISION_NUMBER 0 3 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_h_ 31 | #define SDL_test_h_ 32 | 33 | #include "SDL.h" 34 | #include "SDL_test_assert.h" 35 | #include "SDL_test_common.h" 36 | #include "SDL_test_compare.h" 37 | #include "SDL_test_crc32.h" 38 | #include "SDL_test_font.h" 39 | #include "SDL_test_fuzzer.h" 40 | #include "SDL_test_harness.h" 41 | #include "SDL_test_images.h" 42 | #include "SDL_test_log.h" 43 | #include "SDL_test_md5.h" 44 | #include "SDL_test_memory.h" 45 | #include "SDL_test_random.h" 46 | 47 | #include "begin_code.h" 48 | /* Set up for C function definitions, even when using C++ */ 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /* Global definitions */ 54 | 55 | /* 56 | * Note: Maximum size of SDLTest log message is less than SDL's limit 57 | * to ensure we can fit additional information such as the timestamp. 58 | */ 59 | #define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* SDL_test_h_ */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_test_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_assert.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Assert API for test code and test cases 33 | * 34 | */ 35 | 36 | #ifndef SDL_test_assert_h_ 37 | #define SDL_test_assert_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Fails the assert. 47 | */ 48 | #define ASSERT_FAIL 0 49 | 50 | /** 51 | * \brief Passes the assert. 52 | */ 53 | #define ASSERT_PASS 1 54 | 55 | /** 56 | * \brief Assert that logs and break execution flow on failures. 57 | * 58 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 59 | * \param assertDescription Message to log with the assert describing it. 60 | */ 61 | void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 62 | 63 | /** 64 | * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. 65 | * 66 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 67 | * \param assertDescription Message to log with the assert describing it. 68 | * 69 | * \returns the assertCondition so it can be used to externally to break execution flow if desired. 70 | */ 71 | int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 72 | 73 | /** 74 | * \brief Explicitly pass without checking an assertion condition. Updates assertion counter. 75 | * 76 | * \param assertDescription Message to log with the assert describing it. 77 | */ 78 | void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); 79 | 80 | /** 81 | * \brief Resets the assert summary counters to zero. 82 | */ 83 | void SDLTest_ResetAssertSummary(void); 84 | 85 | /** 86 | * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. 87 | */ 88 | void SDLTest_LogAssertSummary(void); 89 | 90 | 91 | /** 92 | * \brief Converts the current assert summary state to a test result. 93 | * 94 | * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT 95 | */ 96 | int SDLTest_AssertSummaryToTestResult(void); 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | #include "close_code.h" 102 | 103 | #endif /* SDL_test_assert_h_ */ 104 | 105 | /* vi: set ts=4 sw=4 expandtab: */ 106 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_test_compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_compare.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines comparison functions (i.e. for surfaces). 33 | 34 | */ 35 | 36 | #ifndef SDL_test_compare_h_ 37 | #define SDL_test_compare_h_ 38 | 39 | #include "SDL.h" 40 | 41 | #include "SDL_test_images.h" 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * \brief Compares a surface and with reference image data for equality 51 | * 52 | * \param surface Surface used in comparison 53 | * \param referenceSurface Test Surface used in comparison 54 | * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. 55 | * 56 | * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. 57 | */ 58 | int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); 59 | 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* SDL_test_compare_h_ */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_test_font.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_font.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_font_h_ 31 | #define SDL_test_font_h_ 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /* Function prototypes */ 40 | 41 | #define FONT_CHARACTER_SIZE 8 42 | 43 | /** 44 | * \brief Draw a string in the currently set font. 45 | * 46 | * \param renderer The renderer to draw on. 47 | * \param x The X coordinate of the upper left corner of the character. 48 | * \param y The Y coordinate of the upper left corner of the character. 49 | * \param c The character to draw. 50 | * 51 | * \returns 0 on success, -1 on failure. 52 | */ 53 | int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c); 54 | 55 | /** 56 | * \brief Draw a string in the currently set font. 57 | * 58 | * \param renderer The renderer to draw on. 59 | * \param x The X coordinate of the upper left corner of the string. 60 | * \param y The Y coordinate of the upper left corner of the string. 61 | * \param s The string to draw. 62 | * 63 | * \returns 0 on success, -1 on failure. 64 | */ 65 | int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s); 66 | 67 | 68 | /** 69 | * \brief Cleanup textures used by font drawing functions. 70 | */ 71 | void SDLTest_CleanupTextDrawing(void); 72 | 73 | /* Ends C function definitions when using C++ */ 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | #include "close_code.h" 78 | 79 | #endif /* SDL_test_font_h_ */ 80 | 81 | /* vi: set ts=4 sw=4 expandtab: */ 82 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_test_images.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_images.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines some images for tests. 33 | 34 | */ 35 | 36 | #ifndef SDL_test_images_h_ 37 | #define SDL_test_images_h_ 38 | 39 | #include "SDL.h" 40 | 41 | #include "begin_code.h" 42 | /* Set up for C function definitions, even when using C++ */ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /** 48 | *Type for test images. 49 | */ 50 | typedef struct SDLTest_SurfaceImage_s { 51 | int width; 52 | int height; 53 | unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ 54 | const char *pixel_data; 55 | } SDLTest_SurfaceImage_t; 56 | 57 | /* Test images */ 58 | SDL_Surface *SDLTest_ImageBlit(void); 59 | SDL_Surface *SDLTest_ImageBlitColor(void); 60 | SDL_Surface *SDLTest_ImageBlitAlpha(void); 61 | SDL_Surface *SDLTest_ImageBlitBlendAdd(void); 62 | SDL_Surface *SDLTest_ImageBlitBlend(void); 63 | SDL_Surface *SDLTest_ImageBlitBlendMod(void); 64 | SDL_Surface *SDLTest_ImageBlitBlendNone(void); 65 | SDL_Surface *SDLTest_ImageBlitBlendAll(void); 66 | SDL_Surface *SDLTest_ImageFace(void); 67 | SDL_Surface *SDLTest_ImagePrimitives(void); 68 | SDL_Surface *SDLTest_ImagePrimitivesBlend(void); 69 | 70 | /* Ends C function definitions when using C++ */ 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | #include "close_code.h" 75 | 76 | #endif /* SDL_test_images_h_ */ 77 | 78 | /* vi: set ts=4 sw=4 expandtab: */ 79 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_test_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_log.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Wrapper to log in the TEST category 33 | * 34 | */ 35 | 36 | #ifndef SDL_test_log_h_ 37 | #define SDL_test_log_h_ 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Prints given message with a timestamp in the TEST category and INFO priority. 47 | * 48 | * \param fmt Message to be logged 49 | */ 50 | void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 51 | 52 | /** 53 | * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. 54 | * 55 | * \param fmt Message to be logged 56 | */ 57 | void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 58 | 59 | /* Ends C function definitions when using C++ */ 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #include "close_code.h" 64 | 65 | #endif /* SDL_test_log_h_ */ 66 | 67 | /* vi: set ts=4 sw=4 expandtab: */ 68 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_test_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_memory.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef SDL_test_memory_h_ 31 | #define SDL_test_memory_h_ 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | 40 | /** 41 | * \brief Start tracking SDL memory allocations 42 | * 43 | * \note This should be called before any other SDL functions for complete tracking coverage 44 | */ 45 | int SDLTest_TrackAllocations(void); 46 | 47 | /** 48 | * \brief Print a log of any outstanding allocations 49 | * 50 | * \note This can be called after SDL_Quit() 51 | */ 52 | void SDLTest_LogAllocations(void); 53 | 54 | 55 | /* Ends C function definitions when using C++ */ 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #include "close_code.h" 60 | 61 | #endif /* SDL_test_memory_h_ */ 62 | 63 | /* vi: set ts=4 sw=4 expandtab: */ 64 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_test_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_test_random.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | A "32-bit Multiply with carry random number generator. Very fast. 33 | Includes a list of recommended multipliers. 34 | 35 | multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. 36 | period: (a*2^31)-1 37 | 38 | */ 39 | 40 | #ifndef SDL_test_random_h_ 41 | #define SDL_test_random_h_ 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* --- Definitions */ 50 | 51 | /* 52 | * Macros that return a random number in a specific format. 53 | */ 54 | #define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) 55 | 56 | /* 57 | * Context structure for the random number generator state. 58 | */ 59 | typedef struct { 60 | unsigned int a; 61 | unsigned int x; 62 | unsigned int c; 63 | unsigned int ah; 64 | unsigned int al; 65 | } SDLTest_RandomContext; 66 | 67 | 68 | /* --- Function prototypes */ 69 | 70 | /** 71 | * \brief Initialize random number generator with two integers. 72 | * 73 | * Note: The random sequence of numbers returned by ...Random() is the 74 | * same for the same two integers and has a period of 2^31. 75 | * 76 | * \param rndContext pointer to context structure 77 | * \param xi integer that defines the random sequence 78 | * \param ci integer that defines the random sequence 79 | * 80 | */ 81 | void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, 82 | unsigned int ci); 83 | 84 | /** 85 | * \brief Initialize random number generator based on current system time. 86 | * 87 | * \param rndContext pointer to context structure 88 | * 89 | */ 90 | void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); 91 | 92 | 93 | /** 94 | * \brief Initialize random number generator based on current system time. 95 | * 96 | * Note: ...RandomInit() or ...RandomInitTime() must have been called 97 | * before using this function. 98 | * 99 | * \param rndContext pointer to context structure 100 | * 101 | * \returns a random number (32bit unsigned integer) 102 | * 103 | */ 104 | unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); 105 | 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* SDL_test_random_h_ */ 114 | 115 | /* vi: set ts=4 sw=4 expandtab: */ 116 | -------------------------------------------------------------------------------- /_libs/include/SDL2/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file SDL_types.h 24 | * 25 | * \deprecated 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_stdinc.h" 30 | -------------------------------------------------------------------------------- /_libs/include/SDL2/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2022 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /** 23 | * \file close_code.h 24 | * 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #ifndef _begin_code_h 30 | #error close_code.h included without matching begin_code.h 31 | #endif 32 | #undef _begin_code_h 33 | 34 | /* Reset structure packing at previous byte alignment */ 35 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 36 | #ifdef __BORLANDC__ 37 | #pragma nopackwarning 38 | #endif 39 | #pragma pack(pop) 40 | #endif /* Compiler needs structure packing set */ 41 | -------------------------------------------------------------------------------- /_libs/include/SDL2/dummy.go: -------------------------------------------------------------------------------- 1 | package dummy 2 | -------------------------------------------------------------------------------- /_libs/include/SDL2/effects_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* $Id$ */ 23 | 24 | #ifndef _INCLUDE_EFFECTS_INTERNAL_H_ 25 | #define _INCLUDE_EFFECTS_INTERNAL_H_ 26 | 27 | #ifndef __MIX_INTERNAL_EFFECT__ 28 | #error You should not include this file or use these functions. 29 | #endif 30 | 31 | #include "SDL_mixer.h" 32 | 33 | extern int _Mix_effects_max_speed; 34 | extern void *_Eff_volume_table; 35 | void *_Eff_build_volume_table_u8(void); 36 | void *_Eff_build_volume_table_s8(void); 37 | 38 | void _Mix_InitEffects(void); 39 | void _Mix_DeinitEffects(void); 40 | void _Eff_PositionDeinit(void); 41 | 42 | int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f, 43 | Mix_EffectDone_t d, void *arg); 44 | int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f); 45 | int _Mix_UnregisterAllEffects_locked(int channel); 46 | 47 | #endif /* _INCLUDE_EFFECTS_INTERNAL_H_ */ 48 | 49 | /* vi: set ts=4 sw=4 expandtab: */ 50 | -------------------------------------------------------------------------------- /_libs/include/SDL2/load_aiff.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/include/SDL2/load_aiff.h -------------------------------------------------------------------------------- /_libs/include/SDL2/load_voc.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | This is the source needed to decode a Creative Labs VOC file into a 22 | waveform. It's pretty straightforward once you get going. The only 23 | externally-callable function is Mix_LoadVOC_RW(), which is meant to 24 | act as identically to SDL_LoadWAV_RW() as possible. 25 | 26 | This file by Ryan C. Gordon (icculus@icculus.org). 27 | 28 | Heavily borrowed from sox v12.17.1's voc.c. 29 | (http://www.freshmeat.net/projects/sox/) 30 | */ 31 | 32 | /* Don't call this directly; use Mix_LoadWAV_RW() for now. */ 33 | SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc, 34 | SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); 35 | 36 | /* vi: set ts=4 sw=4 expandtab: */ 37 | -------------------------------------------------------------------------------- /_libs/include/SDL2/mixer.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* Locking wrapper functions */ 23 | extern void Mix_LockAudio(void); 24 | extern void Mix_UnlockAudio(void); 25 | 26 | extern void add_chunk_decoder(const char *decoder); 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_cmd.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports an external command for playing music */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_CMD; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_flac.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #include "music.h" 23 | 24 | extern Mix_MusicInterface Mix_MusicInterface_FLAC; 25 | 26 | /* vi: set ts=4 sw=4 expandtab: */ 27 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_fluidsynth.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | James Le Cuirot 22 | chewi@aura-online.co.uk 23 | */ 24 | 25 | /* This file supports playing MIDI files with FluidSynth */ 26 | 27 | #include "music.h" 28 | 29 | extern Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH; 30 | 31 | /* vi: set ts=4 sw=4 expandtab: */ 32 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_mad.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports playing MP3 files with libmad */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_MAD; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_mikmod.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports playing MOD files with libmikmod */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_MIKMOD; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_modplug.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports playing MOD files with libmodplug */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_MODPLUG; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_mpg123.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports playing MP3 files with mpg123 */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_MPG123; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_nativemidi.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports playing MIDI files with OS APIs */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_ogg.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports Ogg Vorbis music streams */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_OGG; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_opus.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports Ogg Opus music streams */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_Opus; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_timidity.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports playing MIDI files with timidity */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_TIMIDITY; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/include/SDL2/music_wav.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL_mixer: An audio mixer library based on the SDL library 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | /* This file supports streaming WAV files */ 23 | 24 | #include "music.h" 25 | 26 | extern Mix_MusicInterface Mix_MusicInterface_WAV; 27 | 28 | /* vi: set ts=4 sw=4 expandtab: */ 29 | -------------------------------------------------------------------------------- /_libs/libSDL2_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_android_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_darwin_arm64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_darwin_arm64.a -------------------------------------------------------------------------------- /_libs/libSDL2_gfx_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_gfx_android_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_gfx_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_gfx_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_gfx_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_gfx_linux_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_gfx_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_gfx_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_gfx_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_gfx_linux_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_gfx_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_gfx_windows_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_gfx_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_gfx_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_android_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_linux_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_linux_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_linux_arm_rpi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_linux_arm_rpi.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_linux_arm_vivante.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_linux_arm_vivante.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_linux_mipsel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_linux_mipsel.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_windows_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_image_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_image_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_linux_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_linux_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_linux_arm_rpi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_linux_arm_rpi.a -------------------------------------------------------------------------------- /_libs/libSDL2_linux_arm_vivante.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_linux_arm_vivante.a -------------------------------------------------------------------------------- /_libs/libSDL2_linux_mipsel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_linux_mipsel.a -------------------------------------------------------------------------------- /_libs/libSDL2_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libSDL2_mixer_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_mixer_android_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_mixer_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_mixer_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_mixer_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_mixer_linux_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_mixer_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_mixer_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_mixer_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_mixer_linux_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_mixer_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_mixer_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libSDL2_mixer_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_mixer_windows_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_mixer_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_mixer_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_android_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_linux_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_linux_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_linux_arm_rpi.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_linux_arm_rpi.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_linux_arm_vivante.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_linux_arm_vivante.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_linux_mipsel.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_linux_mipsel.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_windows_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_ttf_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_ttf_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_windows_386.a -------------------------------------------------------------------------------- /_libs/libSDL2_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2main_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2main_android_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2main_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2main_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2main_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2main_linux_386.a -------------------------------------------------------------------------------- /_libs/libSDL2main_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2main_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libSDL2main_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2main_linux_arm.a -------------------------------------------------------------------------------- /_libs/libSDL2main_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2main_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libSDL2main_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2main_windows_386.a -------------------------------------------------------------------------------- /_libs/libSDL2main_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libSDL2main_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libfreetype_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libfreetype_android_arm.a -------------------------------------------------------------------------------- /_libs/libfreetype_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libfreetype_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libfreetype_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libfreetype_linux_386.a -------------------------------------------------------------------------------- /_libs/libfreetype_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libfreetype_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libfreetype_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libfreetype_linux_arm.a -------------------------------------------------------------------------------- /_libs/libfreetype_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libfreetype_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libfreetype_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libfreetype_windows_386.a -------------------------------------------------------------------------------- /_libs/libfreetype_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libfreetype_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libjpeg_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libjpeg_android_arm.a -------------------------------------------------------------------------------- /_libs/libjpeg_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libjpeg_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libjpeg_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libjpeg_linux_386.a -------------------------------------------------------------------------------- /_libs/libjpeg_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libjpeg_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libjpeg_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libjpeg_linux_arm.a -------------------------------------------------------------------------------- /_libs/libjpeg_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libjpeg_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libjpeg_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libjpeg_windows_386.a -------------------------------------------------------------------------------- /_libs/libjpeg_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libjpeg_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libmpg123_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libmpg123_android_arm.a -------------------------------------------------------------------------------- /_libs/libmpg123_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libmpg123_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libmpg123_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libmpg123_linux_386.a -------------------------------------------------------------------------------- /_libs/libmpg123_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libmpg123_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libmpg123_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libmpg123_linux_arm.a -------------------------------------------------------------------------------- /_libs/libmpg123_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libmpg123_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libmpg123_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libmpg123_windows_386.a -------------------------------------------------------------------------------- /_libs/libmpg123_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libmpg123_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libogg_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libogg_android_arm.a -------------------------------------------------------------------------------- /_libs/libogg_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libogg_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libogg_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libogg_linux_386.a -------------------------------------------------------------------------------- /_libs/libogg_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libogg_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libogg_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libogg_linux_arm.a -------------------------------------------------------------------------------- /_libs/libogg_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libogg_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libogg_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libogg_windows_386.a -------------------------------------------------------------------------------- /_libs/libogg_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libogg_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libpng_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libpng_android_arm.a -------------------------------------------------------------------------------- /_libs/libpng_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libpng_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libpng_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libpng_linux_386.a -------------------------------------------------------------------------------- /_libs/libpng_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libpng_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libpng_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libpng_linux_arm.a -------------------------------------------------------------------------------- /_libs/libpng_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libpng_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libpng_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libpng_windows_386.a -------------------------------------------------------------------------------- /_libs/libpng_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libpng_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libvorbis_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbis_android_arm.a -------------------------------------------------------------------------------- /_libs/libvorbis_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbis_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libvorbis_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbis_linux_386.a -------------------------------------------------------------------------------- /_libs/libvorbis_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbis_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libvorbis_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbis_linux_arm.a -------------------------------------------------------------------------------- /_libs/libvorbis_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbis_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libvorbis_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbis_windows_386.a -------------------------------------------------------------------------------- /_libs/libvorbis_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbis_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libvorbisfile_android_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbisfile_android_arm.a -------------------------------------------------------------------------------- /_libs/libvorbisfile_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbisfile_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libvorbisfile_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbisfile_linux_386.a -------------------------------------------------------------------------------- /_libs/libvorbisfile_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbisfile_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libvorbisfile_linux_arm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbisfile_linux_arm.a -------------------------------------------------------------------------------- /_libs/libvorbisfile_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbisfile_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libvorbisfile_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbisfile_windows_386.a -------------------------------------------------------------------------------- /_libs/libvorbisfile_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libvorbisfile_windows_amd64.a -------------------------------------------------------------------------------- /_libs/libz_darwin_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libz_darwin_amd64.a -------------------------------------------------------------------------------- /_libs/libz_linux_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libz_linux_386.a -------------------------------------------------------------------------------- /_libs/libz_linux_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libz_linux_amd64.a -------------------------------------------------------------------------------- /_libs/libz_linux_mipsle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libz_linux_mipsle.a -------------------------------------------------------------------------------- /_libs/libz_windows_386.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libz_windows_386.a -------------------------------------------------------------------------------- /_libs/libz_windows_amd64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/veandco/go-sdl2/7f43f67a3a12d53b3d69f142b9bb67678081313a/_libs/libz_windows_amd64.a -------------------------------------------------------------------------------- /gfx/sdl_gfx_cgo.go: -------------------------------------------------------------------------------- 1 | // +build !static 2 | 3 | package gfx 4 | 5 | //#cgo windows LDFLAGS: -lSDL2 -lSDL2_gfx 6 | //#cgo linux freebsd darwin pkg-config: sdl2 7 | //#cgo linux freebsd darwin LDFLAGS: -lSDL2_gfx 8 | import "C" 9 | -------------------------------------------------------------------------------- /gfx/sdl_gfx_cgo_static.go: -------------------------------------------------------------------------------- 1 | // +build static 2 | 3 | package gfx 4 | 5 | //#cgo CFLAGS: -I${SRCDIR}/../_libs/include -I${SRCDIR}/../_libs/include/SDL2 6 | //#cgo LDFLAGS: -L${SRCDIR}/../_libs 7 | //#cgo linux,386 LDFLAGS: -lSDL2_gfx_linux_386 -lSDL2_linux_386 -Wl,--no-undefined -lm -ldl -lasound -lm -ldl -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 8 | //#cgo linux,amd64 LDFLAGS: -lSDL2_gfx_linux_amd64 -lSDL2_linux_amd64 -Wl,--no-undefined -lm -ldl -lasound -lm -ldl -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 9 | //#cgo windows,386 LDFLAGS: -lSDL2_gfx_windows_386 -lSDL2_windows_386 -Wl,--no-undefined -lSDL2main_windows_386 -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -static-libgcc 10 | //#cgo windows,amd64 LDFLAGS: -lSDL2_gfx_windows_amd64 -lSDL2_windows_amd64 -Wl,--no-undefined -lSDL2main_windows_amd64 -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -static-libgcc 11 | //#cgo darwin,amd64 LDFLAGS: -lSDL2_gfx_darwin_amd64 -lSDL2_darwin_amd64 -lm -liconv -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,Metal 12 | //#cgo android,arm LDFLAGS: -lSDL2_gfx_android_arm -lSDL2_android_arm -Wl,--no-undefined -lm -ldl -llog -landroid -lGLESv2 -lGLESv1_CM 13 | //#cgo linux,arm,!android LDFLAGS: -L/opt/vc/lib -L/opt/vc/lib64 -lSDL2_gfx_linux_arm -lSDL2_linux_arm -Wl,--no-undefined -lm -ldl -liconv -lbcm_host -lvcos -lvchiq_arm -pthread 14 | import "C" 15 | -------------------------------------------------------------------------------- /gfx/sdl_gfx_test.go: -------------------------------------------------------------------------------- 1 | package gfx 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestMin(t *testing.T) { 8 | if a := []int{4, 2, 3, 5, 1, 6, 5, 7}; min(a...) != 1 { 9 | t.Fail() 10 | } 11 | 12 | if a := []int{5, 6, -2, 1, 8, 1, 4, 3}; min(a...) != -2 { 13 | t.Fail() 14 | } 15 | } 16 | 17 | func TestFPSmanager(t *testing.T) { 18 | fpsManager := FPSmanager{} 19 | InitFramerate(&fpsManager) 20 | 21 | if !SetFramerate(&fpsManager, 60) { 22 | t.Errorf("gfx.SetFramerate failed") 23 | } 24 | 25 | if fps, ok := GetFramerate(&fpsManager); !ok || fps != 60 { 26 | t.Errorf("gfx.GetFramerate() = (%v, %v) - want (60, true)", fps, ok) 27 | } 28 | 29 | // frame count is initialized to 0 30 | if count, ok := GetFramecount(&fpsManager); !ok || count != 0 { 31 | t.Errorf("gfx.GetFramecount() = (%v, %v) - want (0, true)", count, ok) 32 | } 33 | 34 | // count one frame 35 | FramerateDelay(&fpsManager) 36 | 37 | // frame count should now be 1 38 | if count, ok := GetFramecount(&fpsManager); !ok || count != 1 { 39 | t.Errorf("gfx.Framecount() = (%v, %v) - want (1, true)", count, ok) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /gfx/sdl_gfx_wrapper.h: -------------------------------------------------------------------------------- 1 | #if defined(__WIN32) 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #else 8 | #include 9 | #include 10 | #include 11 | #include 12 | #endif 13 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/veandco/go-sdl2 2 | 3 | go 1.15 4 | -------------------------------------------------------------------------------- /img/sdl_image_cgo.go: -------------------------------------------------------------------------------- 1 | // +build !static 2 | 3 | package img 4 | 5 | //#cgo linux freebsd darwin pkg-config: sdl2 6 | //#cgo linux freebsd darwin LDFLAGS: -lSDL2_image 7 | //#cgo windows LDFLAGS: -lSDL2 -lSDL2_image 8 | import "C" 9 | -------------------------------------------------------------------------------- /img/sdl_image_cgo_static.go: -------------------------------------------------------------------------------- 1 | // +build static 2 | 3 | package img 4 | 5 | //#cgo CFLAGS: -I${SRCDIR}/../_libs/include -I${SRCDIR}/../_libs/include/SDL2 6 | //#cgo LDFLAGS: -L${SRCDIR}/../_libs 7 | //#cgo linux,386 LDFLAGS: -lSDL2_image_linux_386 -Wl,--no-undefined -lpng_linux_386 -ljpeg_linux_386 -lSDL2_linux_386 -lm -ldl -lz -lasound -lm -ldl -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 8 | //#cgo linux,amd64 LDFLAGS: -lSDL2_image_linux_amd64 -Wl,--no-undefined -lpng_linux_amd64 -ljpeg_linux_amd64 -lSDL2_linux_amd64 -lm -ldl -lz -lasound -lm -ldl -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 9 | //#cgo linux,mipsle LDFLAGS: -lSDL2_image_linux_mipsle -Wl,--no-undefined -lpng_linux_mipsle -ljpeg_linux_mipsle -lSDL2_linux_mipsle -lm -ldl 10 | //#cgo windows,386 LDFLAGS: -lSDL2_image_windows_386 -Wl,--no-undefined -lpng_windows_386 -ljpeg_windows_386 -lz_windows_386 -lSDL2_windows_386 -lSDL2main_windows_386 -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -static-libgcc 11 | //#cgo windows,amd64 LDFLAGS: -lSDL2_image_windows_amd64 -Wl,--no-undefined -lpng_windows_amd64 -ljpeg_windows_amd64 -lz_windows_amd64 -lSDL2_windows_amd64 -lSDL2main_windows_amd64 -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -static-libgcc 12 | //#cgo darwin,amd64 LDFLAGS: -lSDL2_image_darwin_amd64 -lSDL2_darwin_amd64 -lpng_darwin_amd64 -ljpeg_darwin_amd64 -lm -lz -liconv -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,Metal 13 | //#cgo android,arm LDFLAGS: -lSDL2_image_android_arm -Wl,--no-undefined -lpng_android_arm -ljpeg_android_arm -lSDL2_android_arm -lm -ldl -lz -llog -landroid -lGLESv2 -lGLESv1_CM 14 | //#cgo linux,arm,!android LDFLAGS: -L/opt/vc/lib -L/opt/vc/lib64 -lSDL2_image_linux_arm -Wl,--no-undefined -lpng_linux_arm -ljpeg_linux_arm -lSDL2_linux_arm -lm -ldl -lz -liconv -lbcm_host -lvcos -lvchiq_arm -pthread 15 | import "C" 16 | -------------------------------------------------------------------------------- /img/sdl_image_wrapper.h: -------------------------------------------------------------------------------- 1 | #if defined(__WIN32) 2 | #include 3 | #include 4 | #else 5 | #include 6 | #endif 7 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | SETLOCAL 3 | 4 | REM Directories 5 | SET SRCDIR=%CD% 6 | 7 | REM @SET ALLDIRS!= find ${SRCDIR} -type d -not -path "./.hg*" 8 | 9 | REM Packages 10 | SET ROOTPKG=github.com/veandco/go-sdl2 11 | SET PACKAGES=sdl img mix ttf 12 | 13 | SET GO=go 14 | 15 | @IF "%~1" == "" GOTO :all 16 | @GOTO :%~1 17 | 18 | :all 19 | CALL :packages 20 | GOTO :eof 21 | 22 | :test 23 | CALL :packages 24 | FOR %%p IN (%PACKAGES%) DO ( 25 | ECHO Testing %ROOTPKG%/%%p... 26 | %GO% test -v %ROOTPKG%/%%p 27 | ) 28 | GOTO :eof 29 | 30 | :bench 31 | CALL :packages 32 | FOR %%p IN (%PACKAGES%) DO ( 33 | ECHO Benchmarking %ROOTPKG%/%%p... 34 | %GO% test -bench=. -cpu 1,2,3,4 %ROOTPKG%/%%p 35 | ) 36 | GOTO :eof 37 | 38 | :packages 39 | FOR %%p IN (%PACKAGES%) DO ( 40 | ECHO Building package %ROOTPKG%/%%p... 41 | %GO% build %ROOTPKG%/%%p 42 | ) 43 | GOTO :eof 44 | 45 | ENDLOCAL 46 | ECHO ON 47 | -------------------------------------------------------------------------------- /mix/TODO.md: -------------------------------------------------------------------------------- 1 | ## 2.8.0 2 | 3 | - [x] Mix_GetNumTracks 4 | - [x] Mix_PauseAudio 5 | - [x] Mix_StartTrack 6 | 7 | ## 2.6.0 8 | 9 | - [x] Mix_GetMusicAlbumTag 10 | - [x] Mix_GetMusicArtistTag 11 | - [x] Mix_GetMusicCopyrightTag 12 | - [x] Mix_GetMusicLoopEndTime 13 | - [x] Mix_GetMusicLoopLengthTime 14 | - [x] Mix_GetMusicLoopStartTime 15 | - [x] Mix_GetMusicPosition 16 | - [x] Mix_GetMusicTitle 17 | - [x] Mix_GetMusicTitleTag 18 | - [x] Mix_GetMusicVolume 19 | - [x] Mix_HasMusicDecoder 20 | - [x] Mix_MasterVolume 21 | - [x] Mix_ModMusicJumpToOrder 22 | - [x] Mix_MusicDuration 23 | - [x] Mix_SetTimidityCfg 24 | 25 | ## 2.0.2 26 | 27 | - [x] OpenAudioDevice() 28 | - [x] Mix_HasChunkDecoder 29 | 30 | ## 2.0.0 31 | 32 | - [ ] UnregisterEffect() 33 | - [x] SetPostMix() 34 | - [x] HookMusic() 35 | - [x] HookMusicFinished() 36 | - [x] ChannelFinished() 37 | - [x] RegisterEffect() 38 | - [x] UnregisterAllEffects() 39 | - [x] EachSoundFont() 40 | - [x] LinkedVersion() 41 | -------------------------------------------------------------------------------- /mix/midi.go: -------------------------------------------------------------------------------- 1 | // +build !nomidi,!android 2 | 3 | package mix 4 | 5 | //#include 6 | //#include "sdl_mixer_wrapper.h" 7 | //extern int callEachSoundFont(char* str, void* udata); 8 | // 9 | //#if !(SDL_MIXER_VERSION_ATLEAST(2,6,0)) 10 | // 11 | //#if defined(WARN_OUTDATED) 12 | //#pragma message("Mix_SetTimidityCfg is not supported before SDL 2.6.0") 13 | //#endif 14 | // 15 | //int Mix_SetTimidityCfg(const char *path) 16 | //{ 17 | // return 0; 18 | //} 19 | // 20 | //#endif 21 | import "C" 22 | import "unsafe" 23 | 24 | var eachSoundFontFunc func(string) int 25 | 26 | //export callEachSoundFont 27 | func callEachSoundFont(str *C.char, udata unsafe.Pointer) C.int { 28 | return C.int(eachSoundFontFunc(C.GoString(str))) 29 | } 30 | 31 | // EachSoundFont iterates over SoundFonts paths to use by supported MIDI backends. 32 | // (https://wiki.libsdl.org/SDL2_mixer/Mix_EachSoundFont) 33 | func EachSoundFont(function func(string) int) int { 34 | eachSoundFontFunc = function 35 | return int(C.Mix_EachSoundFont((*[0]byte)(C.callEachSoundFont), nil)) 36 | } 37 | 38 | // SetSoundFonts sets SoundFonts paths to use by supported MIDI backends. 39 | // (https://wiki.libsdl.org/SDL2_mixer/Mix_SetSoundFonts) 40 | func SetSoundFonts(paths string) bool { 41 | _paths := C.CString(paths) 42 | defer C.free(unsafe.Pointer(_paths)) 43 | return int(C.Mix_SetSoundFonts(_paths)) == 0 44 | } 45 | 46 | // GetSoundFonts returns SoundFonts paths to use by supported MIDI backends. 47 | // (https://wiki.libsdl.org/SDL2_mixer/Mix_GetSoundFonts) 48 | func GetSoundFonts() string { 49 | return (string)(C.GoString(C.Mix_GetSoundFonts())) 50 | } 51 | 52 | // Set full path of the Timidity config file. Returns true if successful, false on error. This is obviously only useful if SDL_mixer is using Timidity internally to play MIDI files. 53 | // (https://wiki.libsdl.org/SDL2_mixer/Mix_SetTimidityCfg) 54 | func SetTimidityCfg(path string) bool { 55 | _path := C.CString(path) 56 | defer C.free(unsafe.Pointer(_path)) 57 | return int(C.Mix_SetTimidityCfg(_path)) == 0 58 | } 59 | -------------------------------------------------------------------------------- /mix/sdl_mixer_cgo.go: -------------------------------------------------------------------------------- 1 | // +build !static 2 | 3 | package mix 4 | 5 | //#cgo windows LDFLAGS: -lSDL2 -lSDL2_mixer 6 | //#cgo linux freebsd darwin pkg-config: sdl2 7 | //#cgo linux freebsd darwin LDFLAGS: -lSDL2_mixer 8 | import "C" 9 | -------------------------------------------------------------------------------- /mix/sdl_mixer_cgo_static.go: -------------------------------------------------------------------------------- 1 | // +build static 2 | 3 | package mix 4 | 5 | //#cgo CFLAGS: -I${SRCDIR}/../_libs/include -I${SRCDIR}/../_libs/include/SDL2 6 | //#cgo LDFLAGS: -L${SRCDIR}/../_libs 7 | //#cgo linux,386 LDFLAGS: -lSDL2_mixer_linux_386 -Wl,--no-undefined -lmpg123_linux_386 -lvorbisfile_linux_386 -lvorbis_linux_386 -logg_linux_386 -lSDL2_linux_386 -lm -ldl -lasound -lm -ldl -lstdc++ -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 8 | //#cgo linux,amd64 LDFLAGS: -lSDL2_mixer_linux_amd64 -Wl,--no-undefined -lmpg123_linux_amd64 -lvorbisfile_linux_amd64 -lvorbis_linux_amd64 -logg_linux_amd64 -lSDL2_linux_amd64 -lm -ldl -lstdc++ -lasound -lm -ldl -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 9 | //#cgo linux,mipsle LDFLAGS: -lSDL2_mixer_linux_mipsle -Wl,--no-undefined -lmpg123_linux_mipsle -lvorbisfile_linux_mipsle -lvorbis_linux_mipsle -logg_linux_mipsle -lSDL2_linux_mipsle -lm -ldl -lstdc++ -lm -ldl 10 | //#cgo windows,386 LDFLAGS: -lSDL2_mixer_windows_386 -Wl,--no-undefined -lmpg123_windows_386 -lvorbisfile_windows_386 -lvorbis_windows_386 -logg_windows_386 -lSDL2_windows_386 -lSDL2main_windows_386 -lstdc++ -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -lshlwapi -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -static-libgcc 11 | //#cgo windows,amd64 LDFLAGS: -lSDL2_mixer_windows_amd64 -Wl,--no-undefined -lmpg123_windows_amd64 -lvorbisfile_windows_amd64 -lvorbis_windows_amd64 -logg_windows_amd64 -lSDL2_windows_amd64 -lSDL2main_windows_amd64 -lstdc++ -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -lshlwapi -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -static-libgcc 12 | //#cgo darwin,amd64 LDFLAGS: -lSDL2_mixer_darwin_amd64 -lmpg123_darwin_amd64 -lvorbisfile_darwin_amd64 -lvorbis_darwin_amd64 -logg_darwin_amd64 -lSDL2_darwin_amd64 -lm -liconv -lfreetype_darwin_amd64 -lz_darwin_amd64 -lSDL2_darwin_amd64 -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,Metal 13 | //#cgo android,arm LDFLAGS: -lSDL2_mixer_android_arm -Wl,--no-undefined -lmpg123_android_arm -lvorbisfile_android_arm -lvorbis_android_arm -logg_android_arm -lSDL2_android_arm -lm -ldl -llog -landroid -lGLESv2 -lGLESv1_CM 14 | //#cgo linux,arm,!android LDFLAGS: -L/opt/vc/lib -L/opt/vc/lib64 -lSDL2_mixer_linux_arm -Wl,--no-undefined -lmpg123_linux_arm -lvorbisfile_linux_arm -lvorbis_linux_arm -logg_linux_arm -lSDL2_linux_arm -lm -ldl -liconv -lbcm_host -lvcos -lvchiq_arm -pthread 15 | import "C" 16 | -------------------------------------------------------------------------------- /mix/sdl_mixer_wrapper.h: -------------------------------------------------------------------------------- 1 | #if defined(__WIN32) 2 | #include 3 | #else 4 | #include 5 | #endif 6 | -------------------------------------------------------------------------------- /raster/painter.go: -------------------------------------------------------------------------------- 1 | // This code is inspired to golang/freetype/raster 2 | 3 | // Package raster implements a Painter interface for rasterizing paths over 4 | // a generic Image, using its ColorModel to convert from a generic raster color 5 | // to the correct color model. 6 | package raster 7 | 8 | import ( 9 | "github.com/golang/freetype/raster" 10 | "image/color" 11 | "image/draw" 12 | ) 13 | 14 | // ImagePainter operates on a generic Image (not only sdl.Surfaces) and allows 15 | // to rasterize a path using a specific color. 16 | type ImagePainter struct { 17 | Image draw.Image 18 | c color.Color 19 | } 20 | 21 | // Paint a batch of Spans using the current ImagePainter image and color. 22 | // Image's Color model will be used to convert the color. 23 | func (p *ImagePainter) Paint(ss []raster.Span, done bool) { 24 | // Convert color to RGBA 25 | dr, dg, db, da := p.c.RGBA() // 16 bit values 26 | // Alpha mask 27 | const m = 1<<16 - 1 28 | // Draw spans 29 | b := p.Image.Bounds() 30 | for _, s := range ss { 31 | if s.Y < b.Min.Y || s.Y >= b.Max.Y { 32 | continue 33 | } 34 | if s.X0 < b.Min.X { 35 | s.X0 = b.Min.X 36 | } 37 | if s.X1 > b.Max.X { 38 | s.X1 = b.Max.X 39 | } 40 | if s.X0 >= s.X1 { 41 | continue 42 | } 43 | for x := s.X0; x < s.X1; x++ { 44 | y := s.Y - b.Min.Y 45 | var ma uint32 = s.Alpha // 16 bit value 46 | // Get destination pixel color in RGBA64 47 | sr, sg, sb, sa := p.Image.At(x, y).RGBA() // 16 bit values 48 | // Compute destination color in RGBA64 49 | var a = (m - (da * ma / m)) 50 | rr := uint16((dr*ma + sr*a) / m) 51 | gg := uint16((dg*ma + sg*a) / m) 52 | bb := uint16((db*ma + sb*a) / m) 53 | aa := uint16((da*ma + sa*a) / m) 54 | // Use image model to convert 55 | p.Image.Set(x, y, color.RGBA64{rr, gg, bb, aa}) 56 | } 57 | } 58 | } 59 | 60 | // SetColor set the color to use when rasterizing 61 | func (p *ImagePainter) SetColor(c color.Color) { 62 | p.c = c 63 | } 64 | 65 | // NewImagePainter builds a Painter for a generic Image 66 | func NewImagePainter(m draw.Image) *ImagePainter { 67 | return &ImagePainter{Image: m} 68 | } 69 | -------------------------------------------------------------------------------- /raster/painter_test.go: -------------------------------------------------------------------------------- 1 | package raster 2 | 3 | import ( 4 | "testing" 5 | 6 | "image" 7 | "image/color" 8 | "image/png" 9 | "os" 10 | 11 | "github.com/golang/freetype/raster" 12 | ) 13 | 14 | func TestImagePainter(t *testing.T) { 15 | // Spans to render 16 | ss := []raster.Span{ 17 | raster.Span{0, 4, 6, 0xffff}, 18 | raster.Span{1, 3, 7, 0xf0f0}, 19 | raster.Span{2, 2, 8, 0x8f8f}, 20 | raster.Span{3, 1, 9, 0x8080}, 21 | raster.Span{4, 0, 10, 0x0f0f}, 22 | } 23 | 24 | img := image.NewRGBA(image.Rect(0, 0, 10, 10)) 25 | pt := NewImagePainter(img) 26 | pt.SetColor(color.RGBA{0xff, 0x00, 0x00, 0xff}) 27 | pt.Paint(ss, false) 28 | 29 | // Write to PNG 30 | f, err := os.Create("output.png") 31 | if err != nil { 32 | t.Error(err) 33 | } 34 | if err := png.Encode(f, img); err != nil { 35 | f.Close() 36 | t.Error(err) 37 | } 38 | if err := f.Close(); err != nil { 39 | t.Error(err) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sdl/audio_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | ) 7 | 8 | var squareWave = []byte("RIFF,\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00" + 9 | "\x01\x00\xab \x00\x00\xab \x00\x00\x01\x00\b\x00data\b\x00\x00\x00\x00" + 10 | "\x00\x00\x00\xff\xff\xff\xff") 11 | 12 | func TestAudioDevices(t *testing.T) { 13 | for _, isCapture := range []bool{false, true} { 14 | n := GetNumAudioDevices(isCapture) 15 | for i := 0; i < n; i++ { 16 | if GetAudioDeviceName(i, isCapture) == "" { 17 | t.Errorf("GetAudioDeviceName(%v, %v) returned empty string", 18 | i, isCapture) 19 | } 20 | } 21 | 22 | // cover GetAudioDeviceName() even if n < 1 23 | if name := GetAudioDeviceName(-1, isCapture); name != "" { 24 | t.Errorf("GetAudioDeviceName(-1, %v) == %#v; want empty string", 25 | isCapture, name) 26 | } 27 | } 28 | } 29 | 30 | func TestAudioInitQuit(t *testing.T) { 31 | Do(func() { 32 | // figure out what driver will work 33 | if err := InitSubSystem(INIT_AUDIO); err != nil { 34 | t.Fatalf("InitSubSystem(INIT_AUDIO): %v", err) 35 | } 36 | driver := GetCurrentAudioDriver() 37 | 38 | // reset audio subsystem 39 | QuitSubSystem(INIT_AUDIO) 40 | if GetCurrentAudioDriver() != "" { 41 | t.Fatalf(`GetCurrentAudioDriver() != "" after QuitSubSystem()`) 42 | } 43 | 44 | // test valid init 45 | if err := AudioInit(driver); err != nil { 46 | t.Errorf("AudioInit(%s) returned error: %v", driver, err) 47 | } else { 48 | if got := GetCurrentAudioDriver(); got != driver { 49 | t.Errorf("GetCurrentAudioDriver() == %#v; want %#v", got, driver) 50 | } 51 | 52 | // test quit 53 | AudioQuit() 54 | if GetCurrentAudioDriver() != "" { 55 | t.Fatalf(`GetCurrentAudioDriver() != "" after AudioQuit()`) 56 | } 57 | } 58 | 59 | // test invalid init 60 | driver = "bogus" 61 | if err := AudioInit(driver); err == nil { 62 | t.Errorf("AudioInit(%s) did not return error", driver) 63 | } 64 | }) 65 | } 66 | 67 | func TestLoadWAVRW(t *testing.T) { 68 | // load WAV from *RWOps pointing to WAV data 69 | src, _ := RWFromMem(squareWave) 70 | buf, spec := LoadWAVRW(src, false) 71 | 72 | // test returned []byte 73 | want := []byte{0, 0, 0, 0, 255, 255, 255, 255} 74 | if buf == nil { 75 | t.Errorf("LoadWAVRW() returned nil []byte") 76 | } else { 77 | if bytes.Compare(buf, want) != 0 { 78 | t.Errorf("LoadWAVRW() returned %v; want %v", buf, want) 79 | } 80 | FreeWAV(buf) // make sure we can free without error 81 | } 82 | 83 | // test returned *AudioSpec 84 | if spec == nil { 85 | t.Errorf("LoadWAVRW() returned nil *AudioSpec") 86 | } else if spec.Freq != 8363 { // no need to test all the spec fields 87 | t.Errorf("LoadWAVRW() returned *AudioSpec with Freq %d; want %d", 88 | spec.Freq, 8363) 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /sdl/clipboard.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !(SDL_VERSION_ATLEAST(2,26,0)) 7 | 8 | #if defined(WARN_OUTDATED) 9 | #pragma message("SDL_SetPrimarySelectionText is not supported before SDL 2.26.0") 10 | #pragma message("SDL_GetPrimarySelectionText is not supported before SDL 2.26.0") 11 | #pragma message("SDL_HasPrimarySelectionText is not supported before SDL 2.26.0") 12 | #endif 13 | 14 | static inline int SDL_SetPrimarySelectionText(const char *text) 15 | { 16 | return -1; 17 | } 18 | 19 | static inline char * SDL_GetPrimarySelectionText(void) 20 | { 21 | return NULL; 22 | } 23 | 24 | static inline SDL_bool SDL_HasPrimarySelectionText(void) 25 | { 26 | return SDL_FALSE; 27 | } 28 | 29 | #endif 30 | */ 31 | import "C" 32 | import "unsafe" 33 | 34 | // SetClipboardText puts UTF-8 text into the clipboard. 35 | // (https://wiki.libsdl.org/SDL2/SDL_SetClipboardText) 36 | func SetClipboardText(text string) error { 37 | _text := C.CString(text) 38 | defer C.free(unsafe.Pointer(_text)) 39 | if C.SDL_SetClipboardText(_text) < 0 { 40 | return GetError() 41 | } 42 | return nil 43 | } 44 | 45 | // GetClipboardText returns UTF-8 text from the clipboard. 46 | // (https://wiki.libsdl.org/SDL2/SDL_GetClipboardText) 47 | func GetClipboardText() (string, error) { 48 | text := C.SDL_GetClipboardText() 49 | if text == nil { 50 | return "", GetError() 51 | } 52 | defer C.SDL_free(unsafe.Pointer(text)) 53 | _text := C.GoString(text) 54 | return _text, nil 55 | } 56 | 57 | // HasClipboardText reports whether the clipboard exists and contains a text string that is non-empty. 58 | // (https://wiki.libsdl.org/SDL2/SDL_HasClipboardText) 59 | func HasClipboardText() bool { 60 | return C.SDL_HasClipboardText() > 0 61 | } 62 | 63 | // SetPrimarySelectionText puts UTF-8 text into the primary selection. 64 | // (https://wiki.libsdl.org/SDL2/SDL_SetPrimarySelectionText) 65 | func SetPrimarySelectionText(text string) error { 66 | _text := C.CString(text) 67 | defer C.free(unsafe.Pointer(_text)) 68 | if C.SDL_SetPrimarySelectionText(_text) < 0 { 69 | return GetError() 70 | } 71 | return nil 72 | } 73 | 74 | // GetPrimarySelectionText gets UTF-8 text from the primary selection. 75 | // (https://wiki.libsdl.org/SDL2/SDL_GetPrimarySelectionText) 76 | func GetPrimarySelectionText() (string, error) { 77 | text := C.SDL_GetPrimarySelectionText() 78 | if text == nil { 79 | return "", GetError() 80 | } 81 | defer C.SDL_free(unsafe.Pointer(text)) 82 | _text := C.GoString(text) 83 | return _text, nil 84 | } 85 | 86 | // HasPrimarySelectionText queries whether the primary selection exists and contains a non-empty text string. 87 | // (https://wiki.libsdl.org/SDL2/SDL_HasPrimarySelectionText) 88 | func HasPrimarySelectionText() bool { 89 | return C.SDL_HasPrimarySelectionText() == C.SDL_TRUE 90 | } 91 | -------------------------------------------------------------------------------- /sdl/clipboard_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import "testing" 4 | 5 | func TestClipboard(t *testing.T) { 6 | Do(func() { 7 | Init(INIT_VIDEO) 8 | defer Quit() 9 | 10 | // need a window to own the clipboard 11 | if win, err := CreateWindow("", 0, 0, 0, 0, 0); err == nil { 12 | defer win.Destroy() 13 | } else { 14 | t.Skipf("Could not CreateWindow(): %v", err) 15 | } 16 | 17 | wantString, wantBool := []string{"", "naïveté"}, []bool{false, true} 18 | for i := 0; i < 2; i++ { 19 | if err := SetClipboardText(wantString[i]); err != nil { 20 | t.Skipf("Could not SetClipboardText(): %v", err) 21 | } 22 | if got := HasClipboardText(); got != wantBool[i] { 23 | t.Errorf("HasClipboardText() == %v; want %v", got, wantBool[i]) 24 | } 25 | if got, err := GetClipboardText(); err == nil && got != wantString[i] { 26 | t.Errorf("GetClipboardText() == (nil, %#v); want (nil, %#v)", 27 | got, wantString[i]) 28 | } 29 | } 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /sdl/cpuinfo_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import ( 4 | "runtime" 5 | "testing" 6 | ) 7 | 8 | func TestCPUCount(t *testing.T) { 9 | if runtime.NumCPU() != GetCPUCount() { 10 | t.Error("GetCPUCount(): CPU count mismatch") 11 | } 12 | } 13 | 14 | func TestGetCPUCacheLineSize(t *testing.T) { 15 | if GetCPUCacheLineSize() == 0 { 16 | t.Error("GetCPUCacheLineSize(): cache line size wrong") 17 | } 18 | } 19 | 20 | func TestGetSystemRAM(t *testing.T) { 21 | if VERSION_ATLEAST(2, 0, 1) && GetSystemRAM() <= 0 { 22 | t.Error("GetSystemRAM(): wrong return value") 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sdl/endian.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | // #include "sdl_wrapper.h" 4 | import "C" 5 | 6 | // Endian-specific values. 7 | // (https://wiki.libsdl.org/CategoryEndian) 8 | const ( 9 | BYTEORDER = C.SDL_BYTEORDER // macro that corresponds to the byte order used by the processor type it was compiled for 10 | LIL_ENDIAN = C.SDL_LIL_ENDIAN // byte order is 1234, where the least significant byte is stored first 11 | BIG_ENDIAN = C.SDL_BIG_ENDIAN // byte order is 4321, where the most significant byte is stored first 12 | ) 13 | -------------------------------------------------------------------------------- /sdl/error.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !(SDL_VERSION_ATLEAST(2,0,14)) 7 | 8 | #if defined(WARN_OUTDATED) 9 | #pragma message("SDL_GetErrorMsg is not supported before SDL 2.0.14") 10 | #endif 11 | 12 | static char * SDL_GetErrorMsg(char *errstr, int maxlen) 13 | { 14 | return errstr; 15 | } 16 | 17 | #endif 18 | 19 | void GoSetError(const char *fmt) { 20 | SDL_SetError("%s", fmt); 21 | } 22 | 23 | */ 24 | import "C" 25 | import ( 26 | "errors" 27 | "unsafe" 28 | ) 29 | 30 | var emptyCString *C.char = C.CString("") 31 | var ErrInvalidParameters = errors.New("Invalid Parameters") 32 | 33 | // SDL error codes with their corresponding predefined strings. 34 | const ( 35 | ENOMEM ErrorCode = C.SDL_ENOMEM // out of memory 36 | EFREAD ErrorCode = C.SDL_EFREAD // error reading from datastream 37 | EFWRITE ErrorCode = C.SDL_EFWRITE // error writing to datastream 38 | EFSEEK ErrorCode = C.SDL_EFSEEK // error seeking in datastream 39 | UNSUPPORTED ErrorCode = C.SDL_UNSUPPORTED // that operation is not supported 40 | LASTERROR ErrorCode = C.SDL_LASTERROR // the highest numbered predefined error 41 | ) 42 | 43 | // ErrorCode is an error code used in SDL error messages. 44 | type ErrorCode uint32 45 | type cErrorCode C.SDL_errorcode 46 | 47 | func (ec ErrorCode) c() C.SDL_errorcode { 48 | return C.SDL_errorcode(ec) 49 | } 50 | 51 | // GetError returns the last error that occurred, or an empty string if there hasn't been an error message set since the last call to ClearError(). 52 | // (https://wiki.libsdl.org/SDL2/SDL_GetError) 53 | func GetError() error { 54 | if err := C.SDL_GetError(); err != nil { 55 | gostr := C.GoString(err) 56 | // SDL_GetError returns "an empty string if there hasn't been an error message" 57 | if len(gostr) > 0 { 58 | return errors.New(gostr) 59 | } 60 | } 61 | return nil 62 | } 63 | 64 | // GetErrorMsg returns the last error message that was set for the current thread. 65 | // (https://wiki.libsdl.org/SDL2/SDL_GetErrorMsg) 66 | func GetErrorMsg(maxlen int) error { 67 | _buf := C.SDL_malloc(C.size_t(maxlen)) 68 | if err := C.SDL_GetErrorMsg((*C.char)(_buf), C.int(maxlen)); err != nil { 69 | gostr := C.GoString(err) 70 | // SDL_GetErrorMsg returns "an empty string if there hasn't been an error message" 71 | if len(gostr) > 0 { 72 | return errors.New(gostr) 73 | } 74 | } 75 | return nil 76 | } 77 | 78 | // SetError set the SDL error message. 79 | // (https://wiki.libsdl.org/SDL2/SDL_SetError) 80 | func SetError(err error) { 81 | if err != nil { 82 | _err := C.CString(err.Error()) 83 | defer C.free(unsafe.Pointer(_err)) 84 | C.GoSetError(_err) 85 | return 86 | } 87 | C.GoSetError(emptyCString) 88 | } 89 | 90 | // ClearError clears any previous error message. 91 | // (https://wiki.libsdl.org/SDL2/SDL_ClearError) 92 | func ClearError() { 93 | C.SDL_ClearError() 94 | } 95 | 96 | // Error sets the SDL error message to the specified error code. 97 | func Error(code ErrorCode) { 98 | C.SDL_Error(code.c()) 99 | } 100 | 101 | // OutOfMemory sets SDL error message to ENOMEM (out of memory). 102 | func OutOfMemory() { 103 | Error(ENOMEM) 104 | } 105 | 106 | // Unsupported sets SDL error message to UNSUPPORTED (that operation is not supported). 107 | func Unsupported() { 108 | Error(UNSUPPORTED) 109 | } 110 | 111 | // errorFromInt returns GetError() if passed negative value, otherwise it returns nil. 112 | func errorFromInt(code int) (err error) { 113 | if code < 0 { 114 | err = GetError() 115 | if err == nil { 116 | err = errors.New("Unknown error (probably using old version of SDL2 and the function called is not supported?)") 117 | } 118 | } 119 | return 120 | } 121 | -------------------------------------------------------------------------------- /sdl/events.c: -------------------------------------------------------------------------------- 1 | #include "_cgo_export.h" 2 | #include "events.h" 3 | 4 | SDL_Event event; 5 | 6 | void setEventFilter() 7 | { 8 | SDL_SetEventFilter((SDL_EventFilter)goSetEventFilterCallback, NULL); 9 | } 10 | 11 | void clearEventFilter() 12 | { 13 | SDL_SetEventFilter(NULL, NULL); 14 | } 15 | 16 | void filterEvents(void *userdata) 17 | { 18 | SDL_FilterEvents((SDL_EventFilter)goEventFilterCallback, userdata); 19 | } 20 | 21 | void addEventWatch(void *userdata) 22 | { 23 | SDL_AddEventWatch((SDL_EventFilter)goEventFilterCallback, userdata); 24 | } 25 | 26 | void delEventWatch(void *userdata) 27 | { 28 | SDL_DelEventWatch((SDL_EventFilter)goEventFilterCallback, userdata); 29 | } 30 | 31 | int PollEvent() 32 | { 33 | return SDL_PollEvent(&event); 34 | } -------------------------------------------------------------------------------- /sdl/events.h: -------------------------------------------------------------------------------- 1 | #ifndef _GO_SDL_EVENTS_H 2 | #define _GO_SDL_EVENTS_H 3 | 4 | #if defined(_WIN32) 5 | #include 6 | #else 7 | #include 8 | #endif 9 | 10 | extern SDL_Event event; 11 | 12 | extern void setEventFilter(); 13 | extern void clearEventFilter(); 14 | extern void filterEvents(void *userdata); 15 | extern void addEventWatch(void *userdata); 16 | extern void delEventWatch(void *userdata); 17 | extern int PollEvent(); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /sdl/filesystem.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !(SDL_VERSION_ATLEAST(2,0,1)) 7 | 8 | #if defined(WARN_OUTDATED) 9 | #pragma message("SDL_GetBasePath is not supported before SDL 2.0.1") 10 | #endif 11 | 12 | static inline char* SDL_GetBasePath() 13 | { 14 | return NULL; 15 | } 16 | 17 | 18 | #if defined(WARN_OUTDATED) 19 | #pragma message("SDL_GetPrefPath is not supported before SDL 2.0.1") 20 | #endif 21 | 22 | static inline char* SDL_GetPrefPath(const char *org, const char *app) 23 | { 24 | return NULL; 25 | } 26 | #endif 27 | 28 | */ 29 | import "C" 30 | import "unsafe" 31 | 32 | // GetBasePath returns the directory where the application was run from. This is where the application data directory is. 33 | // (https://wiki.libsdl.org/SDL2/SDL_GetBasePath) 34 | func GetBasePath() string { 35 | _val := C.SDL_GetBasePath() 36 | defer C.SDL_free(unsafe.Pointer(_val)) 37 | return C.GoString(_val) 38 | } 39 | 40 | // GetPrefPath returns the "pref dir". This is meant to be where the application can write personal files (Preferences and save games, etc.) that are specific to the application. This directory is unique per user and per application. 41 | // (https://wiki.libsdl.org/SDL2/SDL_GetPrefPath) 42 | func GetPrefPath(org, app string) string { 43 | _org := C.CString(org) 44 | _app := C.CString(app) 45 | defer C.free(unsafe.Pointer(_org)) 46 | defer C.free(unsafe.Pointer(_app)) 47 | _val := C.SDL_GetPrefPath(_org, _app) 48 | defer C.SDL_free(unsafe.Pointer(_val)) 49 | return C.GoString(_val) 50 | } 51 | -------------------------------------------------------------------------------- /sdl/filesystem_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestGetBasePath(t *testing.T) { 8 | if !VERSION_ATLEAST(2, 0, 1) { 9 | return 10 | } 11 | 12 | Do(func() { 13 | Init(INIT_EVERYTHING) 14 | path := GetBasePath() 15 | // pathetic, but a comparison to runtime.Caller() does not help here, 16 | // since this would return go's testing package 17 | if path == "" { 18 | t.Error("GetBasePath() did not return anything") 19 | } 20 | Quit() 21 | }) 22 | } 23 | 24 | // Do not test GetPrefPath(), since SDL_GetPrefPath() also 25 | // *creates* the necessary directories, polluting the user's 26 | // system with unnecessary stuff. 27 | // func TestGetPrefPath(t *testing.T) { 28 | // path := GetPrefPath("go-sdl2", "test") 29 | // t.Error(path) 30 | // } 31 | -------------------------------------------------------------------------------- /sdl/gesture.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | // #include "sdl_wrapper.h" 4 | import "C" 5 | 6 | // GestureID is the unique id of the closest gesture to the performed stroke. 7 | type GestureID C.SDL_GestureID 8 | 9 | func (g GestureID) c() C.SDL_GestureID { 10 | return C.SDL_GestureID(g) 11 | } 12 | 13 | // RecordGesture begins recording a gesture on a specified touch device or all touch devices. 14 | // (https://wiki.libsdl.org/SDL2/SDL_RecordGesture) 15 | func RecordGesture(t TouchID) int { 16 | return int(C.SDL_RecordGesture(t.c())) 17 | } 18 | 19 | // SaveAllDollarTemplates saves all currently loaded Dollar Gesture templates. 20 | // (https://wiki.libsdl.org/SDL2/SDL_SaveAllDollarTemplates) 21 | func SaveAllDollarTemplates(src *RWops) int { 22 | return int(C.SDL_SaveAllDollarTemplates(src.cptr())) 23 | } 24 | 25 | // SaveDollarTemplate saves a currently loaded Dollar Gesture template. 26 | // (https://wiki.libsdl.org/SDL2/SDL_SaveDollarTemplate) 27 | func SaveDollarTemplate(g GestureID, src *RWops) int { 28 | return int(C.SDL_SaveDollarTemplate(g.c(), src.cptr())) 29 | } 30 | 31 | // LoadDollarTemplates loads Dollar Gesture templates from a file. 32 | // (https://wiki.libsdl.org/SDL2/SDL_LoadDollarTemplates) 33 | func LoadDollarTemplates(t TouchID, src *RWops) int { 34 | return int(C.SDL_LoadDollarTemplates(t.c(), src.cptr())) 35 | } 36 | -------------------------------------------------------------------------------- /sdl/guid.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !SDL_VERSION_ATLEAST(2,24,0) 7 | #if defined(WARN_OUTDATED) 8 | #pragma message("SDL_GUIDToString is not supported before SDL 2.24.0") 9 | #pragma message("SDL_GUIDFromString is not supported before SDL 2.24.0") 10 | #endif 11 | 12 | typedef struct { 13 | Uint8 data[16]; 14 | } SDL_GUID; 15 | 16 | static inline void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) 17 | { 18 | return; 19 | } 20 | 21 | static inline SDL_GUID SDL_GUIDFromString(const char *pchGUID) 22 | { 23 | SDL_GUID guid; 24 | return guid; 25 | } 26 | #endif 27 | */ 28 | import "C" 29 | import ( 30 | "unsafe" 31 | ) 32 | 33 | type GUID C.SDL_GUID 34 | 35 | // ToString returns an ASCII string representation for a given GUID. 36 | func (guid GUID) ToString() (ascii string) { 37 | _cap := C.size_t(33) 38 | _buf := (*C.char)(C.SDL_malloc(_cap)) 39 | defer C.SDL_free(unsafe.Pointer(_buf)) 40 | C.SDL_GUIDToString(C.SDL_GUID(guid), _buf, C.int(_cap)) 41 | return C.GoString(_buf) 42 | } 43 | 44 | // GUIDFromString converts a GUID string into a GUID structure. 45 | func GUIDFromString(ascii string) (guid GUID) { 46 | _ascii := C.CString(ascii) 47 | defer C.free(unsafe.Pointer(_ascii)) 48 | return GUID(C.SDL_GUIDFromString(_ascii)) 49 | } 50 | -------------------------------------------------------------------------------- /sdl/helpers.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | // Btoi returns 0 or 1 according to the value of b. 4 | func Btoi(b bool) int { 5 | if b == true { 6 | return 1 7 | } 8 | 9 | return 0 10 | } 11 | -------------------------------------------------------------------------------- /sdl/hints.c: -------------------------------------------------------------------------------- 1 | #include "_cgo_export.h" 2 | 3 | #include "sdl_wrapper.h" 4 | #include "hints.h" 5 | 6 | void hintCallback(void *userdata, const char *name, const char *oldValue, const char *newValue) 7 | { 8 | goHintCallback((char *) name, (char *) oldValue, (char *) newValue); 9 | } 10 | 11 | void addHintCallback(const char *name) 12 | { 13 | SDL_AddHintCallback(name, hintCallback, NULL); 14 | } 15 | 16 | void delHintCallback(const char *name) 17 | { 18 | SDL_DelHintCallback(name, hintCallback, NULL);} 19 | -------------------------------------------------------------------------------- /sdl/hints.h: -------------------------------------------------------------------------------- 1 | void hintCallback(void *userdata, const char *name, const char *oldValue, const char *newValue); 2 | void addHintCallback(const char *name); 3 | void delHintCallback(const char *name); 4 | -------------------------------------------------------------------------------- /sdl/loadso.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | // #include "sdl_wrapper.h" 4 | import "C" 5 | import "unsafe" 6 | 7 | // SharedObject is a pointer to the object handle. 8 | type SharedObject uintptr 9 | 10 | // LoadObject dynamically loads a shared object and returns a pointer to the object handle. 11 | // (https://wiki.libsdl.org/SDL2/SDL_LoadObject) 12 | func LoadObject(sofile string) SharedObject { 13 | _sofile := C.CString(sofile) 14 | defer C.free(unsafe.Pointer(_sofile)) 15 | return (SharedObject)(C.SDL_LoadObject(_sofile)) 16 | } 17 | 18 | // LoadFunction returns a pointer to the named function from the shared object. 19 | // (https://wiki.libsdl.org/SDL2/SDL_LoadFunction) 20 | func (handle SharedObject) LoadFunction(name string) unsafe.Pointer { 21 | _name := C.CString(name) 22 | defer C.free(unsafe.Pointer(_name)) 23 | return (unsafe.Pointer)(C.SDL_LoadFunction((unsafe.Pointer)(handle), _name)) 24 | } 25 | 26 | // Unload unloads a shared object from memory. 27 | // (https://wiki.libsdl.org/SDL2/SDL_UnloadObject) 28 | func (handle SharedObject) Unload() { 29 | C.SDL_UnloadObject((unsafe.Pointer)(handle)) 30 | } 31 | -------------------------------------------------------------------------------- /sdl/locale.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !(SDL_VERSION_ATLEAST(2,0,14)) 7 | 8 | typedef struct SDL_Locale 9 | { 10 | const char *language; 11 | const char *country; 12 | } SDL_Locale; 13 | 14 | #if defined(WARN_OUTDATED) 15 | #pragma message("SDL_GetPreferredLocales is not supported before SDL 2.0.14") 16 | #endif 17 | 18 | static SDL_Locale * SDL_GetPreferredLocales(void) 19 | { 20 | return NULL; 21 | } 22 | 23 | #endif 24 | */ 25 | import "C" 26 | 27 | type Locale struct { 28 | Language string // A language name, like "en" for English. 29 | Country string // A country, like "US" for America. Can be empty. 30 | } 31 | 32 | func GetPreferredLocales() (locale Locale, err error) { 33 | _locale := C.SDL_GetPreferredLocales() 34 | if _locale == nil { 35 | err = GetError() 36 | return 37 | } 38 | locale.Language = C.GoString(_locale.language) 39 | locale.Country = C.GoString(_locale.country) 40 | return 41 | } 42 | -------------------------------------------------------------------------------- /sdl/log.c: -------------------------------------------------------------------------------- 1 | #include "_cgo_export.h" 2 | 3 | void LogSetOutputFunction(void *data) 4 | { 5 | SDL_LogSetOutputFunction((SDL_LogOutputFunction)logOutputFunction, data); 6 | } 7 | -------------------------------------------------------------------------------- /sdl/log.h: -------------------------------------------------------------------------------- 1 | void LogSetOutputFunction(void *data); 2 | -------------------------------------------------------------------------------- /sdl/log_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestLog(t *testing.T) { 8 | Log("log_test: TestLog: %s", "this is a message") 9 | } 10 | 11 | func TestLogSetOutputFunction(t *testing.T) { 12 | LogSetOutputFunction(func(d interface{}, c LogCategory, pri LogPriority, message string) { 13 | println("CUSTOM:", message) 14 | }, nil) 15 | Log("log_test: TestLogSetOutputFunction: %s", "this is a message") 16 | } 17 | -------------------------------------------------------------------------------- /sdl/metal.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !(SDL_VERSION_ATLEAST(2,0,12)) 7 | 8 | typedef void *SDL_MetalView; 9 | 10 | #if defined(WARN_OUTDATED) 11 | #pragma message("SDL_Metal_CreateView is not supported before SDL 2.0.12") 12 | #pragma message("SDL_Metal_DestroyView is not supported before SDL 2.0.12") 13 | #endif 14 | 15 | static SDL_MetalView SDL_Metal_CreateView(SDL_Window * window) 16 | { 17 | return NULL; 18 | } 19 | 20 | static void SDL_Metal_DestroyView(SDL_MetalView view) 21 | { 22 | // do nothing 23 | } 24 | 25 | #endif 26 | 27 | #if !(SDL_VERSION_ATLEAST(2,0,14)) 28 | 29 | #if defined(WARN_OUTDATED) 30 | #pragma message("SDL_Metal_GetLayer is not supported before SDL 2.0.14") 31 | #pragma message("SDL_Metal_GetDrawableSize is not supported before SDL 2.0.14") 32 | #endif 33 | 34 | static void * SDL_Metal_GetLayer(SDL_MetalView view) 35 | { 36 | return NULL; 37 | } 38 | 39 | static void SDL_Metal_GetDrawableSize(SDL_Window* window, int *w, int *h) 40 | { 41 | // do nothing 42 | } 43 | 44 | #endif 45 | */ 46 | import "C" 47 | import "unsafe" 48 | 49 | // A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). 50 | type MetalView C.SDL_MetalView 51 | 52 | // Metal_CreateView creates a CAMetalLayer-backed NSView/UIView and attach it to the specified window. 53 | // (https://wiki.libsdl.org/SDL2/SDL_Metal_CreateView) 54 | func Metal_CreateView(window *Window) MetalView { 55 | return MetalView(C.SDL_Metal_CreateView(window.cptr())) 56 | } 57 | 58 | // Metal_DestroyView Destroy an existing SDL_MetalView object. 59 | // (https://wiki.libsdl.org/SDL2/SDL_Metal_DestroyView) 60 | func Metal_DestroyView(metalView MetalView) { 61 | C.SDL_Metal_DestroyView(C.SDL_MetalView(metalView)) 62 | } 63 | 64 | // Metal_GetLayer gets a pointer to the backing CAMetalLayer for the given view. 65 | // (https://wiki.libsdl.org/SDL2/SDL_Metal_GetLayer) 66 | func Metal_GetLayer(metalView MetalView) unsafe.Pointer { 67 | return C.SDL_Metal_GetLayer(C.SDL_MetalView(metalView)) 68 | } 69 | 70 | // Metal_GetDrawableSize Get the size of a window's underlying drawable in pixels (for use with setting viewport, scissor & etc). 71 | // (https://wiki.libsdl.org/SDL2/SDL_Metal_GetDrawableSize) 72 | func Metal_GetDrawableSize(window *Window) (w, h int) { 73 | C.SDL_Metal_GetDrawableSize(window.cptr(), (*C.int)(unsafe.Pointer(&w)), (*C.int)(unsafe.Pointer((&h)))) 74 | return 75 | } 76 | -------------------------------------------------------------------------------- /sdl/misc.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !(SDL_VERSION_ATLEAST(2,0,14)) 7 | 8 | #if defined(WARN_OUTDATED) 9 | #pragma message("SDL_OpenURL is not supported before SDL 2.0.14") 10 | #endif 11 | 12 | static int SDL_OpenURL(const char *url) 13 | { 14 | return -1; 15 | } 16 | 17 | #endif 18 | */ 19 | import "C" 20 | import "unsafe" 21 | 22 | // OpenURL opens an URL / URI in the browser or other 23 | // (https://wiki.libsdl.org/SDL2/SDL_OpenURL) 24 | func OpenURL(url string) error { 25 | _url := C.CString(url) 26 | defer C.free(unsafe.Pointer(_url)) 27 | return errorFromInt(int(C.SDL_OpenURL(_url))) 28 | } 29 | -------------------------------------------------------------------------------- /sdl/pixels_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import "testing" 4 | 5 | func TestBytesAndBitsPerPixel(t *testing.T) { 6 | tests := []struct { 7 | name string 8 | format PixelFormatConstant 9 | wantBytes int 10 | wantBits int 11 | }{ 12 | {"UNKNOWN", PIXELFORMAT_UNKNOWN, 0, 0}, 13 | {"INDEX1LSB", PIXELFORMAT_INDEX1LSB, 0, 1}, 14 | {"INDEX1MSB", PIXELFORMAT_INDEX1MSB, 0, 1}, 15 | {"INDEX4LSB", PIXELFORMAT_INDEX4LSB, 0, 4}, 16 | {"INDEX4MSB", PIXELFORMAT_INDEX4MSB, 0, 4}, 17 | {"INDEX8", PIXELFORMAT_INDEX8, 1, 8}, 18 | {"RGB332", PIXELFORMAT_RGB332, 1, 8}, 19 | {"RGB444", PIXELFORMAT_RGB444, 2, 12}, 20 | {"RGB555", PIXELFORMAT_RGB555, 2, 15}, 21 | {"BGR555", PIXELFORMAT_BGR555, 2, 15}, 22 | {"ARGB4444", PIXELFORMAT_ARGB4444, 2, 16}, 23 | {"RGBA4444", PIXELFORMAT_RGBA4444, 2, 16}, 24 | {"ABGR4444", PIXELFORMAT_ABGR4444, 2, 16}, 25 | {"BGRA4444", PIXELFORMAT_BGRA4444, 2, 16}, 26 | {"ARGB1555", PIXELFORMAT_ARGB1555, 2, 16}, 27 | {"RGBA5551", PIXELFORMAT_RGBA5551, 2, 16}, 28 | {"ABGR1555", PIXELFORMAT_ABGR1555, 2, 16}, 29 | {"BGRA5551", PIXELFORMAT_BGRA5551, 2, 16}, 30 | {"RGB565", PIXELFORMAT_RGB565, 2, 16}, 31 | {"BGR565", PIXELFORMAT_BGR565, 2, 16}, 32 | {"RGB24", PIXELFORMAT_RGB24, 3, 24}, 33 | {"BGR24", PIXELFORMAT_BGR24, 3, 24}, 34 | {"RGB888", PIXELFORMAT_RGB888, 4, 24}, 35 | {"RGBX8888", PIXELFORMAT_RGBX8888, 4, 24}, 36 | {"BGR888", PIXELFORMAT_BGR888, 4, 24}, 37 | {"BGRX8888", PIXELFORMAT_BGRX8888, 4, 24}, 38 | {"ARGB8888", PIXELFORMAT_ARGB8888, 4, 32}, 39 | {"RGBA8888", PIXELFORMAT_RGBA8888, 4, 32}, 40 | {"ABGR8888", PIXELFORMAT_ABGR8888, 4, 32}, 41 | {"BGRA8888", PIXELFORMAT_BGRA8888, 4, 32}, 42 | {"ARGB2101010", PIXELFORMAT_ARGB2101010, 4, 32}, 43 | {"YV12", PIXELFORMAT_YV12, 1, 86}, 44 | {"IYUV", PIXELFORMAT_IYUV, 1, 89}, 45 | {"YUY2", PIXELFORMAT_YUY2, 2, 85}, 46 | {"UYVY", PIXELFORMAT_UYVY, 2, 89}, 47 | {"YVYU", PIXELFORMAT_YVYU, 2, 86}, 48 | } 49 | for _, tt := range tests { 50 | if got := BytesPerPixel(uint32(tt.format)); got != tt.wantBytes { 51 | t.Errorf("BytesPerPixel(%s) want %d, got %d", tt.name, tt.wantBytes, got) 52 | } 53 | if got := BitsPerPixel(uint32(tt.format)); got != tt.wantBits { 54 | t.Errorf("BitsPerPixel(%s) want %d, got %d", tt.name, tt.wantBits, got) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /sdl/power.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | // #include "sdl_wrapper.h" 4 | import "C" 5 | 6 | // An enumeration of the basic state of the system's power supply. 7 | // (https://wiki.libsdl.org/SDL2/SDL_PowerState) 8 | type PowerState C.SDL_PowerState 9 | 10 | const ( 11 | POWERSTATE_UNKNOWN PowerState = C.SDL_POWERSTATE_UNKNOWN // cannot determine power status 12 | POWERSTATE_ON_BATTERY PowerState = C.SDL_POWERSTATE_ON_BATTERY // not plugged in, running on the battery 13 | POWERSTATE_NO_BATTERY PowerState = C.SDL_POWERSTATE_NO_BATTERY // plugged in, no battery available 14 | POWERSTATE_CHARGING PowerState = C.SDL_POWERSTATE_CHARGING // plugged in, charging battery 15 | POWERSTATE_CHARGED PowerState = C.SDL_POWERSTATE_CHARGED // plugged in, battery charged 16 | ) 17 | 18 | // GetPowerInfo returns the current power supply details. 19 | // (https://wiki.libsdl.org/SDL2/SDL_GetPowerInfo) 20 | func GetPowerInfo() (PowerState, int, int) { 21 | _secs := C.int(0) 22 | _percent := C.int(0) 23 | _state := PowerState(C.SDL_GetPowerInfo(&_secs, &_percent)) 24 | return _state, (int)(_secs), (int)(_percent) 25 | } 26 | -------------------------------------------------------------------------------- /sdl/power_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import "testing" 4 | 5 | func TestGetPowerInfo(t *testing.T) { 6 | state, seconds, percent := GetPowerInfo() 7 | strstate := "Unknown" 8 | minutes := -1 9 | if state == POWERSTATE_CHARGED { 10 | strstate = "Battery charged" 11 | } else if state == POWERSTATE_CHARGING { 12 | strstate = "Battery charging" 13 | } else if state == POWERSTATE_NO_BATTERY { 14 | strstate = "No battery" 15 | } else if state == POWERSTATE_ON_BATTERY { 16 | strstate = "On battery" 17 | } 18 | if seconds != -1 { 19 | minutes = seconds / 60 20 | } 21 | t.Log("Power status report, please check manually") 22 | t.Logf("Status: %s", strstate) 23 | t.Logf("Minutes left (-1 = undetermined): %d", minutes) 24 | t.Logf("Percent left (-1 = undetermined): %d", percent) 25 | } 26 | -------------------------------------------------------------------------------- /sdl/render_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import ( 4 | "errors" 5 | "testing" 6 | ) 7 | 8 | func TestRenderIntegerScale(t *testing.T) { 9 | _, r, err := CreateWindowAndRenderer(50, 50, 0) 10 | if err != nil { 11 | t.Fatalf("unable to create renderer: %s", err) 12 | return 13 | } 14 | 15 | errUnsupported := errors.New("That operation is not supported") 16 | 17 | if !VERSION_ATLEAST(2, 0, 5) { 18 | t.Run("GetIntegerScale on versions < 2.0.5 should return unsupported", func(t *testing.T) { 19 | _, got := r.GetIntegerScale() 20 | if got.Error() != errUnsupported.Error() { 21 | t.Fatalf("expected call to GetIntegerScale to fail with %s, got %s", errUnsupported, got) 22 | } 23 | }) 24 | t.Run("SetIntegerScale on versions < 2.0.5 should return unsupported", func(t *testing.T) { 25 | got := r.SetIntegerScale(false) 26 | if got.Error() != errUnsupported.Error() { 27 | t.Fatalf("expected call to SetIntegerScale to fail with %s, got %s", errUnsupported, got) 28 | } 29 | }) 30 | 31 | return 32 | } 33 | 34 | set := func(v bool, t *testing.T) { 35 | if err := r.SetIntegerScale(v); err != nil { 36 | t.Fatalf("unable to set scale %v: %s", v, err) 37 | } 38 | } 39 | check := func(want bool, t *testing.T) { 40 | got, err := r.GetIntegerScale() 41 | if err != nil { 42 | t.Fatalf("unable to get scale: %s", err) 43 | } 44 | 45 | if got != want { 46 | t.Fatalf("wanted renderer scale to be %v", want) 47 | } 48 | } 49 | 50 | t.Run("should start out as false", func(t *testing.T) { 51 | check(false, t) 52 | }) 53 | 54 | t.Run("if set to true should return true", func(t *testing.T) { 55 | set(true, t) 56 | check(true, t) 57 | }) 58 | 59 | t.Run("if set to false should return false", func(t *testing.T) { 60 | set(true, t) 61 | check(true, t) 62 | 63 | set(false, t) 64 | check(false, t) 65 | }) 66 | 67 | t.Run("should handle SDL_FALSE return on GetIntegerScale", func(t *testing.T) { 68 | _, dummy, err := CreateWindowAndRenderer(50, 50, 0) 69 | if err != nil { 70 | t.Fatalf("unable to create renderer: %s", err) 71 | return 72 | } 73 | 74 | if err := dummy.SetIntegerScale(true); err != nil { 75 | t.Fatalf("expected call to SetIntegerScale to succeed, got %s", err) 76 | } 77 | if err := dummy.Destroy(); err != nil { 78 | t.Fatalf("expected call to Destroy to succeed, got %s", err) 79 | } 80 | 81 | v, err := dummy.GetIntegerScale() 82 | if err == nil { 83 | t.Fatalf("expected call to GetIntegerScale on ivalid renderer to fail") 84 | } 85 | if v != false { 86 | t.Fatalf("wanted renderer scale to be %v", false) 87 | } 88 | }) 89 | } 90 | -------------------------------------------------------------------------------- /sdl/sdl_cgo.go: -------------------------------------------------------------------------------- 1 | // +build !static 2 | 3 | package sdl 4 | 5 | //#cgo windows LDFLAGS: -lSDL2 6 | //#cgo linux freebsd darwin openbsd pkg-config: sdl2 7 | import "C" 8 | -------------------------------------------------------------------------------- /sdl/sdl_cgo_static.go: -------------------------------------------------------------------------------- 1 | // +build static 2 | 3 | package sdl 4 | 5 | //#cgo CFLAGS: -I${SRCDIR}/../_libs/include -I${SRCDIR}/../_libs/include/SDL2 6 | //#cgo LDFLAGS: -L${SRCDIR}/../_libs 7 | //#cgo linux,386 LDFLAGS: -lSDL2_linux_386 -lm -ldl -lasound -lm -ldl -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 8 | //#cgo linux,amd64 LDFLAGS: -lSDL2_linux_amd64 -lm -ldl -lasound -lm -ldl -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 9 | //#cgo linux,mipsle LDFLAGS: -lSDL2_linux_mipsle -lm -ldl 10 | //#cgo windows,386 LDFLAGS: -lSDL2_windows_386 -lSDL2main_windows_386 -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc 11 | //#cgo windows,amd64 LDFLAGS: -lSDL2_windows_amd64 -lSDL2main_windows_amd64 -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -static-libgcc 12 | //#cgo darwin,amd64 LDFLAGS: -lSDL2_darwin_amd64 -lm -liconv -Wl,-framework,OpenGL -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,Metal 13 | //#cgo darwin,arm64 LDFLAGS: -lSDL2_darwin_arm64 -lm -liconv -Wl,-framework,OpenGL -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,Metal 14 | //#cgo android,arm LDFLAGS: -lSDL2_android_arm -lm -ldl -llog -landroid -lGLESv2 -lGLESv1_CM 15 | //#cgo linux,arm,!android LDFLAGS: -L/opt/vc/lib -L/opt/vc/lib64 -lSDL2_linux_arm -lm -ldl -liconv -lbcm_host -lvcos -lvchiq_arm -pthread 16 | import "C" 17 | import ( 18 | _ "github.com/veandco/go-sdl2/_libs" 19 | _ "github.com/veandco/go-sdl2/_libs/include/SDL2" 20 | ) 21 | -------------------------------------------------------------------------------- /sdl/sdl_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "runtime" 7 | "testing" 8 | ) 9 | 10 | func init() { 11 | if !VERSION_ATLEAST(2, 0, 4) { 12 | fmt.Printf("Warning: Your SDL version (%d.%d.%d) is outdated and may fail to pass tests written for 2.0.4\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL) 13 | } 14 | } 15 | 16 | /* Set up main thread during testing to run any thread-stubborn test code. 17 | * This is necessary as Go runs test functions on different threads. 18 | * Examples of functions that are best run in main: 19 | * Init, Quit, PollEvent, WaitEvent 20 | * Failure to run such functions in main during testing may produce insidious, 21 | * hard-to-reproduce bugs. 22 | */ 23 | func TestMain(m *testing.M) { 24 | var exitcode int 25 | Main(func() { 26 | exitcode = m.Run() 27 | }) 28 | os.Exit(exitcode) 29 | } 30 | 31 | func TestInitQuit(t *testing.T) { 32 | Do(func() { 33 | Init(0) 34 | subs := []uint32{INIT_TIMER, INIT_AUDIO, INIT_VIDEO, INIT_JOYSTICK, 35 | INIT_HAPTIC, INIT_GAMECONTROLLER} 36 | 37 | for i := 0; i < len(subs); i++ { 38 | if (runtime.GOOS == "freebsd") && (subs[i] == INIT_HAPTIC) { 39 | // FreeBSD does not support the haptic subsystem 40 | continue 41 | } 42 | if err := Init(subs[i]); err != nil { 43 | t.Errorf("Error on Init(%d): %s", subs[i], err) 44 | } 45 | if WasInit(subs[i]) != subs[i] { 46 | t.Errorf("Init(%d): subsystem not initialized", subs[i]) 47 | } 48 | QuitSubSystem(subs[i]) 49 | if WasInit(subs[i]) == subs[i] { 50 | t.Errorf("QuitSubSystem(%d): subsystem still initialized", subs[i]) 51 | } 52 | if err := InitSubSystem(subs[i]); err != nil { 53 | t.Errorf("Error on Init(%d): %s", subs[i], err) 54 | } 55 | if WasInit(subs[i]) != subs[i] { 56 | t.Errorf("InitSubSystem(%d): subsystem not initialized", subs[i]) 57 | } 58 | QuitSubSystem(subs[i]) 59 | if WasInit(subs[i]) == subs[i] { 60 | t.Errorf("QuitSubSystem(%d): subsystem still initialized", subs[i]) 61 | } 62 | } 63 | Quit() 64 | }) 65 | } 66 | 67 | func TestGetPlatform(t *testing.T) { 68 | goos := runtime.GOOS 69 | value := GetPlatform() 70 | if (goos == "linux" && value != "Linux") || 71 | (goos == "freebsd" && value != "FreeBSD") || 72 | (goos == "windows" && value != "Windows") || 73 | (goos == "darwin" && value != "Mac OS X") { 74 | t.Errorf("platform mismatch: '%s' != '%s'", goos, value) 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /sdl/sdl_wrapper.h: -------------------------------------------------------------------------------- 1 | #if defined(_WIN32) 2 | #include 3 | #include 4 | #else 5 | #include 6 | #endif 7 | 8 | #if !defined(SDL_2_0_10) 9 | #define SDL_2_0_10 10 | 11 | #if !(SDL_VERSION_ATLEAST(2,0,10)) 12 | 13 | #if defined(WARN_OUTDATED) 14 | #pragma message("SDL_FPoint is not supported before SDL 2.0.10") 15 | #endif 16 | 17 | typedef struct SDL_FPoint 18 | { 19 | float x; 20 | float y; 21 | } SDL_FPoint; 22 | 23 | #if defined(WARN_OUTDATED) 24 | #pragma message("SDL_FRect is not supported before SDL 2.0.10") 25 | #endif 26 | 27 | typedef struct SDL_FRect 28 | { 29 | float x; 30 | float y; 31 | float w; 32 | float h; 33 | } SDL_FRect; 34 | 35 | 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /sdl/surface_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestSurface(t *testing.T) { 8 | Do(func() { 9 | var window *Window 10 | var surface *Surface 11 | var image *Surface 12 | var err error 13 | 14 | Init(INIT_EVERYTHING) 15 | defer Quit() 16 | 17 | if window, err = CreateWindow("Hello!", 100, 100, 800, 600, WINDOW_SHOWN); err != nil { 18 | t.Error(err) 19 | } 20 | defer window.Destroy() 21 | 22 | if surface, err = window.GetSurface(); err != nil { 23 | t.Error(err) 24 | } 25 | 26 | pixels := surface.Pixels() 27 | for i := range pixels { 28 | pixels[i] = 0xFF 29 | } 30 | 31 | if err = window.UpdateSurface(); err != nil { 32 | t.Error(err) 33 | } 34 | 35 | Delay(50) 36 | 37 | if image, err = LoadBMP("../.go-sdl2-examples/assets/test.bmp"); err != nil { 38 | t.Error(err) 39 | } 40 | defer image.Free() 41 | 42 | if err = image.Blit(&Rect{0, 0, 512, 512}, surface, &Rect{0, 0, 512, 512}); err != nil { 43 | t.Error(err) 44 | } 45 | 46 | if err = window.UpdateSurface(); err != nil { 47 | t.Error(err) 48 | } 49 | 50 | Delay(50) 51 | }) 52 | } 53 | -------------------------------------------------------------------------------- /sdl/sysrender.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | // #include "sdl_wrapper.h" 4 | import "C" 5 | import "unsafe" 6 | 7 | // Texture contains an efficient, driver-specific representation of pixel data. 8 | // (https://wiki.libsdl.org/SDL2/SDL_Texture) 9 | type Texture C.SDL_Texture 10 | 11 | // Renderer contains a rendering state. 12 | // (https://wiki.libsdl.org/SDL2/SDL_Renderer) 13 | type Renderer C.SDL_Renderer 14 | 15 | func (t *Texture) cptr() *C.SDL_Texture { 16 | return (*C.SDL_Texture)(unsafe.Pointer(t)) 17 | } 18 | 19 | func (r *Renderer) cptr() *C.SDL_Renderer { 20 | return (*C.SDL_Renderer)(unsafe.Pointer(r)) 21 | } 22 | -------------------------------------------------------------------------------- /sdl/system.c: -------------------------------------------------------------------------------- 1 | #include "_cgo_export.h" 2 | #include "system.h" 3 | 4 | #if defined(_WIN32) 5 | void SetWindowsMessageHook() 6 | { 7 | SDL_SetWindowsMessageHook((SDL_WindowsMessageHook) goWindowsMessageHook, NULL); 8 | } 9 | #endif 10 | -------------------------------------------------------------------------------- /sdl/system.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !(SDL_VERSION_ATLEAST(2,0,9)) 7 | 8 | #if defined(WARN_OUTDATED) 9 | #pragma message("SDL_IsTablet is not supported before SDL 2.0.9") 10 | #endif 11 | 12 | static inline SDL_bool SDL_IsTablet() 13 | { 14 | return SDL_FALSE; 15 | } 16 | 17 | #endif 18 | */ 19 | import "C" 20 | 21 | // IsTablet returns true if the current device is a tablet 22 | // (https://wiki.libsdl.org/SDL2/SDL_IsTablet) 23 | func IsTablet() bool { 24 | return C.SDL_IsTablet() == C.SDL_TRUE 25 | } 26 | -------------------------------------------------------------------------------- /sdl/system.h: -------------------------------------------------------------------------------- 1 | #ifndef _GO_SDL_SYSTEM_H 2 | #define _GO_SDL_SYSTEM_H 3 | 4 | #if defined(_WIN32) 5 | extern void SetWindowsMessageHook(); 6 | #endif 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /sdl/system_linux.go: -------------------------------------------------------------------------------- 1 | // +build !android 2 | 3 | package sdl 4 | 5 | /* 6 | #include "sdl_wrapper.h" 7 | 8 | #if !(SDL_VERSION_ATLEAST(2,0,9)) 9 | 10 | #if defined(WARN_OUTDATED) 11 | #pragma message("SDL_LinuxSetThreadPriority is not supported before SDL 2.0.9") 12 | #endif 13 | 14 | static int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) 15 | { 16 | return -1; 17 | } 18 | 19 | #endif 20 | 21 | #if !(SDL_VERSION_ATLEAST(2,0,18)) 22 | 23 | #if defined(WARN_OUTDATED) 24 | #pragma message("SDL_LinuxSetThreadPriorityAndPolicy is not supported before SDL 2.0.18") 25 | #endif 26 | 27 | static int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy) 28 | { 29 | return -1; 30 | } 31 | 32 | #endif 33 | */ 34 | import "C" 35 | 36 | // LinuxSetThreadPriority sets the UNIX nice value for a thread. 37 | // 38 | // This uses setpriority() if possible, and RealtimeKit if available. 39 | // 40 | // (https://wiki.libsdl.org/SDL2/SDL_LinuxSetThreadPriority) 41 | func LinuxSetThreadPriority(threadID int64, priority int) (err error) { 42 | _threadID := C.Sint64(threadID) 43 | _priority := C.int(priority) 44 | return errorFromInt(int(C.SDL_LinuxSetThreadPriority(_threadID, _priority))) 45 | } 46 | 47 | // LinuxSetThreadPriority sets the priority (not nice level) and scheduling policy for a thread. 48 | // 49 | // This uses setpriority() if possible, and RealtimeKit if available. 50 | // 51 | // (https://wiki.libsdl.org/SDL2/SDL_LinuxSetThreadPriorityAndPolicy) 52 | func LinuxSetThreadPriorityAndPolicy(threadID int64, sdlPriority, schedPolicy int) (err error) { 53 | _threadID := C.Sint64(threadID) 54 | _sdlPriority := C.int(sdlPriority) 55 | _schedPolicy := C.int(schedPolicy) 56 | return errorFromInt(int(C.SDL_LinuxSetThreadPriorityAndPolicy(_threadID, _sdlPriority, _schedPolicy))) 57 | } 58 | -------------------------------------------------------------------------------- /sdl/system_windows.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | #include "system.h" 6 | 7 | #if !(SDL_VERSION_ATLEAST(2,0,16)) 8 | 9 | #if defined(WARN_OUTDATED) 10 | #pragma message("SDL_RenderGetD3D11Device is not supported before SDL 2.0.16") 11 | #endif 12 | 13 | typedef struct ID3D11Device ID3D11Device; 14 | 15 | static ID3D11Device* SDL_RenderGetD3D11Device(SDL_Renderer * renderer) 16 | { 17 | return NULL; 18 | } 19 | 20 | #endif 21 | */ 22 | import "C" 23 | import ( 24 | "unsafe" 25 | ) 26 | 27 | type WindowsMessageHook func(userdata interface{}, hWnd unsafe.Pointer, message uint32, wParam uint64, lParam int64) 28 | var windowsMessageHook WindowsMessageHook 29 | 30 | type ID3D11Device C.ID3D11Device; 31 | 32 | // SetWindowsMessageHook sets a callback for every Windows message, run before TranslateMessage(). 33 | // (https://wiki.libsdl.org/SDL2/SDL_SetWindowsMessageHook) 34 | func SetWindowsMessageHook(callback WindowsMessageHook, userdata interface{}) { 35 | windowsMessageHook = callback 36 | C.SetWindowsMessageHook() 37 | } 38 | 39 | //export goWindowsMessageHook 40 | func goWindowsMessageHook(userdata interface{}, hWnd unsafe.Pointer, message uint32, wParam uint64, lParam int64) { 41 | if windowsMessageHook == nil { 42 | return 43 | } 44 | windowsMessageHook(userdata, hWnd, message, wParam, lParam) 45 | } 46 | 47 | // SDL_RenderGetD3D11Device gets the D3D11 device associated with a renderer. 48 | // (https://wiki.libsdl.org/SDL2/SDL_RenderGetD3D11Device) 49 | func (renderer *Renderer) GetD3D11Device() (device *ID3D11Device, err error) { 50 | device = (*ID3D11Device)(C.SDL_RenderGetD3D11Device(renderer.cptr())) 51 | if device == nil { 52 | err = GetError() 53 | } 54 | return 55 | } 56 | -------------------------------------------------------------------------------- /sdl/syswm_cocoa.go: -------------------------------------------------------------------------------- 1 | // +build cocoa OR darwin 2 | 3 | package sdl 4 | 5 | import "C" 6 | import "unsafe" 7 | 8 | // CocoaMsg contains Apple Mac OS X window information. 9 | type CocoaMsg struct { 10 | dummy C.int 11 | } 12 | 13 | // Cocoa() returns Apple Mac OS X message. 14 | func (msg *SysWMmsg) Cocoa() *CocoaMsg { 15 | return (*CocoaMsg)(unsafe.Pointer(&msg.data[0])) 16 | } 17 | -------------------------------------------------------------------------------- /sdl/syswm_dfb.go: -------------------------------------------------------------------------------- 1 | // +build dfb 2 | 3 | package sdl 4 | 5 | import "C" 6 | import "unsafe" 7 | 8 | // DFBMsg contains DirectFB window information. 9 | type DFBMsg struct { 10 | Event C.DFBEvent 11 | } 12 | 13 | // DFB() returns DirectFB message. 14 | func (msg *SysWMmsg) DFB() *DFBMsg { 15 | return (*DFBMsg)(unsafe.Pointer(&msg.data[0])) 16 | } 17 | -------------------------------------------------------------------------------- /sdl/syswm_uikit.go: -------------------------------------------------------------------------------- 1 | // +build uikit 2 | 3 | package sdl 4 | 5 | import "C" 6 | import "unsafe" 7 | 8 | // UIKitMsg contains Apple iOS window information. 9 | type UIKitMsg struct { 10 | dummy C.int 11 | } 12 | 13 | // UIKit() returns Apple iOS message. 14 | func (msg *SysWMmsg) UIKit() *UIKitMsg { 15 | return (*UIKitMsg)(unsafe.Pointer(&msg.data[0])) 16 | } 17 | -------------------------------------------------------------------------------- /sdl/syswm_vivante.go: -------------------------------------------------------------------------------- 1 | // +build vivante 2 | 3 | package sdl 4 | 5 | import "C" 6 | import "unsafe" 7 | 8 | // VivanteKitMsg contains Vivante window information. 9 | type VivanteKitMsg struct { 10 | dummy C.int 11 | } 12 | 13 | // Vivante() returns Vivante message. 14 | func (msg *SysWMmsg) Vivante() *VivanteMsg { 15 | return (*VivanteMsg)(unsafe.Pointer(&msg.data[0])) 16 | } 17 | -------------------------------------------------------------------------------- /sdl/syswm_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package sdl 4 | 5 | /* 6 | #include 7 | */ 8 | import "C" 9 | import "unsafe" 10 | 11 | // WindowsMsg contains Microsoft Windows window information. 12 | type WindowsMsg struct { 13 | Hwnd C.HWND 14 | Msg C.UINT 15 | WParam C.WPARAM 16 | LParam C.LPARAM 17 | } 18 | 19 | // Windows() returns Microsoft Windows message. 20 | func (msg *SysWMmsg) Windows() *WindowsMsg { 21 | return (*WindowsMsg)(unsafe.Pointer(&msg.data[0])) 22 | } 23 | -------------------------------------------------------------------------------- /sdl/syswm_x11.go: -------------------------------------------------------------------------------- 1 | // +build x11 2 | 3 | package sdl 4 | 5 | /* 6 | #include 7 | */ 8 | import "C" 9 | import "unsafe" 10 | 11 | // X11Msg contains X Window System window information. 12 | type X11Msg struct { 13 | Event C.XEvent 14 | } 15 | 16 | // X11() returns X Window System message. 17 | func (msg *SysWMmsg) X11() *X11Msg { 18 | return (*X11Msg)(unsafe.Pointer(&msg.data[0])) 19 | } 20 | -------------------------------------------------------------------------------- /sdl/thread.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | // #include "sdl_wrapper.h" 4 | import "C" 5 | 6 | // CurrentThreadID gets the thread identifier for the current thread. 7 | // (https://wiki.libsdl.org/SDL2/SDL_ThreadID) 8 | func CurrentThreadID() uint { 9 | return uint(C.SDL_ThreadID()) 10 | } 11 | -------------------------------------------------------------------------------- /sdl/timer.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !(SDL_VERSION_ATLEAST(2,0,18)) 7 | 8 | #if defined(WARN_OUTDATED) 9 | #pragma message("SDL_GetTicks64 is not supported before SDL 2.0.18") 10 | #endif 11 | 12 | static inline Uint64 SDL_GetTicks64(void) 13 | { 14 | return 0; 15 | } 16 | 17 | #endif 18 | */ 19 | import "C" 20 | 21 | // GetTicks returns the number of milliseconds since the SDL library initialization. 22 | // 23 | // Deprecated: This function is not recommended as of SDL 2.0.18; use GetTicks64() 24 | // instead, where the value doesn't wrap every ~49 days. There are places in 25 | // SDL where we provide a 32-bit timestamp that can not change without 26 | // breaking binary compatibility, though, so this function isn't officially 27 | // deprecated. 28 | // 29 | // (https://wiki.libsdl.org/SDL2/SDL_GetTicks) 30 | func GetTicks() uint32 { 31 | return uint32(C.SDL_GetTicks()) 32 | } 33 | 34 | // GetTicks64 returns the number of milliseconds since the SDL library initialization. 35 | // (https://wiki.libsdl.org/SDL2/SDL_GetTicks64) 36 | func GetTicks64() uint64 { 37 | return uint64(C.SDL_GetTicks64()) 38 | } 39 | 40 | // GetPerformanceCounter returns the current value of the high resolution counter. 41 | // (https://wiki.libsdl.org/SDL2/SDL_GetPerformanceCounter) 42 | func GetPerformanceCounter() uint64 { 43 | return uint64(C.SDL_GetPerformanceCounter()) 44 | } 45 | 46 | // GetPerformanceFrequency returns the count per second of the high resolution counter. 47 | // (https://wiki.libsdl.org/SDL2/SDL_GetPerformanceFrequency) 48 | func GetPerformanceFrequency() uint64 { 49 | return uint64(C.SDL_GetPerformanceFrequency()) 50 | } 51 | 52 | // Delay waits a specified number of milliseconds before returning. 53 | // (https://wiki.libsdl.org/SDL2/SDL_Delay) 54 | func Delay(ms uint32) { 55 | C.SDL_Delay(C.Uint32(ms)) 56 | } 57 | -------------------------------------------------------------------------------- /sdl/timer_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | // Both time.Sleep() and Delay() are only guaranteed to wait *at least* the 9 | // given duration, so all tests only check that time differentials are at least 10 | // a certain value. 11 | 12 | func TestGetTicks(t *testing.T) { 13 | before := GetTicks() 14 | ms := 1 15 | time.Sleep(time.Duration(ms) * time.Millisecond) 16 | after := GetTicks() 17 | if after-before < uint32(ms) { 18 | t.Errorf("GetTicks(): returned %d, then %d after %d ms", 19 | before, after, ms) 20 | } 21 | } 22 | 23 | func TestGetPerformance(t *testing.T) { 24 | freq := GetPerformanceFrequency() 25 | if freq <= 0 { 26 | t.Errorf("GetPerformanceFrequency(): returned %d", freq) 27 | } 28 | before := GetPerformanceCounter() 29 | ms := 10 30 | time.Sleep(time.Duration(ms) * time.Millisecond) 31 | after := GetPerformanceCounter() 32 | if after-before < freq*uint64(ms)/1000 { 33 | t.Errorf("GetPerformanceCounter(): returned %d, then %d after %d ms", 34 | before, after, ms) 35 | } 36 | } 37 | 38 | func TestDelay(t *testing.T) { 39 | for msDelay := 0; msDelay <= 20; msDelay += 10 { 40 | before := time.Now() 41 | Delay(uint32(msDelay)) 42 | msSince := time.Since(before) / time.Millisecond 43 | if int64(msSince) < int64(msDelay) { 44 | t.Errorf("Delay(%d): delayed for only %d ms", msDelay, msSince) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sdl/touch.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if !(SDL_VERSION_ATLEAST(2,0,10)) 7 | 8 | typedef enum 9 | { 10 | SDL_TOUCH_DEVICE_INVALID = -1, 11 | SDL_TOUCH_DEVICE_DIRECT, // touch screen with window-relative coordinates 12 | SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, // trackpad with absolute device coordinates 13 | SDL_TOUCH_DEVICE_INDIRECT_RELATIVE // trackpad with screen cursor-relative coordinates 14 | } SDL_TouchDeviceType; 15 | 16 | #if defined(WARN_OUTDATED) 17 | #pragma message("SDL_GetTouchDeviceType is not supported before SDL 2.0.10") 18 | #endif 19 | 20 | static inline SDL_TouchDeviceType SDL_GetTouchDeviceType(SDL_TouchID touchID) 21 | { 22 | return SDL_TOUCH_DEVICE_INVALID; 23 | } 24 | 25 | #endif 26 | 27 | */ 28 | import "C" 29 | import "unsafe" 30 | 31 | // TOUCH_MOUSEID is the device ID for mouse events simulated with touch input 32 | const TOUCH_MOUSEID = C.SDL_TOUCH_MOUSEID 33 | 34 | // TouchID is the ID of a touch device. 35 | type TouchID C.SDL_TouchID 36 | 37 | // FingerID is a finger id. 38 | type FingerID C.SDL_FingerID 39 | 40 | // TouchDeviceType is a touch device type. 41 | type TouchDeviceType C.SDL_TouchDeviceType 42 | 43 | const ( 44 | TOUCH_DEVICE_INVALID TouchDeviceType = C.SDL_TOUCH_DEVICE_INVALID 45 | TOUCH_DEVICE_DIRECT TouchDeviceType = C.SDL_TOUCH_DEVICE_DIRECT // touch screen with window-relative coordinates 46 | TOUCH_DEVICE_INDIRECT_ABSOLUTE TouchDeviceType = C.SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE // trackpad with absolute device coordinates 47 | TOUCH_DEVICE_INDIRECT_RELATIVE TouchDeviceType = C.SDL_TOUCH_DEVICE_INDIRECT_RELATIVE // trackpad with screen cursor-relative coordinates 48 | ) 49 | 50 | // Finger contains touch information. 51 | type Finger struct { 52 | ID FingerID // the finger id 53 | X float32 // the x-axis location of the touch event, normalized (0...1) 54 | Y float32 // the y-axis location of the touch event, normalized (0...1) 55 | Pressure float32 // the quantity of pressure applied, normalized (0...1) 56 | } 57 | 58 | func (t TouchID) c() C.SDL_TouchID { 59 | return C.SDL_TouchID(t) 60 | } 61 | 62 | // GetNumTouchDevices returns the number of registered touch devices. 63 | // (https://wiki.libsdl.org/SDL2/SDL_GetNumTouchDevices) 64 | func GetNumTouchDevices() int { 65 | return int(C.SDL_GetNumTouchDevices()) 66 | } 67 | 68 | // GetTouchDevice returns the touch ID with the given index. 69 | // (https://wiki.libsdl.org/SDL2/SDL_GetTouchDevice) 70 | func GetTouchDevice(index int) TouchID { 71 | return TouchID(C.SDL_GetTouchDevice(C.int(index))) 72 | } 73 | 74 | // GetTouchDeviceType returns the type of the given touch device. 75 | // (https://wiki.libsdl.org/SDL2/SDL_GetTouchDeviceType) 76 | func GetTouchDeviceType(id TouchID) TouchDeviceType { 77 | return TouchDeviceType(C.SDL_GetTouchDeviceType(C.SDL_TouchID(id))) 78 | } 79 | 80 | // GetNumTouchFingers returns the number of active fingers for a given touch device. 81 | // (https://wiki.libsdl.org/SDL2/SDL_GetNumTouchFingers) 82 | func GetNumTouchFingers(t TouchID) int { 83 | return int(C.SDL_GetNumTouchFingers(t.c())) 84 | } 85 | 86 | // GetTouchFinger returns the finger object for specified touch device ID and finger index. 87 | // (https://wiki.libsdl.org/SDL2/SDL_GetTouchFinger) 88 | func GetTouchFinger(t TouchID, index int) *Finger { 89 | return (*Finger)(unsafe.Pointer(C.SDL_GetTouchFinger(t.c(), C.int(index)))) 90 | } 91 | -------------------------------------------------------------------------------- /sdl/version.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | /* 4 | #include "sdl_wrapper.h" 5 | 6 | #if SDL_VERSION_ATLEAST(2,0,16) 7 | 8 | static inline int GetRevisionNumber(void) 9 | { 10 | return 0; 11 | } 12 | 13 | #else 14 | 15 | static inline int GetRevisionNumber(void) 16 | { 17 | return SDL_GetRevisionNumber(); 18 | } 19 | 20 | #endif 21 | */ 22 | import "C" 23 | import "unsafe" 24 | 25 | // The version of SDL in use. 26 | const ( 27 | MAJOR_VERSION = C.SDL_MAJOR_VERSION // major version 28 | MINOR_VERSION = C.SDL_MINOR_VERSION // minor version 29 | PATCHLEVEL = C.SDL_PATCHLEVEL // update version (patchlevel) 30 | ) 31 | 32 | // Version contains information about the version of SDL in use. 33 | // (https://wiki.libsdl.org/SDL2/SDL_version) 34 | type Version struct { 35 | Major uint8 // major version 36 | Minor uint8 // minor version 37 | Patch uint8 // update version (patchlevel) 38 | } 39 | type cVersion C.SDL_version 40 | 41 | func (v *Version) cptr() *C.SDL_version { 42 | return (*C.SDL_version)(unsafe.Pointer(v)) 43 | } 44 | 45 | // VERSION fills the selected struct with the version of SDL in use. 46 | // (https://wiki.libsdl.org/SDL2/SDL_VERSION) 47 | func VERSION(v *Version) { 48 | v.Major = MAJOR_VERSION 49 | v.Minor = MINOR_VERSION 50 | v.Patch = PATCHLEVEL 51 | } 52 | 53 | // VERSIONNUM converts separate version components into a single numeric value. 54 | // (https://wiki.libsdl.org/SDL2/SDL_VERSIONNUM) 55 | func VERSIONNUM(x, y, z int) int { 56 | return (x*1000 + y*100 + z) 57 | } 58 | 59 | // COMPILEDVERSION returns the SDL version number that you compiled against. 60 | // (https://wiki.libsdl.org/SDL2/SDL_COMPILEDVERSION) 61 | func COMPILEDVERSION() int { 62 | return VERSIONNUM(MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL) 63 | } 64 | 65 | // VERSION_ATLEAST reports whether the SDL version compiled against is at least as new as the specified version. 66 | // (https://wiki.libsdl.org/SDL2/SDL_VERSION_ATLEAST) 67 | func VERSION_ATLEAST(x, y, z int) bool { 68 | return COMPILEDVERSION() >= VERSIONNUM(x, y, z) 69 | } 70 | 71 | // GetVersion returns the version of SDL that is linked against your program. 72 | // (https://wiki.libsdl.org/SDL2/SDL_GetVersion) 73 | func GetVersion(v *Version) { 74 | C.SDL_GetVersion(v.cptr()) 75 | } 76 | 77 | // GetRevision returns the code revision of SDL that is linked against your program. 78 | // (https://wiki.libsdl.org/SDL2/SDL_GetRevision) 79 | func GetRevision() string { 80 | return (string)(C.GoString(C.SDL_GetRevision())) 81 | } 82 | 83 | // Deprecated: GetRevisionNumber is deprecated in SDL2 2.0.16 and will return 0. Users should use GetRevision instead. 84 | func GetRevisionNumber() int { 85 | return (int)(C.GetRevisionNumber()) 86 | } 87 | -------------------------------------------------------------------------------- /sdl/video_test.go: -------------------------------------------------------------------------------- 1 | package sdl 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestWindow(t *testing.T) { 8 | Do(func() { 9 | var window *Window 10 | var err error 11 | 12 | Init(INIT_EVERYTHING) 13 | defer Quit() 14 | 15 | if window, err = CreateWindow("Hello!", 100, 100, 800, 600, WINDOW_SHOWN); err != nil { 16 | t.Error(err) 17 | } 18 | defer window.Destroy() 19 | 20 | if title := window.GetTitle(); title != "Hello!" { 21 | t.Error("Window title is incorrect!") 22 | } 23 | 24 | if x, y := window.GetPosition(); x != 100 || y != 100 { 25 | t.Error("Window position is incorrect!") 26 | } 27 | 28 | if w, h := window.GetSize(); w != 800 || h != 600 { 29 | t.Error("Window size is incorrect!") 30 | } 31 | 32 | Delay(100) 33 | }) 34 | } 35 | -------------------------------------------------------------------------------- /ttf/sdl_ttf_cgo.go: -------------------------------------------------------------------------------- 1 | // +build !static 2 | 3 | package ttf 4 | 5 | //#cgo windows LDFLAGS: -lSDL2 -lSDL2_ttf 6 | //#cgo linux freebsd darwin pkg-config: SDL2_ttf 7 | //#cgo linux freebsd darwin LDFLAGS: -lSDL2_ttf 8 | import "C" 9 | -------------------------------------------------------------------------------- /ttf/sdl_ttf_cgo_static.go: -------------------------------------------------------------------------------- 1 | //go:build static 2 | // +build static 3 | 4 | package ttf 5 | 6 | //#cgo CFLAGS: -I${SRCDIR}/../_libs/include -I${SRCDIR}/../_libs/include/SDL2 7 | //#cgo LDFLAGS: -L${SRCDIR}/../_libs 8 | //#cgo linux,386 LDFLAGS: -lSDL2_ttf_linux_386 -Wl,--no-undefined -lfreetype_linux_386 -lSDL2_linux_386 -lm -ldl -lasound -lm -ldl -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 9 | //#cgo linux,amd64 LDFLAGS: -lSDL2_ttf_linux_amd64 -Wl,--no-undefined -lfreetype_linux_amd64 -lSDL2_linux_amd64 -lm -ldl -lasound -lm -ldl -lpthread -lX11 -lXext -lXcursor -lXinerama -lXi -lXrandr -lXss -lXxf86vm -lpthread -lrt 10 | //#cgo linux,mipsle LDFLAGS: -lSDL2_ttf_linux_mipsle -Wl,--no-undefined -lfreetype_linux_mipsle -lSDL2_linux_mipsle -lm -ldl 11 | //#cgo windows,386 LDFLAGS: -lSDL2_ttf_windows_386 -Wl,--no-undefined -lfreetype_windows_386 -lSDL2_windows_386 -lSDL2main_windows_386 -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -lrpcrt4 -static-libgcc 12 | //#cgo windows,amd64 LDFLAGS: -lSDL2_ttf_windows_amd64 -Wl,--no-undefined -lfreetype_windows_amd64 -lSDL2_windows_amd64 -lSDL2main_windows_amd64 -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -lsetupapi -lrpcrt4 -static-libgcc 13 | //#cgo darwin,amd64 LDFLAGS: -lSDL2_ttf_darwin_amd64 -lm -liconv -lfreetype_darwin_amd64 -lSDL2_darwin_amd64 -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,CoreVideo -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,Metal 14 | //#cgo android,arm LDFLAGS: -lSDL2_ttf_android_arm -Wl,--no-undefined -lfreetype_android_arm -lSDL2_android_arm -lm -ldl -llog -landroid -lGLESv2 -lGLESv1_CM 15 | //#cgo linux,arm,!android LDFLAGS: -L/opt/vc/lib -L/opt/vc/lib64 -lSDL2_ttf_linux_arm -Wl,--no-undefined -lfreetype_linux_arm -lSDL2_linux_arm -lm -ldl -liconv -lbcm_host -lvcos -lvchiq_arm -pthread 16 | import "C" 17 | -------------------------------------------------------------------------------- /ttf/sdl_ttf_test.go: -------------------------------------------------------------------------------- 1 | package ttf 2 | 3 | import ( 4 | "math/rand" 5 | "testing" 6 | 7 | "github.com/veandco/go-sdl2/sdl" 8 | ) 9 | 10 | var characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ `!@#$%^&*()-=~_+[]\\{}|;':\",./<>?" 11 | 12 | func randomString(t *testing.T) string { 13 | s := "" 14 | length := 16 + rand.Int()%16 15 | 16 | for i := 0; i < length; i++ { 17 | s += string(characters[rand.Int()%len(characters)]) 18 | } 19 | t.Log("text:", s) 20 | 21 | return s 22 | } 23 | 24 | func TestTTF(t *testing.T) { 25 | var font *Font 26 | var solid *sdl.Surface 27 | var err error 28 | 29 | if err := Init(); err != nil { 30 | t.Errorf("Failed to initialize TTF: %s\n", err) 31 | } 32 | 33 | if font, err = OpenFont("../.go-sdl2-examples/assets/test.ttf", 32); err != nil { 34 | t.Errorf("Failed to open font: %s\n", err) 35 | } 36 | defer font.Close() 37 | 38 | for i := 0; i < 10000; i++ { 39 | if solid, err = font.RenderUTF8Solid(randomString(t), sdl.Color{255, 0, 0, 255}); err != nil { 40 | t.Errorf("Failed to render text: %s\n", err) 41 | } 42 | defer solid.Free() 43 | } 44 | 45 | gm, err := font.GlyphMetrics('A') 46 | if err != nil { 47 | t.Errorf("Failed to get glyph metrics: %s\n", err) 48 | } 49 | expectMetrics := GlyphMetrics{0, 22, 0, 23, 22} 50 | if *gm != expectMetrics { 51 | t.Errorf("GlyphMetrics got %v - want %v", *gm, expectMetrics) 52 | } 53 | } 54 | 55 | func TestGlyphIsProvided(t *testing.T) { 56 | var font *Font 57 | var err error 58 | 59 | if err := Init(); err != nil { 60 | t.Errorf("Failed to initialize TTF: %s\n", err) 61 | } 62 | 63 | if font, err = OpenFont("../.go-sdl2-examples/assets/test.ttf", 32); err != nil { 64 | t.Errorf("Failed to open font: %s\n", err) 65 | } 66 | 67 | asciiRune := 'A' 68 | 69 | if !font.GlyphIsProvided(uint16(asciiRune)) { 70 | t.Errorf("GlyphIsProvided(): rune not found in font that includes glyph") 71 | } 72 | 73 | if !font.GlyphIsProvided32(uint32(asciiRune)) { 74 | t.Errorf("GlyphIsProvided32(): rune not found in font that includes glyph") 75 | } 76 | 77 | emojiRune := '🤖' 78 | 79 | if font.GlyphIsProvided(uint16(emojiRune)) { 80 | t.Errorf("GlyphIsProvided(): rune found in font that doesn't support emojis") 81 | } 82 | 83 | if font.GlyphIsProvided32(uint32(emojiRune)) { 84 | t.Errorf("GlyphIsProvided32(): rune found in font that doesn't support emojis") 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /ttf/sdl_ttf_wrapper.h: -------------------------------------------------------------------------------- 1 | #if defined(__WIN32) 2 | #include 3 | #include 4 | #else 5 | #include 6 | #endif 7 | --------------------------------------------------------------------------------