Coder Social home page Coder Social logo

glium-sdl2's Introduction

glium_sdl2

Build Status Latest Version

An SDL2 backend for Glium - a high-level OpenGL wrapper for the Rust language.

This library, along with glium and rust-sdl2, are in heavy development and are subject to change.

[dependencies]
glium_sdl2 = "0.12"
sdl2 = "0.19"
glium = "0.14"

features = []
default-features = false

glium_sdl2 doesn't reexport the glium or sdl2 crates, so you must declare them with the versions listed above in your Cargo.toml file.

glium_sdl2 will be bumped to 0.13, 0.14, etc. once this library, glium or sdl2 make breaking changes.

Example usage

Using glium with SDL2 is very similar to using glium with glutin. Generally speaking, Glium documentation and tutorials should be fairly trivial to adapt to SDL2.

#[macro_use]
extern crate glium;

extern crate glium_sdl2;
extern crate sdl2;

fn main() {
    use glium_sdl2::DisplayBuild;

    let sdl_context = sdl2::init().unwrap();
    let video_subsystem = sdl_context.video().unwrap();

    let display = video_subsystem.window("My window", 800, 600)
        .resizable()
        .build_glium()
        .unwrap();

    let mut running = true;
    let mut event_pump = sdl_context.event_pump().unwrap();

    while running {
        let mut target = display.draw();
        // do drawing here...
        target.finish().unwrap();

        // Event loop: includes all windows

        for event in event_pump.poll_iter() {
            use sdl2::event::Event;

            match event {
                Event::Quit { .. } => {
                    running = false;
                },
                _ => ()
            }
        }
    }
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

glium-sdl2's People

Contributors

cristicbz avatar michaelriss avatar nukep avatar robo-corg 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.