Giter Site home page Giter Site logo

vsdl's Introduction

VSDL

VSDL is a work-in-progress V wrapper for the C-based SDL library. The aim of this library is to provide a thorough implementation of SDL2 in V. The implementation is faithful to the original API but takes some liberties to provide a native "V" feel.

'Image' Example

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 files with 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, run:

apt install libsdl2{,-image,-mixer,-ttf}-dev zlib1g-dev libfreetype6-dev

On MacOS install SDL2 via Homebrew:

brew install sdl2{,-image,-mixer,-ttf}

On Windows,

  1. Download the runtime binaries from SDL2
  1. 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 necessary to get the Image, Mixer or TTF library runtimes if you do not plan to use them in your application.

By default VSDL only initializes the subsystems that are imported. For example, importing just vsdl only initializes the main SDL2 system, giving you limited access to SDL2 base functionality. The video or audio subsystems are only initialized when vsdl.gfx or vsdl.audio are imported. This allows you to only activate the subsystems that are important to your project.

If an extension library is loaded (vsdl.image, vsdl.mixer, vsdl.ttf), the required runtime binaries must be installed or provided along with the build.

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!

vsdl's People

Contributors

kjlaw89 avatar klawrence-fs avatar spytheman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.