{"id":20502725,"url":"https://github.com/vlang/sdl","last_synced_at":"2026-02-09T11:02:22.291Z","repository":{"id":38198508,"uuid":"252179691","full_name":"vlang/sdl","owner":"vlang","description":"Official SDL2 \u0026 SDL3 bindings for V","archived":false,"fork":false,"pushed_at":"2026-02-01T21:43:18.000Z","size":4389,"stargazers_count":107,"open_issues_count":5,"forks_count":15,"subscribers_count":16,"default_branch":"master","last_synced_at":"2026-02-01T23:45:51.671Z","etag":null,"topics":["bindings","module","sdl","sdl2","sdl3","v","v-module","vlang","wrapper"],"latest_commit_sha":null,"homepage":"https://vlang.io","language":"V","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vlang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-04-01T13:14:17.000Z","updated_at":"2026-01-26T10:45:46.000Z","dependencies_parsed_at":"2023-01-22T03:15:10.352Z","dependency_job_id":"99e34359-f55a-4111-906f-c32deae674ec","html_url":"https://github.com/vlang/sdl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vlang/sdl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlang%2Fsdl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlang%2Fsdl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlang%2Fsdl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlang%2Fsdl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vlang","download_url":"https://codeload.github.com/vlang/sdl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vlang%2Fsdl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29262861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T04:11:57.159Z","status":"ssl_error","status_checked_at":"2026-02-09T04:11:56.117Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindings","module","sdl","sdl2","sdl3","v","v-module","vlang","wrapper"],"created_at":"2024-11-15T19:27:15.417Z","updated_at":"2026-02-09T11:02:22.282Z","avatar_url":"https://github.com/vlang.png","language":"V","readme":"# sdl\n\n`sdl` is a SDL V module and a wrapper around [libSDL](https://www.libsdl.org/).\nBoth SDL2 and SDL3 versions are supported through dedicated [branches](https://github.com/vlang/sdl/branches).\n\nThe module strives to support 100% of the SDL API.\n\nSo, among many other things, you can:\n- Open windows and accelerated rendering contexts\n- Render basic 2D graphics\n- Handle input events from keyboards, touches, mice, gamepads and joysticks\n- Play audio, sound effects and music\n\n## Project Navigation\n\nYou are currently reading the instructions for **SDL2**.\nFor SDL3 instructions, see the `README.md` in any of the `3.x.x` [branches](https://github.com/vlang/sdl/branches).\n\n## Install\n\nTo use `vlang/sdl` you need SDL2 libraries installed and the corresponding\n`vlang/sdl` *branch* checked out that *matches the SDL2 version installed* on the target system.\n\nSee [Dependencies](#Dependencies) section below for how to install SDL2\nfor different OSes and systems.\n\nIf you have SDL2 version `2.30.x` installed on your system you can simply do:\n```bash\nv install sdl\nv ~/.vmodules/sdl/setup.vsh\n```\n\nIf you want to use another version of SDL2 you will, currently, have to install\nit via `git` or by manual download.\n\nAn example of installing the system provided version of SDL2 via `git`:\n```bash\ngit clone https://github.com/vlang/sdl.git ~/.vmodules/sdl\nv ~/.vmodules/sdl/setup.vsh\n```\n\nShould `sdl2-config` be absent on your system you can try the following instead,\nby providing the version manually:\n\nAn example of installing the `2.0.12` branch (that *matches* SDL2 version 2.0.12) via `git`:\n```bash\ngit clone https://github.com/vlang/sdl.git ~/.vmodules/sdl\ncd ~/.vmodules/sdl\ngit checkout 2.0.12\n```\n... and for Windows in cmd.exe:\n```bash\ngit clone https://github.com/vlang/sdl.git %HOMEPATH%/.vmodules/sdl\ncd %HOMEPATH%/.vmodules/sdl\ngit checkout 2.0.12\n```\n... and for Windows in PowerShell (PS):\n```bash\ngit clone https://github.com/vlang/sdl.git \"$HOME/.vmodules/sdl\"\ncd \"$HOME/.vmodules/sdl\"\ngit checkout 2.0.12\n```\n\nThen follow the steps in the [Windows](#windows) section below.\n\nYou can see what `sdl` releases are available in the [GitHub repository](https://github.com/vlang/sdl/branches) via branches.\n\n## Notes\n\n### Versions\n\nSDL2 `v2.0.8` is currently the lowest version of SDL2 supported.\nSDL2 is backwards compatible - so anything written against `v2.0.8` can be compiled and run\nagainst newer versions of the SDL2 library.\n\nAlso note that SDL2 **is not** compatible with SDL `v1.x`.\nSDL2 is however compatible with SDL3 through the [`sdl2-compat`](https://github.com/libsdl-org/sdl2-compat) layer.\nWhich makes it possible to use the SDL2 API through the SDL3 libraries.\nYou can tell `sdl` to use this compatibility layer on systems that support `pkgconfig` by\npassing the compile time flag `-d sdl_compat` when building your `sdl`/SDL2 based V application.\n\n### Notes on garbage collection and memory issues\n\nCurrently, with some setups, SDL2 is known to trigger crashes when used in conjunction\nwith V's default garbage collector. Because of this you have to explicitly **opt-in**\nto use V's garbage collection with SDL2.\n\nIf you choose to use the garbage collector with SDL objects\n(by running apps importing `sdl` with `v -d sdl_use_gc run`)\nyou may experience runtime crashes and output similar to this:\n\n```\nmain__main: RUNTIME ERROR: invalid memory access\n```\n\nWe are tracking the issue here: https://github.com/vlang/sdl/issues/744\n\nThe crashes can be avoided by simply **not** passing `-d sdl_use_gc` and\nmanaging memory manually with SDL's memory functions like `sdl.free/1`, `sdl.malloc/1`,\n`sdl.calloc/2`, `sdl.realloc/2` and the various `create_*` and `destroy` functions.\n\n## Support\n\n`sdl` is currently supported on:\n- Linux\n- MacOS (via [homebrew](https://brew.sh/))\n- Windows\n\n## Examples\n\n[tVintris](examples/tvintris)\n\n![tVintris screenshot](/examples/assets/images/tvintris.png)\n\nYou can run the tVintris example like this :\n```\nv run sdl/examples/tvintris/tvintris.v\n```\n\n## Dependencies\n\n### Linux\n\n#### Fedora\n```bash\nsudo dnf install SDL2-devel SDL2_ttf-devel SDL2_mixer-devel SDL2_image-devel\n```\n#### Ubuntu\n```bash\nsudo apt install libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev\n```\n\n#### Arch\n```bash\nsudo pacman -S sdl2 sdl2_image sdl2_mixer sdl2_ttf\n```\n\n#### ClearLinux\n```bash\nsudo swupd bundle-add devpkg-SDL2_ttf devpkg-SDL2_mixer devpkg-SDL2_image\n```\n\n### MacOS\n\n#### Brew\n```bash\nbrew install sdl2 sdl2_gfx sdl2_ttf sdl2_mixer sdl2_image sdl2_net\n```\n\nIf you get no music with the above, try:\n```bash\nbrew reinstall --build-from-source --force sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf webp libtiff libmodplug libogg\n```\n\n### Windows\nIt is necessary to install the SDL2 development libraries for Windows.\n\nTo do this, run this in cmd.exe:\n```bash\ncd %HOMEPATH%\\.vmodules\\sdl\nv run windows_install_dependencies.vsh\n```\n\nIn Powershell, instead of the above, run this:\n```bash\ncd \"$HOME/.vmodules/sdl\"\nv run windows_install_dependencies.vsh\n```\n\nThis will create a directory called \"thirdparty\" which will be used to download and\nextract the required libraries. To successfully run a provided example or your own projects,\nthe sdl dlls must be copied to the main application directory. e.g.:\n```bash\ncopy thirdparty\\SDL2-2.30.0\\lib\\x64\\SDL2.dll examples\\basic_window\\\ncd ..\nv run sdl\\examples\\basic_window\\main.v\n```\n\n## Contributions\n\n- nsauzede\n- spytheman\n- adlesh\n- Larpon\n","funding_links":[],"categories":["Recently Updated","Libraries"],"sub_categories":["[Feb 28, 2025](/content/2025/02/28/README.md)","Graphics"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvlang%2Fsdl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvlang%2Fsdl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvlang%2Fsdl/lists"}