lib_glfw

Build Status

Library to expose the GLFW API to Crystal. This is a direct mapping of glfw3.h found here. The current GLFW version is 3.2.1.

Resleases of this shard are made according to the following format: [GLFW version].[shard version]

Installation

Add this to your application's shard.yml:

dependencies:
  lib_glfw:
    github: lirith-engine/lib_glfw

Install GLFW trough homebrew brew install glfw3

Usage

require "lib_glfw"

LibGLFW.init
handle = LibGLFW.create_window(1920, 1080, "GLFW Window", nil, nil)
LibGLFW.make_context_current handle

# callbacks are supported trough procs:
def handle_key(window : LibGLFW::Window*, key : Int32, scancode : Int32, action : Int32, mods : Int32) : Void
  # Do things width the key
end

LibGLFW.set_key_callback(handle, ->handle_key(LibGLFW::Window*, Int32, Int32, Int32, Int32))

loop do
  LibGLFW.poll_events
  LibGLFW.swap_buffers handle
end

LibGLFW.terminate

All the methods have the same name as the source but with a few key differences:

Notes

Currently only the glfw3 core is supported. Extra's like vulkan support are yet to come.

Contributing

  1. Fork it ( https://github.com/lirith-engine/lib_glfw/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors