Class: Disp3D::GLUTWindow

Inherits:
GLView
  • Object
show all
Defined in:
lib/glut_window.rb

Instance Attribute Summary

Attributes inherited from GLView

#bk_color, #camera, #camera_scene_graph, #light, #manipulator, #picker, #world_scene_graph

Instance Method Summary collapse

Methods inherited from GLView

#capture, #centering, #fit, #gl_display_camera_scene_graph, #gl_display_world_scene_graph, #mouse_move, #mouse_move_process, #mouse_press, #mouse_press_process, #mouse_release, #mouse_release_process, #reshape, #sync_to

Constructor Details

#initialize(width, height, title = "") ⇒ GLUTWindow

Returns a new instance of GLUTWindow.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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

Instance Method Details

#gl_displayObject



26
27
28
29
# File 'lib/glut_window.rb', line 26

def gl_display
  super
  GLUT.SwapBuffers
end

#idle_process(wait_msec = nil, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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

#startObject



46
47
48
49
# File 'lib/glut_window.rb', line 46

def start
  fit
  GLUT.MainLoop()
end

#updateObject



22
23
24
# File 'lib/glut_window.rb', line 22

def update
  gl_display
end