class Disp3D::GLUTWindow
Public Class Methods
new(width, height, title = "")
click to toggle source
Calls superclass method
Disp3D::GLView::new
# File lib/glut_window.rb, line 6 def initialize(width, height, title = "") x = 100 y = 100 GLUT.InitWindowPosition(x, y) GLUT.InitWindowSize(width, height) GLUT.InitDisplayMode(GLUT::GLUT_DOUBLE | GLUT::GLUT_RGB | GLUT::GLUT_DEPTH) GLUT.CreateWindow(title) GLUT.DisplayFunc(method(:gl_display).to_proc()) GLUT.ReshapeFunc(method(:reshape).to_proc()) GLUT.MouseFunc(method(:mouse).to_proc()) GLUT.MotionFunc(method(:motion).to_proc()) GLUT.PassiveMotionFunc(method(:motion).to_proc()) super(width, height) end
Public Instance Methods
gl_display()
click to toggle source
Calls superclass method
Disp3D::GLView#gl_display
# File lib/glut_window.rb, line 26 def gl_display super GLUT.SwapBuffers end
idle_process(wait_msec = nil) { || ... }
click to toggle source
# File lib/glut_window.rb, line 31 def idle_process(wait_msec = nil, &block) if(!wait_msec.nil?) new_block = lambda do @lasttime = Time.now if(@lasttime.nil?) interval = Time.now - @lasttime next if( interval < wait_msec/1000.0) yield @lasttime = Time.now end GLUT.IdleFunc(new_block) else GLUT.IdleFunc(block) end end
start()
click to toggle source
# File lib/glut_window.rb, line 46 def start fit GLUT.MainLoop() end
update()
click to toggle source
# File lib/glut_window.rb, line 22 def update gl_display end
Private Instance Methods
motion(x,y)
click to toggle source
# File lib/glut_window.rb, line 60 def motion(x,y) need_update = mouse_move_process(x, y) if(need_update) GLUT.PostRedisplay() end end
mouse(button,state,x,y)
click to toggle source
# File lib/glut_window.rb, line 52 def mouse(button,state,x,y) if(state == GLUT::GLUT_UP) mouse_release_process(button, x, y) elsif(state == GLUT::GLUT_DOWN) mouse_press_process(button, x, y) end end