Class: RubyGL::DefaultSetup
- Inherits:
-
Object
- Object
- RubyGL::DefaultSetup
- Defined in:
- lib/rubygl/setup.rb
Instance Method Summary collapse
- #end_frame ⇒ Object
-
#initialize(args = {}) ⇒ DefaultSetup
constructor
The args hash accepts position and size values to be applied to the window.
- #show_dialog(title, message) ⇒ Object
- #teardown ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ DefaultSetup
The args hash accepts position and size values to be applied to the window. :x, :y, :width, :height
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubygl/setup.rb', line 9 def initialize(args = {}) RubyGL::Native.initWindow RubyGL::Native.initInput RubyGL::Native.loadLibrary(FFI::Pointer::NULL) RubyGL::Native.setAttribute(:context_major_version, 4) RubyGL::Native.setAttribute(:context_minor_version, 2) RubyGL::Native.setAttribute(:context_profile_mask, RubyGL::Native.CONTEXT_PROFILE_COMPATIBILITY) RubyGL::Native.setAttribute(:depth_size, 24) RubyGL::Native.setAttribute(:doublebuffer, 1) @window = RubyGL::Native.createWindow("RubyGL Window", args[:x] || 50, args[:y] || 50, args[:width] || 500, args[:height] || 500, RubyGL::Native.OPENGL) @context = RubyGL::Native.createContext(@window) RubyGL::Native.makeCurrent(@window, @context) RubyGL::Native.setSwapInterval(1) end |
Instance Method Details
#end_frame ⇒ Object
35 36 37 38 39 |
# File 'lib/rubygl/setup.rb', line 35 def end_frame() RubyGL::Native.swapWindow(@window) RubyGL::Native.pumpEvents() end |
#show_dialog(title, message) ⇒ Object
31 32 33 |
# File 'lib/rubygl/setup.rb', line 31 def show_dialog(title, ) RubyGL::Native.showSimpleMessageBox(0, title, , @window) end |
#teardown ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/rubygl/setup.rb', line 41 def teardown() RubyGL::Native.deleteContext(@context) RubyGL::Native.destroyWindow(@window) RubyGL::Native.unloadLibrary() RubyGL::Native.quitWindow() RubyGL::Native.quitInput() end |