SHARE
TWEET

Untitled

a guest Jan 24th, 2015 212 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extern crate gl;
  2. extern crate glfw;
  3.  
  4. use glfw::{Context, OpenGlProfileHint, WindowHint, WindowMode};
  5.  
  6. fn main() {
  7.     let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
  8.  
  9.     // Choose a GL profile that is compatible with OS X 10.7+
  10.     glfw.window_hint(WindowHint::ContextVersion(3, 2));
  11.     glfw.window_hint(WindowHint::OpenglForwardCompat(true));
  12.     glfw.window_hint(WindowHint::OpenglProfile(OpenGlProfileHint::Core));
  13.  
  14.     let (window, _) = glfw.create_window(800, 600, "OpenGL", WindowMode::Windowed)
  15.         .expect("Failed to create GLFW window.");
  16.  
  17.     // It is essential to make the context current before calling `gl::load_with`.
  18.     window.make_current();
  19.  
  20.     // Load the OpenGL function pointers
  21.     gl::load_with(|s| window.get_proc_address(s));
  22.  
  23.     while !window.should_close() {
  24.         // Poll events
  25.         glfw.poll_events();
  26.  
  27.         // Clear the screen to black
  28.         unsafe {
  29.             gl::ClearColor(0.3, 0.3, 0.3, 1.0);
  30.             gl::Clear(gl::COLOR_BUFFER_BIT);
  31.         }
  32.  
  33.         // Swap buffers
  34.         window.swap_buffers();
  35.     }
  36. }
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. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top