sdl
sdl
The module strives to support 100% of the SDL2 API.
So, among many other things, you can:
- Open windows and accelerated rendering contexts
- Render basic 2D graphics
- Handle input events from keyboards, touches, mice, gamepads and joysticks
- Play audio, sound effects and music
Install
If you want to use SDL2
v2.0.8
If you want to use another version of SDL2 you will, currently, have to install
it via
git
An example of installing the system provided version of SDL2 via
git
Should
sdl2-config
An example of installing SDL2
v2.0.12
git
and for Windows:
Then follow the steps in the
Windows
You can see what
sdl
Also note that you'll need the SDL2 libraries available on your system
see the
Dependencies
Version notes
SDL2
v2.0.8
v2.0.8
Also note that SDL2
is not
v1.x
Notes on garbage collection and memory issues
Currently, with some setups, SDL2 is known to trigger crashes when used in conjunction
with V's default garbage collector. In these cases running apps importing
sdl
v run
main__main: RUNTIME ERROR: invalid memory access
We are tracking the issue here: https://github.com/vlang/sdl/issues/744
The crashes can be avoided by passing
-d sdl_memory_no_gc
import sdl
destroy
sdl.free/1
Support
sdl
- Linux
- MacOS (via
homebrew
) - Windows
Examples
You can run the tVintris example like this :
v run sdl/examples/tvintris/tvintris.v
Dependencies
Linux
Fedora
Ubuntu
Arch
ClearLinux
MacOS
Brew
If you get no music with the above, try:
Windows
It is necessary to install the sdl2 development libraries for Windows.
To do this, change to the root directory of the sdl module, like
cd %HOMEPATH%\.vmodules\sdl
v run windows_install_dependencies.vsh
Contributions
- nsauzede
- spytheman
- adlesh
- Larpon