Class: GLViewer::GL2DViewer

Inherits:
Object
  • Object
show all
Defined in:
lib/rglviewer/gl2dviewer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ GL2DViewer

Returns a new instance of GL2DViewer.



10
11
12
13
14
15
16
17
18
# File 'lib/rglviewer/gl2dviewer.rb', line 10

def initialize args = {}
	@width      = args[:width]  || 640
	@height     = args[:height] || 480
	@background = args[:background] || [255,255,255]
	@init       = args[:init]   || Proc.new {}
	@render     = args[:render] || Proc.new {}
	@width  = 1 if @width  <= 0
	@height = 1 if @height <= 0
end

Instance Attribute Details

#backgroundObject

Returns the value of attribute background.



8
9
10
# File 'lib/rglviewer/gl2dviewer.rb', line 8

def background
  @background
end

#heightObject

Returns the value of attribute height.



8
9
10
# File 'lib/rglviewer/gl2dviewer.rb', line 8

def height
  @height
end

#initObject

Returns the value of attribute init.



8
9
10
# File 'lib/rglviewer/gl2dviewer.rb', line 8

def init
  @init
end

#renderObject

Returns the value of attribute render.



8
9
10
# File 'lib/rglviewer/gl2dviewer.rb', line 8

def render
  @render
end

#widthObject

Returns the value of attribute width.



8
9
10
# File 'lib/rglviewer/gl2dviewer.rb', line 8

def width
  @width
end

Instance Method Details

#main_loopObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rglviewer/gl2dviewer.rb', line 22

def main_loop
	glutInit
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA )
	glutInitWindowSize(@width,@height)
	glutInitWindowPosition(0,0)
	@window = glutCreateWindow("RGLViewer")
	glutDisplayFunc(method(:gl_draw).to_proc)
	glutIdleFunc(method(:gl_idle).to_proc)
	glutReshapeFunc(method(:gl_reshape).to_proc)

	gl_init

	glutMainLoop
end