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 30 31 |
# File 'lib/rubygl/setup.rb', line 9 def initialize(args = {}) RubyGL::Native.initWindow RubyGL::Native.initInput RubyGL::Native.loadLibrary(FFI::Pointer::NULL) # Dont Try To Guess User's OpenGL Version Even If SDL Want Us To Specify # It. I Have Not Seen Context Creation Fail Because Of Not Calling This. #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
37 38 39 40 41 |
# File 'lib/rubygl/setup.rb', line 37 def end_frame() RubyGL::Native.swapWindow(@window) RubyGL::Native.pumpEvents() end |
#show_dialog(title, message) ⇒ Object
33 34 35 |
# File 'lib/rubygl/setup.rb', line 33 def show_dialog(title, ) RubyGL::Native.showSimpleMessageBox(0, title, , @window) end |
#teardown ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/rubygl/setup.rb', line 43 def teardown() RubyGL::Native.deleteContext(@context) RubyGL::Native.destroyWindow(@window) RubyGL::Native.unloadLibrary() # Segmentation fault On MacOSX When Called #RubyGL::Native.quitWindow() RubyGL::Native.quitInput() end |