An object-oriented API for GLFW in Crystal.
GLFW is a razor-thin, cross-platform library for spinning up OpenGL contexts via windows as well as receiving user input and platform events. CrystGLFW provides an object-oriented API for the full GLFW specification, including window creation, working with multiple monitors, keyboard and joystick/controller input, idiomatic callbacks, and more.
The flexibility and portability of GLFW meets the speed and ease-of-use of Crystal. What a time to be alive!
CrystGLFW uses LibGLFW behind the scenes.
First, you'll want to make sure you've got GLFW3:
brew install glfw3
Add this to your application's shard.yml
:
dependencies:
crystglfw:
github: calebuharrison/CrystGLFW
branch: master
Install your dependencies:
shards install
require "crystglfw"
include CrystGLFW
# Initialize GLFW
CrystGLFW.run do
# Create a new window.
window = Window.new(title: "My First Window")
# Configure the window to print its dimensions each time it is resized.
window.on_resize do |event|
puts "Window resized to #{event.size}"
end
# Make this window's OpenGL context the current drawing context.
window.make_context_current
# Listen for callbacks and draw the window until it has been marked for closing.
until window.should_close?
CrystGLFW.wait_events
window.swap_buffers
end
# Destroy the window.
window.destroy
# Shut down and clean up GLFW.
end
CrystGLFW has much more to offer - check out the guides!
- Fork it ( https://github.com/calebuharrison/CrystGLFW/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- calebuharrison Caleb Uriah Harrison - creator, maintainer