- extern crate gl;
- extern crate glfw;
- use glfw::{Context, OpenGlProfileHint, WindowHint, WindowMode};
- fn main() {
- let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
- // Choose a GL profile that is compatible with OS X 10.7+
- glfw.window_hint(WindowHint::ContextVersion(3, 2));
- glfw.window_hint(WindowHint::OpenglForwardCompat(true));
- glfw.window_hint(WindowHint::OpenglProfile(OpenGlProfileHint::Core));
- let (window, _) = glfw.create_window(800, 600, "OpenGL", WindowMode::Windowed)
- .expect("Failed to create GLFW window.");
- // It is essential to make the context current before calling `gl::load_with`.
- window.make_current();
- // Load the OpenGL function pointers
- gl::load_with(|s| window.get_proc_address(s));
- while !window.should_close() {
- // Poll events
- glfw.poll_events();
- // Clear the screen to black
- unsafe {
- gl::ClearColor(0.3, 0.3, 0.3, 1.0);
- gl::Clear(gl::COLOR_BUFFER_BIT);
- }
- // Swap buffers
- window.swap_buffers();
- }
- }
SHARE
TWEET
Untitled
a guest
Jan 24th, 2015
212
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

