VSDL
VSDL is a work-in-progress V wrapper for the C-based
SDL library
Features
-
gfx
- window management
- renderer
- texture
- surface
- rect
- gl hook
- vulkan hook (untested)
- pixel formats
-
events
- basic event handling
- subscribed events
-
input
- keyboard
- mouse
-
controller
- joysticks
- game controllers
- sensors
- haptics
- audio
- ttf
- mixer
-
image
- load
- file type
- network
- concurrency/threading
- RWops
Example
module main
import vsdl
import vsdl.events
import vsdl.gfx
fn main() {
mut window := gfx.create_window("Simple VSDL Window", -1, -1, 640, 480, .shown)?
surface := window.get_surface()?
surface.fill(r: 255, g: 255, b: 255)
defer {
surface.free()
window.destroy()
vsdl.quit()
}
window.update()
events.loop()
}
See the examples folder for more examples. Run any
.v
v run [file]
Requirements
The SDL2 headers come pre-included with this repo. To run the only thing needed are the runtime binaries.
On
Ubuntu 14.04 and above
apt install libsdl2{,-image,-mixer,-ttf}-dev zlib1g-dev libfreetype6-dev
On
MacOS
brew install sdl2{,-image,-mixer,-ttf}
On
Windows
- Download the runtime binaries from SDL2
- SDL2 Runtime Binaries
-
SDL2 Image Runtime Binaries
(optional) -
SDL2 Mixer Runtime Binaries
(optional) -
SDL2 TTF Runtime Binaries
(optional)
- Extract the binaries to the folder where your executable resides
Notes about dependencies
This repo comes with a copy of the headers for the version of SDL2 that it was developed against (2.0.12), but does not ship with the runtime libraries. It is
not
By default VSDL only initializes the subsystems that are imported. For example, importing just
vsdl
video
audio
vsdl.gfx
vsdl.audio
If an extension library is loaded (
vsdl.image
vsdl.mixer
vsdl.ttf
Contributing / Support
This project was developed as a way of improving my understanding of V & C. I will not be providing active support for the project, but I'll happily accept any pull requests. Use at your own discretion!