项目作者: nilium

项目描述 :
GLFW 3 bindings for Ruby 2.x (Migrated to https://git.sr.ht/~nilium/ruby-glfw3)
高级语言: C
项目地址: git://github.com/nilium/ruby-glfw3.git
创建时间: 2013-06-21T23:15:22Z
项目社区:https://github.com/nilium/ruby-glfw3

开源协议:BSD 2-Clause "Simplified" License

下载


ruby-glfw3

  1. $ gem install glfw3

Intro

GLFW 3 bindings gem for Ruby 2.x.

To install the gem, you’ll need GLFW 3 built and installed where pkg-config can
find it. You may also want to grab some OpenGL bindings as well.

Once that’s taken care of, you can install it simply by installing the gem via RubyGems.org using

  1. $ gem install glfw3

Or by building and installing the gem, making note of the version so you know
the gem package to install, like so:

  1. $ gem build glfw3.gemspec
  2. $ gem install glfw3-VERSION-HERE.gemspec

After that, write a quick script to toy with it. For example:

  1. require 'glfw3'
  2. require 'opengl-core'
  3. # Initialize GLFW 3
  4. Glfw.init
  5. # Create a window
  6. window = Glfw::Window.new(800, 600, "Foobar")
  7. # Set some callbacks
  8. window.set_key_callback do |window, key, code, action, mods|
  9. window.should_close = true if key == Glfw::KEY_ESCAPE
  10. end
  11. window.set_close_callback do |window|
  12. window.should_close = true
  13. end
  14. # Make the window's context current
  15. window.make_context_current
  16. loop do
  17. # And do stuff
  18. Glfw.wait_events
  19. GL.glClear(GL::GL_COLOR_BUFFER_BIT | GL::GL_DEPTH_BUFFER_BIT)
  20. window.swap_buffers
  21. break if window.should_close?
  22. end
  23. # Explicitly destroy the window when done with it.
  24. window.destroy

License

ruby-glfw3 is licensed under a simplified BSD license because it seems the most
reasonable. If there’s a problem with that, let me know.

  1. Copyright (c) 2013, Noel Raymond Cower <ncower@gmail.com>.
  2. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. 1. Redistributions of source code must retain the above copyright notice, this
  6. list of conditions and the following disclaimer.
  7. 2. Redistributions in binary form must reproduce the above copyright notice,
  8. this list of conditions and the following disclaimer in the documentation
  9. and/or other materials provided with the distribution.
  10. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  11. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  12. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  13. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  14. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  15. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  16. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  19. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.