GLApp – A tiny wrapper for ruby-opengl
It’s simple:
- require “gl_app”
- Include GLApp::Engine
class MyGame
include GLApp::Engine
<p>end
- Override as many of the callbacks as you need:
- setup
- update(seconds)
- draw
- keyboard_down(key, modifiers)
- keyboard_up(key, modifiers)
- special_keyboard_down(key, modifiers)
- special_keyboard_up(key, modifiers)
- mouse_click(button, state, x, y)
- mouse_dragging_motion(x, y)
- mouse_passive_motion(x, y)
- Instantiate GLApp with an instance of your engine, width, height and title, and do show.
app = GLApp.new(MyGame.new, 800, 600, "My game")
<p>app.show
- Done!
Look at the scripts in the examples/ directory. In fact, here’s one:
require ‘gl_app’ class MyGame include GLApp::Engine def draw glTranslate(0, 0, -5) glutSolidCube(2) end end app = GLApp.new(MyGame.new, 800, 600, “My game”) app.show