opengl 0.7.0.pre1-x86-mingw32 → 0.7.0.pre2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +29 -0
- data/.gitignore +5 -8
- data/History.rdoc +33 -0
- data/Manifest.txt +72 -57
- data/README.rdoc +72 -25
- data/Rakefile +60 -72
- data/Rakefile.cross +5 -2
- data/{doc → docs}/build_install.txt +0 -0
- data/{doc → docs}/extensions.txt.in +0 -0
- data/{doc → docs}/history.txt +0 -0
- data/{doc → docs}/requirements_and_design.txt +0 -0
- data/{doc → docs}/roadmap.txt +0 -0
- data/{doc → docs}/scientific_use.txt +0 -0
- data/{doc → docs}/supplies/page_template.html +0 -0
- data/{doc → docs}/thanks.txt +0 -0
- data/{doc → docs}/tutorial.txt +0 -0
- data/examples/NeHe/NeHe.png +0 -0
- data/examples/NeHe/crate.png +0 -0
- data/examples/NeHe/glass.png +0 -0
- data/examples/NeHe/nehe_lesson02.rb +82 -83
- data/examples/NeHe/nehe_lesson03.rb +88 -88
- data/examples/NeHe/nehe_lesson04.rb +93 -96
- data/examples/NeHe/nehe_lesson05.rb +137 -144
- data/examples/NeHe/nehe_lesson06.rb +183 -0
- data/examples/NeHe/nehe_lesson07.rb +237 -0
- data/examples/NeHe/nehe_lesson08.rb +252 -0
- data/examples/NeHe/nehe_lesson09.rb +199 -0
- data/examples/NeHe/nehe_lesson11.rb +173 -0
- data/examples/NeHe/nehe_lesson12.rb +200 -0
- data/examples/NeHe/nehe_lesson16.rb +208 -0
- data/examples/NeHe/nehe_lesson19.rb +206 -0
- data/examples/NeHe/particle.png +0 -0
- data/examples/NeHe/star.png +0 -0
- data/examples/NeHe/tim.png +0 -0
- data/examples/RedBook/light.rb +154 -0
- data/examples/misc/OGLBench.rb +2 -2
- data/examples/misc/trislam.rb +2 -2
- data/ext/{common → opengl}/common.h +2 -11
- data/ext/{common → opengl}/conv.h +43 -31
- data/ext/{glut → opengl}/extconf.rb +14 -7
- data/ext/{common → opengl}/funcdef.h +155 -125
- data/ext/{gl → opengl}/gl-1.0-1.1.c +426 -162
- data/ext/{gl → opengl}/gl-1.2.c +70 -66
- data/ext/{gl → opengl}/gl-1.3.c +19 -19
- data/ext/{gl → opengl}/gl-1.4.c +23 -23
- data/ext/{gl → opengl}/gl-1.5.c +46 -47
- data/ext/{gl → opengl}/gl-2.0.c +66 -60
- data/ext/{gl → opengl}/gl-2.1.c +4 -4
- data/ext/{gl → opengl}/gl-enums.c +2 -1
- data/ext/{common → opengl}/gl-enums.h +0 -0
- data/ext/{gl → opengl}/gl-error.c +12 -4
- data/ext/{common → opengl}/gl-error.h +7 -2
- data/ext/{gl → opengl}/gl-ext-3dfx.c +1 -1
- data/ext/{gl → opengl}/gl-ext-arb.c +75 -70
- data/ext/{gl → opengl}/gl-ext-ati.c +3 -3
- data/ext/{gl → opengl}/gl-ext-ext.c +54 -54
- data/ext/{gl → opengl}/gl-ext-gremedy.c +3 -3
- data/ext/{gl → opengl}/gl-ext-nv.c +49 -48
- data/ext/{common → opengl}/gl-types.h +0 -0
- data/ext/{gl → opengl}/gl.c +8 -10
- data/ext/{glu → opengl}/glu-enums.c +1 -1
- data/ext/{common → opengl}/glu-enums.h +0 -0
- data/ext/{glu → opengl}/glu.c +7 -3
- data/ext/{glut → opengl}/glut.c +98 -48
- data/ext/opengl/opengl.c +11 -0
- data/lib/gl.rb +1 -0
- data/lib/glu.rb +1 -0
- data/lib/glut.rb +1 -0
- data/lib/opengl.rb +13 -14
- data/lib/opengl/opengl.so +0 -0
- data/lib/opengl/test_case.rb +87 -0
- data/test/{tc_misc.rb → test_gl.rb} +2 -14
- data/test/test_gl_10_11.rb +1363 -0
- data/test/test_gl_12.rb +182 -0
- data/test/{tc_func_13.rb → test_gl_13.rb} +14 -14
- data/test/test_gl_14.rb +221 -0
- data/test/test_gl_15.rb +260 -0
- data/test/test_gl_20.rb +430 -0
- data/test/test_gl_21.rb +553 -0
- data/test/test_gl_ext_arb.rb +526 -0
- data/test/{tc_ext_ati.rb → test_gl_ext_ati.rb} +11 -14
- data/test/test_gl_ext_ext.rb +608 -0
- data/test/{tc_ext_gremedy.rb → test_gl_ext_gremedy.rb} +6 -6
- data/test/test_gl_ext_nv.rb +352 -0
- data/test/test_glu.rb +309 -0
- metadata +159 -102
- data/History.txt +0 -36
- data/ext/gl/extconf.rb +0 -43
- data/ext/glu/extconf.rb +0 -51
- data/test/README +0 -10
- data/test/tc_common.rb +0 -98
- data/test/tc_ext_arb.rb +0 -467
- data/test/tc_ext_ext.rb +0 -551
- data/test/tc_ext_nv.rb +0 -357
- data/test/tc_func_10_11.rb +0 -1281
- data/test/tc_func_12.rb +0 -186
- data/test/tc_func_14.rb +0 -197
- data/test/tc_func_15.rb +0 -270
- data/test/tc_func_20.rb +0 -346
- data/test/tc_func_21.rb +0 -541
- data/test/tc_glu.rb +0 -310
- data/test/tc_include_gl.rb +0 -35
- data/test/tc_require_gl.rb +0 -34
@@ -1,13 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby -rubygems
|
2
2
|
# Name: nehe_lesson04.rb
|
3
3
|
# Purpose: An implementation of NeHe's OpenGL Lesson #04
|
4
|
-
# using ruby-opengl
|
5
|
-
#
|
4
|
+
# using ruby-opengl http://nehe.gamedev.net/
|
6
5
|
|
7
|
-
require
|
8
|
-
require "glu"
|
9
|
-
require "glut"
|
10
|
-
require "mathn"
|
6
|
+
require 'opengl'
|
11
7
|
|
12
8
|
# Add GL and GLUT namespaces in to make porting easier
|
13
9
|
include Gl
|
@@ -16,118 +12,119 @@ include Glut
|
|
16
12
|
|
17
13
|
# Placeholder for the window object
|
18
14
|
$window = ""
|
19
|
-
# Angle for the triangle
|
15
|
+
# Angle for the triangle Global
|
20
16
|
$triangle_angle = 0
|
21
|
-
# Angle for the quadrilateral
|
17
|
+
# Angle for the quadrilateral Global
|
22
18
|
$quad_angle = 0
|
23
19
|
|
24
|
-
def init_gl_window
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
20
|
+
def init_gl_window width = 640, height = 480
|
21
|
+
# Background color to black
|
22
|
+
glClearColor 0.0, 0.0, 0.0, 0
|
23
|
+
# Enables clearing of depth buffer
|
24
|
+
glClearDepth 1.0
|
25
|
+
# Set type of depth test
|
26
|
+
glDepthFunc GL_LEQUAL
|
27
|
+
# Enable depth testing
|
28
|
+
glEnable GL_DEPTH_TEST
|
29
|
+
# Enable smooth color shading
|
30
|
+
glShadeModel GL_SMOOTH
|
31
|
+
|
32
|
+
glMatrixMode GL_PROJECTION
|
33
|
+
glLoadIdentity
|
34
|
+
# Calculate aspect ratio of the window
|
35
|
+
gluPerspective 45.0, width / height, 0.1, 100.0
|
36
|
+
|
37
|
+
glMatrixMode GL_MODELVIEW
|
38
|
+
|
39
|
+
draw_gl_scene
|
44
40
|
end
|
45
41
|
|
46
42
|
#reshape = Proc.new do |width, height|
|
47
|
-
def reshape
|
48
|
-
|
43
|
+
def reshape width, height
|
44
|
+
height = 1 if height == 0
|
49
45
|
|
50
|
-
|
51
|
-
|
46
|
+
# Reset current viewpoint and perspective transformation
|
47
|
+
glViewport 0, 0, width, height
|
52
48
|
|
53
|
-
|
54
|
-
|
49
|
+
glMatrixMode GL_PROJECTION
|
50
|
+
glLoadIdentity
|
55
51
|
|
56
|
-
|
52
|
+
gluPerspective 45.0, width / height, 0.1, 100.0
|
57
53
|
end
|
58
54
|
|
59
55
|
#draw_gl_scene = Proc.new do
|
60
56
|
def draw_gl_scene
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
57
|
+
# Clear the screen and depth buffer
|
58
|
+
glClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
|
59
|
+
|
60
|
+
# Reset the view
|
61
|
+
glMatrixMode GL_MODELVIEW
|
62
|
+
glLoadIdentity
|
63
|
+
|
64
|
+
# Move left 1.5 units and into the screen 6.0 units
|
65
|
+
glTranslatef -1.5, 0.0, -6.0
|
66
|
+
|
67
|
+
# Rotate the triangle on the Y-axis
|
68
|
+
glRotatef $triangle_angle, 0.0, 1.0, 0.0
|
69
|
+
# Draw a triangle
|
70
|
+
glBegin GL_POLYGON do
|
71
|
+
glColor3f 1.0, 0.0, 0.0
|
72
|
+
glVertex3f 0.0, 1.0, 0.0
|
73
|
+
glColor3f 0.0, 1.0, 0.0
|
74
|
+
glVertex3f 1.0, -1.0, 0.0
|
75
|
+
glColor3f 0.0, 0.0, 1.0
|
76
|
+
glVertex3f -1.0, -1.0, 0.0
|
77
|
+
end
|
78
|
+
|
79
|
+
# Move right 3 units
|
80
|
+
glLoadIdentity
|
81
|
+
glTranslatef 1.5, 0.0, -6.0
|
82
|
+
|
83
|
+
# Draw a quadrilateral
|
84
|
+
# Rotate the quad on the X-axis
|
85
|
+
glRotatef $quad_angle, 1.0, 0.0, 0.0
|
86
|
+
# Set it to a blue color one time only
|
87
|
+
glColor3f 0.5, 0.5, 1.0
|
88
|
+
glBegin GL_QUADS do
|
89
|
+
glVertex3f -1.0, 1.0, 0.0
|
90
|
+
glVertex3f 1.0, 1.0, 0.0
|
91
|
+
glVertex3f 1.0, -1.0, 0.0
|
92
|
+
glVertex3f -1.0, -1.0, 0.0
|
93
|
+
end
|
94
|
+
|
95
|
+
$triangle_angle += 0.2
|
96
|
+
$quad_angle -= 0.15
|
97
|
+
|
98
|
+
# Swap buffers for display
|
99
|
+
glutSwapBuffers
|
103
100
|
end
|
104
101
|
|
105
|
-
# The idle function to handle
|
102
|
+
# The idle function to handle
|
106
103
|
def idle
|
107
|
-
|
104
|
+
glutPostRedisplay
|
108
105
|
end
|
109
106
|
|
110
107
|
# Keyboard handler to exit when ESC is typed
|
111
108
|
keyboard = lambda do |key, x, y|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
109
|
+
case key
|
110
|
+
when ?\e
|
111
|
+
glutDestroyWindow $window
|
112
|
+
exit 0
|
113
|
+
end
|
114
|
+
glutPostRedisplay
|
118
115
|
end
|
119
116
|
|
120
117
|
|
121
118
|
# Initliaze our GLUT code
|
122
|
-
glutInit
|
119
|
+
glutInit
|
123
120
|
# Setup a double buffer, RGBA color, alpha components and depth buffer
|
124
|
-
glutInitDisplayMode
|
125
|
-
glutInitWindowSize
|
126
|
-
glutInitWindowPosition
|
127
|
-
$window = glutCreateWindow
|
128
|
-
glutDisplayFunc
|
129
|
-
glutReshapeFunc
|
130
|
-
glutIdleFunc
|
131
|
-
glutKeyboardFunc
|
132
|
-
init_gl_window
|
133
|
-
glutMainLoop
|
121
|
+
glutInitDisplayMode GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH
|
122
|
+
glutInitWindowSize 640, 480
|
123
|
+
glutInitWindowPosition 0, 0
|
124
|
+
$window = glutCreateWindow "NeHe Lesson 04 - ruby-opengl version"
|
125
|
+
glutDisplayFunc :draw_gl_scene
|
126
|
+
glutReshapeFunc :reshape
|
127
|
+
glutIdleFunc :idle
|
128
|
+
glutKeyboardFunc keyboard
|
129
|
+
init_gl_window 640, 480
|
130
|
+
glutMainLoop
|
@@ -1,186 +1,179 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
require 'opengl'
|
2
|
+
|
3
|
+
class Lesson05
|
4
|
+
include Gl
|
5
|
+
include Glu
|
6
|
+
include Glut
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@pyramid_angle = 0
|
10
|
+
@cube_angle = 0
|
11
|
+
|
12
|
+
# Initliaze our GLUT code
|
13
|
+
glutInit
|
14
|
+
# Setup a double buffer, RGBA color, alpha components and depth buffer
|
15
|
+
glutInitDisplayMode GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH
|
16
|
+
glutInitWindowSize 640, 480
|
17
|
+
glutInitWindowPosition 0, 0
|
18
|
+
@window = glutCreateWindow "NeHe Lesson 05 - ruby-opengl version"
|
19
|
+
glutDisplayFunc :draw_gl_scene
|
20
|
+
glutReshapeFunc :reshape
|
21
|
+
glutIdleFunc :idle
|
22
|
+
glutKeyboardFunc :keyboard
|
23
|
+
init_gl_window 640, 480
|
24
|
+
glutMainLoop
|
25
|
+
end
|
26
|
+
|
27
|
+
def init_gl_window width = 640, height = 480
|
25
28
|
# Background color to black
|
26
|
-
glClearColor
|
29
|
+
glClearColor 0.0, 0.0, 0.0, 0
|
27
30
|
# Enables clearing of depth buffer
|
28
|
-
glClearDepth
|
31
|
+
glClearDepth 1.0
|
29
32
|
# Set type of depth test
|
30
|
-
glDepthFunc
|
33
|
+
glDepthFunc GL_LEQUAL
|
31
34
|
# Enable depth testing
|
32
|
-
glEnable
|
35
|
+
glEnable GL_DEPTH_TEST
|
33
36
|
# Enable smooth color shading
|
34
|
-
glShadeModel
|
37
|
+
glShadeModel GL_SMOOTH
|
35
38
|
|
36
|
-
glMatrixMode
|
39
|
+
glMatrixMode GL_PROJECTION
|
37
40
|
glLoadIdentity
|
38
41
|
# Calculate aspect ratio of the window
|
39
|
-
gluPerspective
|
42
|
+
gluPerspective 45.0, width / height, 0.1, 100.0
|
40
43
|
|
41
|
-
glMatrixMode
|
44
|
+
glMatrixMode GL_MODELVIEW
|
42
45
|
|
43
46
|
draw_gl_scene
|
44
|
-
end
|
47
|
+
end
|
45
48
|
|
46
|
-
|
47
|
-
def reshape(width, height)
|
49
|
+
def reshape width, height
|
48
50
|
height = 1 if height == 0
|
49
51
|
|
50
52
|
# Reset current viewpoint and perspective transformation
|
51
|
-
glViewport
|
53
|
+
glViewport 0, 0, width, height
|
52
54
|
|
53
|
-
glMatrixMode
|
55
|
+
glMatrixMode GL_PROJECTION
|
54
56
|
glLoadIdentity
|
55
57
|
|
56
|
-
gluPerspective
|
57
|
-
end
|
58
|
+
gluPerspective 45.0, width / height, 0.1, 100.0
|
59
|
+
end
|
58
60
|
|
59
|
-
|
60
|
-
def draw_gl_scene
|
61
|
+
def draw_gl_scene
|
61
62
|
# Clear the screen and depth buffer
|
62
|
-
glClear
|
63
|
+
glClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
|
63
64
|
|
64
65
|
# Reset the view
|
65
|
-
glMatrixMode
|
66
|
+
glMatrixMode GL_MODELVIEW
|
66
67
|
glLoadIdentity
|
67
68
|
|
68
69
|
# Move left 1.5 units and into the screen 6.0 units
|
69
|
-
glTranslatef
|
70
|
+
glTranslatef -1.5, 0.0, -6.0
|
70
71
|
|
71
72
|
# Rotate the pyramid on the Y-axis
|
72
|
-
glRotatef
|
73
|
+
glRotatef @pyramid_angle, 0.0, 1.0, 0.0
|
74
|
+
|
73
75
|
# Draw a pyramid
|
74
|
-
glBegin
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
76
|
+
glBegin GL_POLYGON do
|
77
|
+
# Draw front side of pyramid
|
78
|
+
glColor3f 1.0, 0.0, 0.0
|
79
|
+
glVertex3f 0.0, 1.0, 0.0
|
80
|
+
glColor3f 0.0, 1.0, 0.0
|
81
|
+
glVertex3f -1.0, -1.0, 1.0
|
82
|
+
glColor3f 0.0, 0.0, 1.0
|
83
|
+
glVertex3f 1.0, -1.0, 1.0
|
84
|
+
|
85
|
+
# Draw right side of pyramid
|
86
|
+
glColor3f 1.0, 0.0, 0.0
|
87
|
+
glVertex3f 0.0, 1.0, 0.0
|
88
|
+
glColor3f 0.0, 0.0, 1.0
|
89
|
+
glVertex3f 1.0, -1.0, 1.0
|
90
|
+
glColor3f 0.0, 1.0, 0.0
|
91
|
+
glVertex3f 1.0, -1.0, -1.0
|
92
|
+
|
93
|
+
# Draw back side of pyramid
|
94
|
+
glColor3f 1.0, 0.0, 0.0
|
95
|
+
glVertex3f 0.0, 1.0, 0.0
|
96
|
+
glColor3f 0.0, 1.0, 0.0
|
97
|
+
glVertex3f 1.0, -1.0, -1.0
|
98
|
+
glColor3f 0.0, 0.0, 1.0
|
99
|
+
glVertex3f -1.0, -1.0, -1.0
|
100
|
+
|
101
|
+
# Draw left side of pyramid
|
102
|
+
glColor3f 1.0, 0.0, 0.0
|
103
|
+
glVertex3f 0.0, 1.0, 0.0
|
104
|
+
glColor3f 0.0, 0.0, 1.0
|
105
|
+
glVertex3f -1.0, -1.0, -1.0
|
106
|
+
glColor3f 0.0, 1.0, 0.0
|
107
|
+
glVertex3f -1.0, -1.0, 1.0
|
108
|
+
end
|
104
109
|
|
105
110
|
glLoadIdentity
|
106
111
|
# Move right 3 units
|
107
|
-
glTranslatef
|
112
|
+
glTranslatef 1.5, 0.0, -7.0
|
108
113
|
|
109
114
|
# Draw a cube
|
110
115
|
# Rotate the cube on the X, Y and Z axis
|
111
|
-
glRotatef
|
116
|
+
glRotatef @cube_angle, 1.0, 1.0, 1.0
|
112
117
|
# Set it to a blue color one time only
|
113
|
-
glBegin
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
# Swap buffers for display
|
118
|
+
glBegin GL_QUADS do
|
119
|
+
# Draw the top side in green
|
120
|
+
glColor3f 0.0, 1.0, 0.0
|
121
|
+
glVertex3f 1.0, 1.0, -1.0
|
122
|
+
glVertex3f -1.0, 1.0, -1.0
|
123
|
+
glVertex3f -1.0, 1.0, 1.0
|
124
|
+
glVertex3f 1.0, 1.0, 1.0
|
125
|
+
# Draw the bottom side in orange
|
126
|
+
glColor3f 1.0, 0.5, 0.0
|
127
|
+
glVertex3f 1.0, -1.0, 1.0
|
128
|
+
glVertex3f -1.0, -1.0, 1.0
|
129
|
+
glVertex3f -1.0, -1.0, -1.0
|
130
|
+
glVertex3f 1.0, -1.0, -1.0
|
131
|
+
# Draw the front side in red
|
132
|
+
glColor3f 1.0, 0.0, 0.0
|
133
|
+
glVertex3f 1.0, 1.0, 1.0
|
134
|
+
glVertex3f -1.0, 1.0, 1.0
|
135
|
+
glVertex3f -1.0, -1.0, 1.0
|
136
|
+
glVertex3f 1.0, -1.0, 1.0
|
137
|
+
# Draw the back side in yellow
|
138
|
+
glColor3f 1.0, 1.0, 0.0
|
139
|
+
glVertex3f 1.0, -1.0, -1.0
|
140
|
+
glVertex3f -1.0, -1.0, -1.0
|
141
|
+
glVertex3f -1.0, 1.0, -1.0
|
142
|
+
glVertex3f 1.0, 1.0, -1.0
|
143
|
+
# Draw the left side in blue
|
144
|
+
glColor3f 0.0, 0.0, 1.0
|
145
|
+
glVertex3f -1.0, 1.0, 1.0
|
146
|
+
glVertex3f -1.0, 1.0, -1.0
|
147
|
+
glVertex3f -1.0, -1.0, -1.0
|
148
|
+
glVertex3f -1.0, -1.0, 1.0
|
149
|
+
# Draw the right side in violet
|
150
|
+
glColor3f 1.0, 0.0, 1.0
|
151
|
+
glVertex3f 1.0, 1.0, -1.0
|
152
|
+
glVertex3f 1.0, 1.0, 1.0
|
153
|
+
glVertex3f 1.0, -1.0, 1.0
|
154
|
+
glVertex3f 1.0, -1.0, -1.0
|
155
|
+
end
|
156
|
+
|
157
|
+
@pyramid_angle += 0.2
|
158
|
+
@cube_angle -= 0.15
|
159
|
+
# Swap buffers for display
|
155
160
|
glutSwapBuffers
|
156
|
-
end
|
161
|
+
end
|
157
162
|
|
158
|
-
|
159
|
-
def idle
|
163
|
+
def idle
|
160
164
|
glutPostRedisplay
|
161
|
-
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def keyboard key, x, y
|
168
|
+
case key
|
169
|
+
when ?\e
|
170
|
+
glutDestroyWindow @window
|
171
|
+
exit 0
|
172
|
+
end
|
173
|
+
glutPostRedisplay
|
174
|
+
end
|
162
175
|
|
163
|
-
# Keyboard handler to exit when ESC is typed
|
164
|
-
keyboard = lambda do |key, x, y|
|
165
|
-
case(key)
|
166
|
-
when ?\e
|
167
|
-
glutDestroyWindow($window)
|
168
|
-
exit(0)
|
169
|
-
end
|
170
|
-
glutPostRedisplay
|
171
176
|
end
|
172
177
|
|
178
|
+
Lesson05.new if $0 == __FILE__
|
173
179
|
|
174
|
-
# Initliaze our GLUT code
|
175
|
-
glutInit;
|
176
|
-
# Setup a double buffer, RGBA color, alpha components and depth buffer
|
177
|
-
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
|
178
|
-
glutInitWindowSize(640, 480);
|
179
|
-
glutInitWindowPosition(0, 0);
|
180
|
-
$window = glutCreateWindow("NeHe Lesson 05 - ruby-opengl version");
|
181
|
-
glutDisplayFunc(method(:draw_gl_scene).to_proc);
|
182
|
-
glutReshapeFunc(method(:reshape).to_proc);
|
183
|
-
glutIdleFunc(method(:idle).to_proc);
|
184
|
-
glutKeyboardFunc(keyboard);
|
185
|
-
init_gl_window(640, 480)
|
186
|
-
glutMainLoop();
|