GithubHelp home page GithubHelp logo

arkoh / glfw-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pistondevelopers/glfw-rs

0.0 2.0 0.0 732 KB

GLFW3 bindings and ideomatic wrapper for Rust.

License: Apache License 2.0

Rust 100.00%

glfw-rs's Introduction

glfw-rs

GLFW bindings and wrapper for The Rust Programming Language.

Example code

extern mod native;
extern mod glfw;

#[start]
fn start(argc: int, argv: **u8) -> int {
    // Run GLFW on the main thread
    native::start(argc, argv, main)
}

fn main() {
    // Set up an error callback
    glfw::set_error_callback(~ErrorContext);

    // Initialize the library
    do glfw::start {
        // Create a windowed mode window and its OpenGL context
        let window = glfw::Window::create(300, 300, "Hello this is window", glfw::Windowed)
            .expect("Failed to create GLFW window.");

        // Make the window's context current
        window.make_context_current();

        // Loop until the user closes the window
        while !window.should_close() {
            // Swap front and back buffers
            window.swap_buffers();

            // Poll for and process events
            glfw::poll_events();
        }
    }
}

struct ErrorContext;
impl glfw::ErrorCallback for ErrorContext {
    fn call(&self, _: glfw::Error, description: ~str) {
        println!("GLFW Error: {:s}", description);
    }
}

Compilation

You will need CMake to set up glfw-rs for building.

First setup your build directory:

git clone https://github.com/bjz/glfw-rs.git
cd glfw-rs
mkdir build
cd build
cmake ..

Building everything

make 

Building the library

make lib

Building the examples

make examples

Or to build a single example:

make <example-name>

FAQ

I get lots of errors like: undefined reference to 'glfwSetScrollCallback'

glfw-rs wraps glfw 3.0. Version 2.7 was out for a long time, and may still be hanging around on package managers. If you encounter these kinds of errors, make sure you version of glfw is up to date.

Ok, so I have windowing sorted, now where do I find OpenGL?

You can use the function pointer loader, gl-rs, or the OpenGL-ES bindings.

glfw-rs in use

Support

Contact bjz on irc.mozilla.org #rust and #rust-gamedev, or post an issue on Github.

glfw-rs's People

Contributors

brendanzab avatar sebcrozet avatar alegalle avatar larsbergstrom avatar kimundi avatar metajack avatar h3r2tic avatar rubber-duck avatar luqmana avatar kmcallister avatar emberian avatar csherratt avatar brson avatar ameyp avatar dustinlacewell avatar jhasse avatar rlane avatar torwegia avatar jmgrosen avatar phillipwalters avatar zofrex avatar

Watchers

James Cloos 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.