opengl 0.9.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +3 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +29 -0
  5. data/.gemtest +0 -0
  6. data/.gitignore +6 -0
  7. data/.travis.yml +19 -0
  8. data/History.rdoc +77 -0
  9. data/MIT-LICENSE +18 -0
  10. data/Manifest.txt +138 -0
  11. data/README.rdoc +102 -0
  12. data/Rakefile +60 -0
  13. data/examples/NeHe/NeHe.png +0 -0
  14. data/examples/NeHe/crate.png +0 -0
  15. data/examples/NeHe/glass.png +0 -0
  16. data/examples/NeHe/nehe_lesson02.rb +117 -0
  17. data/examples/NeHe/nehe_lesson03.rb +123 -0
  18. data/examples/NeHe/nehe_lesson04.rb +132 -0
  19. data/examples/NeHe/nehe_lesson05.rb +182 -0
  20. data/examples/NeHe/nehe_lesson06.rb +186 -0
  21. data/examples/NeHe/nehe_lesson07.rb +240 -0
  22. data/examples/NeHe/nehe_lesson08.rb +255 -0
  23. data/examples/NeHe/nehe_lesson09.rb +203 -0
  24. data/examples/NeHe/nehe_lesson11.rb +176 -0
  25. data/examples/NeHe/nehe_lesson12.rb +203 -0
  26. data/examples/NeHe/nehe_lesson16.rb +211 -0
  27. data/examples/NeHe/nehe_lesson19.rb +209 -0
  28. data/examples/NeHe/nehe_lesson36.rb +308 -0
  29. data/examples/NeHe/particle.png +0 -0
  30. data/examples/NeHe/star.png +0 -0
  31. data/examples/NeHe/tim.png +0 -0
  32. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  33. data/examples/OrangeBook/brick.frag +36 -0
  34. data/examples/OrangeBook/brick.rb +378 -0
  35. data/examples/OrangeBook/brick.vert +41 -0
  36. data/examples/OrangeBook/particle.frag +17 -0
  37. data/examples/OrangeBook/particle.rb +408 -0
  38. data/examples/OrangeBook/particle.vert +38 -0
  39. data/examples/README +16 -0
  40. data/examples/RedBook/aapoly.rb +143 -0
  41. data/examples/RedBook/aargb.rb +121 -0
  42. data/examples/RedBook/accanti.rb +164 -0
  43. data/examples/RedBook/accpersp.rb +217 -0
  44. data/examples/RedBook/alpha.rb +125 -0
  45. data/examples/RedBook/alpha3D.rb +160 -0
  46. data/examples/RedBook/bezcurve.rb +107 -0
  47. data/examples/RedBook/bezmesh.rb +139 -0
  48. data/examples/RedBook/checker.rb +126 -0
  49. data/examples/RedBook/clip.rb +97 -0
  50. data/examples/RedBook/colormat.rb +137 -0
  51. data/examples/RedBook/cube.rb +71 -0
  52. data/examples/RedBook/depthcue.rb +101 -0
  53. data/examples/RedBook/dof.rb +206 -0
  54. data/examples/RedBook/double.rb +107 -0
  55. data/examples/RedBook/drawf.rb +93 -0
  56. data/examples/RedBook/feedback.rb +147 -0
  57. data/examples/RedBook/fog.rb +168 -0
  58. data/examples/RedBook/font.rb +153 -0
  59. data/examples/RedBook/hello.rb +81 -0
  60. data/examples/RedBook/image.rb +139 -0
  61. data/examples/RedBook/jitter.rb +207 -0
  62. data/examples/RedBook/light.rb +155 -0
  63. data/examples/RedBook/lines.rb +130 -0
  64. data/examples/RedBook/list.rb +113 -0
  65. data/examples/RedBook/material.rb +276 -0
  66. data/examples/RedBook/mipmap.rb +158 -0
  67. data/examples/RedBook/model.rb +115 -0
  68. data/examples/RedBook/movelight.rb +134 -0
  69. data/examples/RedBook/pickdepth.rb +181 -0
  70. data/examples/RedBook/planet.rb +110 -0
  71. data/examples/RedBook/quadric.rb +160 -0
  72. data/examples/RedBook/robot.rb +117 -0
  73. data/examples/RedBook/select.rb +198 -0
  74. data/examples/RedBook/smooth.rb +97 -0
  75. data/examples/RedBook/stencil.rb +165 -0
  76. data/examples/RedBook/stroke.rb +169 -0
  77. data/examples/RedBook/surface.rb +168 -0
  78. data/examples/RedBook/teaambient.rb +134 -0
  79. data/examples/RedBook/teapots.rb +184 -0
  80. data/examples/RedBook/tess.rb +185 -0
  81. data/examples/RedBook/texbind.rb +149 -0
  82. data/examples/RedBook/texgen.rb +171 -0
  83. data/examples/RedBook/texturesurf.rb +130 -0
  84. data/examples/RedBook/varray.rb +161 -0
  85. data/examples/RedBook/wrap.rb +150 -0
  86. data/examples/misc/OGLBench.rb +338 -0
  87. data/examples/misc/anisotropic.rb +196 -0
  88. data/examples/misc/fbo_test.rb +357 -0
  89. data/examples/misc/font-glut.rb +47 -0
  90. data/examples/misc/glfwtest.rb +30 -0
  91. data/examples/misc/plane.rb +161 -0
  92. data/examples/misc/readpixel.rb +66 -0
  93. data/examples/misc/sdltest.rb +36 -0
  94. data/examples/misc/trislam.rb +829 -0
  95. data/ext/opengl/common.h +428 -0
  96. data/ext/opengl/conv.h +244 -0
  97. data/ext/opengl/extconf.rb +47 -0
  98. data/ext/opengl/funcdef.h +313 -0
  99. data/ext/opengl/gl-1.0-1.1.c +3075 -0
  100. data/ext/opengl/gl-1.2.c +155 -0
  101. data/ext/opengl/gl-1.3.c +443 -0
  102. data/ext/opengl/gl-1.4.c +348 -0
  103. data/ext/opengl/gl-1.5.c +224 -0
  104. data/ext/opengl/gl-2.0.c +667 -0
  105. data/ext/opengl/gl-2.1.c +57 -0
  106. data/ext/opengl/gl-3.0.c +493 -0
  107. data/ext/opengl/gl-enums.c +4873 -0
  108. data/ext/opengl/gl-enums.h +14588 -0
  109. data/ext/opengl/gl-error.c +112 -0
  110. data/ext/opengl/gl-error.h +28 -0
  111. data/ext/opengl/gl-ext-3dfx.c +27 -0
  112. data/ext/opengl/gl-ext-arb.c +875 -0
  113. data/ext/opengl/gl-ext-ati.c +41 -0
  114. data/ext/opengl/gl-ext-ext.c +889 -0
  115. data/ext/opengl/gl-ext-gremedy.c +41 -0
  116. data/ext/opengl/gl-ext-nv.c +680 -0
  117. data/ext/opengl/gl-types.h +67 -0
  118. data/ext/opengl/gl.c +220 -0
  119. data/ext/opengl/gl_buffer.c +177 -0
  120. data/ext/opengl/opengl.c +7 -0
  121. data/lib/gl.rb +1 -0
  122. data/lib/opengl.rb +53 -0
  123. data/lib/opengl/2.0/opengl.so +0 -0
  124. data/lib/opengl/2.1/opengl.so +0 -0
  125. data/lib/opengl/test_case.rb +86 -0
  126. data/test/dummy.xorg.conf +140 -0
  127. data/test/test_gl.rb +38 -0
  128. data/test/test_gl_10_11.rb +1363 -0
  129. data/test/test_gl_12.rb +71 -0
  130. data/test/test_gl_13.rb +221 -0
  131. data/test/test_gl_14.rb +218 -0
  132. data/test/test_gl_15.rb +258 -0
  133. data/test/test_gl_20.rb +417 -0
  134. data/test/test_gl_21.rb +436 -0
  135. data/test/test_gl_ext_arb.rb +508 -0
  136. data/test/test_gl_ext_ati.rb +28 -0
  137. data/test/test_gl_ext_ext.rb +608 -0
  138. data/test/test_gl_ext_gremedy.rb +29 -0
  139. data/test/test_gl_ext_nv.rb +349 -0
  140. data/test/test_opengl_buffer.rb +120 -0
  141. data/utils/README +6 -0
  142. data/utils/enumgen.rb +108 -0
  143. data/utils/extlistgen.rb +90 -0
  144. metadata +319 -0
  145. metadata.gz.sig +1 -0
Binary file
Binary file
Binary file
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env ruby
2
+ # Name: nehe_lesson02.rb
3
+ # Purpose: An implementation of NeHe's OpenGL Lesson #02
4
+ # using ruby-opengl (http://nehe.gamedev.net/)
5
+ #
6
+
7
+ require 'opengl'
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 = nil
19
+
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
40
+ end
41
+
42
+ #reshape = Proc.new do |width, height|
43
+ def reshape width, height
44
+ height = 1 if height == 0
45
+
46
+ # Reset current viewpoint and perspective transformation
47
+ glViewport 0, 0, width, height
48
+
49
+ glMatrixMode GL_PROJECTION
50
+ glLoadIdentity
51
+
52
+ gluPerspective 45.0, width / height, 0.1, 100.0
53
+ end
54
+
55
+ #draw_gl_scene = Proc.new do
56
+ def draw_gl_scene
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
+ # Draw a triangle
68
+ glBegin GL_POLYGON do
69
+ glVertex3f 0.0, 1.0, 0.0
70
+ glVertex3f 1.0, -1.0, 0.0
71
+ glVertex3f -1.0, -1.0, 0.0
72
+ end
73
+
74
+ # Move right 3 units
75
+ glTranslatef 3.0, 0.0, 0.0
76
+
77
+ # Draw a rectangle
78
+ glBegin GL_QUADS do
79
+ glVertex3f -1.0, 1.0, 0.0
80
+ glVertex3f 1.0, 1.0, 0.0
81
+ glVertex3f 1.0, -1.0, 0.0
82
+ glVertex3f -1.0, -1.0, 0.0
83
+ end
84
+
85
+ # Swap buffers for display
86
+ glutSwapBuffers
87
+ end
88
+
89
+ # The idle function to handle
90
+ def idle
91
+ glutPostRedisplay
92
+ end
93
+
94
+ # Keyboard handler to exit when ESC is typed
95
+ keyboard = lambda do |key, x, y|
96
+ case key
97
+ when ?\e
98
+ glutDestroyWindow window
99
+ exit(0)
100
+ end
101
+ glutPostRedisplay
102
+ end
103
+
104
+
105
+ # Initliaze our GLUT code
106
+ glutInit
107
+ # Setup a double buffer, RGBA color, alpha components and depth buffer
108
+ glutInitDisplayMode GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH
109
+ glutInitWindowSize 640, 480
110
+ glutInitWindowPosition 0, 0
111
+ window = glutCreateWindow "NeHe Lesson 02 - ruby-opengl version"
112
+ glutIdleFunc :idle
113
+ glutDisplayFunc :draw_gl_scene
114
+ glutReshapeFunc :reshape
115
+ glutKeyboardFunc keyboard
116
+ init_gl_window 640, 480
117
+ glutMainLoop
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env ruby
2
+ # Name: nehe_lesson03.rb
3
+ # Purpose: An implementation of NeHe's OpenGL Lesson #03
4
+ # using ruby-opengl (http://nehe.gamedev.net/)
5
+ #
6
+
7
+ require 'opengl'
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 = nil
19
+
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
40
+ end
41
+
42
+ #reshape = Proc.new do |width, height|
43
+ def reshape width, height
44
+ height = 1 if height == 0
45
+
46
+ # Reset current viewpoint and perspective transformation
47
+ glViewport 0, 0, width, height
48
+
49
+ glMatrixMode GL_PROJECTION
50
+ glLoadIdentity
51
+
52
+ gluPerspective 45.0, width / height, 0.1, 100.0
53
+ end
54
+
55
+ #draw_gl_scene = Proc.new do
56
+ def draw_gl_scene
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
+ # Draw a triangle setting the color to red, green, blue for each respective
68
+ # vertex
69
+ glBegin GL_POLYGON do
70
+ glColor3f 1.0, 0.0, 0.0
71
+ glVertex3f 0.0, 1.0, 0.0
72
+ glColor3f 0.0, 1.0, 0.0
73
+ glVertex3f 1.0, -1.0, 0.0
74
+ glColor3f 0.0, 0.0, 1.0
75
+ glVertex3f -1.0, -1.0, 0.0
76
+ end
77
+
78
+ # Move right 3 units
79
+ glTranslatef 3.0, 0.0, 0.0
80
+
81
+ # Set the color to medium blue for all vertexes
82
+ glColor3f 0.5, 0.5, 1.0
83
+ # Draw a rectangle
84
+ glBegin GL_QUADS do
85
+ glVertex3f -1.0, 1.0, 0.0
86
+ glVertex3f 1.0, 1.0, 0.0
87
+ glVertex3f 1.0, -1.0, 0.0
88
+ glVertex3f -1.0, -1.0, 0.0
89
+ end
90
+
91
+ # Swap buffers for display
92
+ glutSwapBuffers
93
+ end
94
+
95
+ # The idle function to handle
96
+ def idle
97
+ glutPostRedisplay
98
+ end
99
+
100
+ # Keyboard handler to exit when ESC is typed
101
+ keyboard = lambda do |key, x, y|
102
+ case key
103
+ when ?\e
104
+ glutDestroyWindow window
105
+ exit(0)
106
+ end
107
+ glutPostRedisplay
108
+ end
109
+
110
+
111
+ # Initliaze our GLUT code
112
+ glutInit
113
+ # Setup a double buffer, RGBA color, alpha components and depth buffer
114
+ glutInitDisplayMode GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH
115
+ glutInitWindowSize 640, 480
116
+ glutInitWindowPosition 0, 0
117
+ window = glutCreateWindow "NeHe Lesson 03 - ruby-opengl version"
118
+ glutIdleFunc :idle
119
+ glutDisplayFunc :draw_gl_scene
120
+ glutReshapeFunc :reshape
121
+ glutKeyboardFunc keyboard
122
+ init_gl_window 640, 480
123
+ glutMainLoop
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env ruby
2
+ # Name: nehe_lesson04.rb
3
+ # Purpose: An implementation of NeHe's OpenGL Lesson #04
4
+ # using ruby-opengl http://nehe.gamedev.net/
5
+
6
+ require 'opengl'
7
+ require 'glu'
8
+ require 'glut'
9
+
10
+ # Add GL and GLUT namespaces in to make porting easier
11
+ include Gl
12
+ include Glu
13
+ include Glut
14
+
15
+ # Placeholder for the window object
16
+ $window = ""
17
+ # Angle for the triangle Global
18
+ $triangle_angle = 0
19
+ # Angle for the quadrilateral Global
20
+ $quad_angle = 0
21
+
22
+ def init_gl_window width = 640, height = 480
23
+ # Background color to black
24
+ glClearColor 0.0, 0.0, 0.0, 0
25
+ # Enables clearing of depth buffer
26
+ glClearDepth 1.0
27
+ # Set type of depth test
28
+ glDepthFunc GL_LEQUAL
29
+ # Enable depth testing
30
+ glEnable GL_DEPTH_TEST
31
+ # Enable smooth color shading
32
+ glShadeModel GL_SMOOTH
33
+
34
+ glMatrixMode GL_PROJECTION
35
+ glLoadIdentity
36
+ # Calculate aspect ratio of the window
37
+ gluPerspective 45.0, width / height, 0.1, 100.0
38
+
39
+ glMatrixMode GL_MODELVIEW
40
+
41
+ draw_gl_scene
42
+ end
43
+
44
+ #reshape = Proc.new do |width, height|
45
+ def reshape width, height
46
+ height = 1 if height == 0
47
+
48
+ # Reset current viewpoint and perspective transformation
49
+ glViewport 0, 0, width, height
50
+
51
+ glMatrixMode GL_PROJECTION
52
+ glLoadIdentity
53
+
54
+ gluPerspective 45.0, width / height, 0.1, 100.0
55
+ end
56
+
57
+ #draw_gl_scene = Proc.new do
58
+ def draw_gl_scene
59
+ # Clear the screen and depth buffer
60
+ glClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
61
+
62
+ # Reset the view
63
+ glMatrixMode GL_MODELVIEW
64
+ glLoadIdentity
65
+
66
+ # Move left 1.5 units and into the screen 6.0 units
67
+ glTranslatef -1.5, 0.0, -6.0
68
+
69
+ # Rotate the triangle on the Y-axis
70
+ glRotatef $triangle_angle, 0.0, 1.0, 0.0
71
+ # Draw a triangle
72
+ glBegin GL_POLYGON do
73
+ glColor3f 1.0, 0.0, 0.0
74
+ glVertex3f 0.0, 1.0, 0.0
75
+ glColor3f 0.0, 1.0, 0.0
76
+ glVertex3f 1.0, -1.0, 0.0
77
+ glColor3f 0.0, 0.0, 1.0
78
+ glVertex3f -1.0, -1.0, 0.0
79
+ end
80
+
81
+ # Move right 3 units
82
+ glLoadIdentity
83
+ glTranslatef 1.5, 0.0, -6.0
84
+
85
+ # Draw a quadrilateral
86
+ # Rotate the quad on the X-axis
87
+ glRotatef $quad_angle, 1.0, 0.0, 0.0
88
+ # Set it to a blue color one time only
89
+ glColor3f 0.5, 0.5, 1.0
90
+ glBegin GL_QUADS do
91
+ glVertex3f -1.0, 1.0, 0.0
92
+ glVertex3f 1.0, 1.0, 0.0
93
+ glVertex3f 1.0, -1.0, 0.0
94
+ glVertex3f -1.0, -1.0, 0.0
95
+ end
96
+
97
+ $triangle_angle += 0.2
98
+ $quad_angle -= 0.15
99
+
100
+ # Swap buffers for display
101
+ glutSwapBuffers
102
+ end
103
+
104
+ # The idle function to handle
105
+ def idle
106
+ glutPostRedisplay
107
+ end
108
+
109
+ # Keyboard handler to exit when ESC is typed
110
+ keyboard = lambda do |key, x, y|
111
+ case key
112
+ when ?\e
113
+ glutDestroyWindow $window
114
+ exit 0
115
+ end
116
+ glutPostRedisplay
117
+ end
118
+
119
+
120
+ # Initliaze our GLUT code
121
+ glutInit
122
+ # Setup a double buffer, RGBA color, alpha components and depth buffer
123
+ glutInitDisplayMode GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH
124
+ glutInitWindowSize 640, 480
125
+ glutInitWindowPosition 0, 0
126
+ $window = glutCreateWindow "NeHe Lesson 04 - ruby-opengl version"
127
+ glutDisplayFunc :draw_gl_scene
128
+ glutReshapeFunc :reshape
129
+ glutIdleFunc :idle
130
+ glutKeyboardFunc keyboard
131
+ init_gl_window 640, 480
132
+ glutMainLoop
@@ -0,0 +1,182 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'opengl'
4
+ require 'glu'
5
+ require 'glut'
6
+
7
+ class Lesson05
8
+ include Gl
9
+ include Glu
10
+ include Glut
11
+
12
+ def initialize
13
+ @pyramid_angle = 0
14
+ @cube_angle = 0
15
+
16
+ # Initliaze our GLUT code
17
+ glutInit
18
+ # Setup a double buffer, RGBA color, alpha components and depth buffer
19
+ glutInitDisplayMode GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH
20
+ glutInitWindowSize 640, 480
21
+ glutInitWindowPosition 0, 0
22
+ @window = glutCreateWindow "NeHe Lesson 05 - ruby-opengl version"
23
+ glutDisplayFunc :draw_gl_scene
24
+ glutReshapeFunc :reshape
25
+ glutIdleFunc :idle
26
+ glutKeyboardFunc :keyboard
27
+ init_gl_window 640, 480
28
+ glutMainLoop
29
+ end
30
+
31
+ def init_gl_window width = 640, height = 480
32
+ # Background color to black
33
+ glClearColor 0.0, 0.0, 0.0, 0
34
+ # Enables clearing of depth buffer
35
+ glClearDepth 1.0
36
+ # Set type of depth test
37
+ glDepthFunc GL_LEQUAL
38
+ # Enable depth testing
39
+ glEnable GL_DEPTH_TEST
40
+ # Enable smooth color shading
41
+ glShadeModel GL_SMOOTH
42
+
43
+ glMatrixMode GL_PROJECTION
44
+ glLoadIdentity
45
+ # Calculate aspect ratio of the window
46
+ gluPerspective 45.0, width / height, 0.1, 100.0
47
+
48
+ glMatrixMode GL_MODELVIEW
49
+
50
+ draw_gl_scene
51
+ end
52
+
53
+ def reshape width, height
54
+ height = 1 if height == 0
55
+
56
+ # Reset current viewpoint and perspective transformation
57
+ glViewport 0, 0, width, height
58
+
59
+ glMatrixMode GL_PROJECTION
60
+ glLoadIdentity
61
+
62
+ gluPerspective 45.0, width / height, 0.1, 100.0
63
+ end
64
+
65
+ def draw_gl_scene
66
+ # Clear the screen and depth buffer
67
+ glClear GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
68
+
69
+ # Reset the view
70
+ glMatrixMode GL_MODELVIEW
71
+ glLoadIdentity
72
+
73
+ # Move left 1.5 units and into the screen 6.0 units
74
+ glTranslatef -1.5, 0.0, -6.0
75
+
76
+ # Rotate the pyramid on the Y-axis
77
+ glRotatef @pyramid_angle, 0.0, 1.0, 0.0
78
+
79
+ # Draw a pyramid
80
+ glBegin GL_POLYGON do
81
+ # Draw front side of pyramid
82
+ glColor3f 1.0, 0.0, 0.0
83
+ glVertex3f 0.0, 1.0, 0.0
84
+ glColor3f 0.0, 1.0, 0.0
85
+ glVertex3f -1.0, -1.0, 1.0
86
+ glColor3f 0.0, 0.0, 1.0
87
+ glVertex3f 1.0, -1.0, 1.0
88
+
89
+ # Draw right 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
+
97
+ # Draw back side of pyramid
98
+ glColor3f 1.0, 0.0, 0.0
99
+ glVertex3f 0.0, 1.0, 0.0
100
+ glColor3f 0.0, 1.0, 0.0
101
+ glVertex3f 1.0, -1.0, -1.0
102
+ glColor3f 0.0, 0.0, 1.0
103
+ glVertex3f -1.0, -1.0, -1.0
104
+
105
+ # Draw left side of pyramid
106
+ glColor3f 1.0, 0.0, 0.0
107
+ glVertex3f 0.0, 1.0, 0.0
108
+ glColor3f 0.0, 0.0, 1.0
109
+ glVertex3f -1.0, -1.0, -1.0
110
+ glColor3f 0.0, 1.0, 0.0
111
+ glVertex3f -1.0, -1.0, 1.0
112
+ end
113
+
114
+ glLoadIdentity
115
+ # Move right 3 units
116
+ glTranslatef 1.5, 0.0, -7.0
117
+
118
+ # Draw a cube
119
+ # Rotate the cube on the X, Y and Z axis
120
+ glRotatef @cube_angle, 1.0, 1.0, 1.0
121
+ # Set it to a blue color one time only
122
+ glBegin GL_QUADS do
123
+ # Draw the top side in green
124
+ glColor3f 0.0, 1.0, 0.0
125
+ glVertex3f 1.0, 1.0, -1.0
126
+ glVertex3f -1.0, 1.0, -1.0
127
+ glVertex3f -1.0, 1.0, 1.0
128
+ glVertex3f 1.0, 1.0, 1.0
129
+ # Draw the bottom side in orange
130
+ glColor3f 1.0, 0.5, 0.0
131
+ glVertex3f 1.0, -1.0, 1.0
132
+ glVertex3f -1.0, -1.0, 1.0
133
+ glVertex3f -1.0, -1.0, -1.0
134
+ glVertex3f 1.0, -1.0, -1.0
135
+ # Draw the front side in red
136
+ glColor3f 1.0, 0.0, 0.0
137
+ glVertex3f 1.0, 1.0, 1.0
138
+ glVertex3f -1.0, 1.0, 1.0
139
+ glVertex3f -1.0, -1.0, 1.0
140
+ glVertex3f 1.0, -1.0, 1.0
141
+ # Draw the back side in yellow
142
+ glColor3f 1.0, 1.0, 0.0
143
+ glVertex3f 1.0, -1.0, -1.0
144
+ glVertex3f -1.0, -1.0, -1.0
145
+ glVertex3f -1.0, 1.0, -1.0
146
+ glVertex3f 1.0, 1.0, -1.0
147
+ # Draw the left side in blue
148
+ glColor3f 0.0, 0.0, 1.0
149
+ glVertex3f -1.0, 1.0, 1.0
150
+ glVertex3f -1.0, 1.0, -1.0
151
+ glVertex3f -1.0, -1.0, -1.0
152
+ glVertex3f -1.0, -1.0, 1.0
153
+ # Draw the right side in violet
154
+ glColor3f 1.0, 0.0, 1.0
155
+ glVertex3f 1.0, 1.0, -1.0
156
+ glVertex3f 1.0, 1.0, 1.0
157
+ glVertex3f 1.0, -1.0, 1.0
158
+ glVertex3f 1.0, -1.0, -1.0
159
+ end
160
+
161
+ @pyramid_angle += 0.2
162
+ @cube_angle -= 0.15
163
+ # Swap buffers for display
164
+ glutSwapBuffers
165
+ end
166
+
167
+ def idle
168
+ glutPostRedisplay
169
+ end
170
+
171
+ def keyboard key, x, y
172
+ case key
173
+ when ?\e
174
+ glutDestroyWindow @window
175
+ exit 0
176
+ end
177
+ glutPostRedisplay
178
+ end
179
+
180
+ end
181
+
182
+ Lesson05.new if $0 == __FILE__