GithubHelp home page GithubHelp logo

rust-sdl2's Introduction

Rust-SDL2 Build Status

Bindings for SDL2 in Rust

Overview

Rust-SDL2 is a library for talking to the new SDL2.0 libraries from Rust. Low-level C components are wrapped in Rust code to make them more idiomatic and abstract away inappropriate manual memory management.

Rust-SDL2 uses the MIT license.

If you want a library compatible with earlier versions of SDL, please see https://github.com/brson/rust-sdl

Where are SDL_image, SDL_mixer, and SDL_ttf?

These live outside of the repo.

Requirements

Rust

We currently compile against the Master branch. I'd recommend using the Nightly installer, as that has the greatest chance of working.

SDL2.0 development libraries

Install these through your favourite package management tool, or via http://www.libsdl.org/

If you're running OSX, it's a good idea to install these via homebrew

brew install sdl2

If you're having issues, see here

Installation

If you're using cargo to manage your project, you can download through Crates.io:

    [dependencies]
    sdl2 = "0.0.15"

Alternatively, pull it from GitHub

    [dependencies.sdl2]
    git = "https://github.com/AngryLawyer/rust-sdl2"

Otherwise, clone this repo and run cargo

cargo build

Demo

We have some simple example projects included:

cargo run --example demo

cargo run --example audio-whitenoise

Some additional examples can be found in the rs-sdl2-examples repo.

OpenGL

If you want to use OpenGL, you also need the gl-rs package. If you're using cargo, just add these lines to your Cargo.toml:

    [dependencies.gl]
    git = "https://github.com/bjz/gl-rs"

Then you need to add this to add this initialization code to establish the bindings:

    gl::load_with(|s| unsafe {
        std::mem::transmute(sdl2::video::gl_get_proc_address(s))
    });

Note that these bindings are very raw, and many of the calls will require unsafe blocks.

When things go wrong

Rust, and Rust-SDL2, are both still heavily in development, and you may run into teething issues when using this. Before panicking, check that you're using the latest version of both Rust and Cargo, check that you've updated Rust-SDL2 to the latest version, and run cargo clean. If that fails, please let us know on the issue tracker.

rust-sdl2's People

Contributors

amaranth avatar andelf avatar angrylawyer avatar arjantopolovec avatar bitonic avatar bvssvni avatar caryhaynie avatar chuckries avatar cifram avatar darkspear7 avatar dcbishop avatar drbawb avatar eagleflo avatar eddyb avatar gekkio avatar gmorenz avatar indiv0 avatar jcmoyer avatar jhasse avatar koljakube avatar mvdnes avatar netvl avatar nukep avatar olsonjeffery avatar pcwalton avatar pnkfelix avatar reima avatar seemk avatar sp0 avatar zachreizner 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.