Parent

RubyGL::DefaultSetup

Public Class Methods

new(args = {}) click to toggle source

The args hash accepts position and size values to be applied to the window. :x, :y, :width, :height

# 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

Public Instance Methods

end_frame() click to toggle source
# File lib/rubygl/setup.rb, line 37
def end_frame()
    RubyGL::Native.swapWindow(@window)
    
    RubyGL::Native.pumpEvents()
end
show_dialog(title, message) click to toggle source
# File lib/rubygl/setup.rb, line 33
def show_dialog(title, message)
    RubyGL::Native.showSimpleMessageBox(0, title, message, @window)
end
teardown() click to toggle source
# 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.