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