opengl 0.7.0.pre1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +8 -0
  3. data/History.txt +36 -0
  4. data/MIT-LICENSE +18 -0
  5. data/Manifest.txt +140 -0
  6. data/README.rdoc +51 -0
  7. data/Rakefile +129 -0
  8. data/Rakefile.cross +104 -0
  9. data/doc/build_install.txt +119 -0
  10. data/doc/extensions.txt.in +348 -0
  11. data/doc/history.txt +66 -0
  12. data/doc/requirements_and_design.txt +117 -0
  13. data/doc/roadmap.txt +28 -0
  14. data/doc/scientific_use.txt +35 -0
  15. data/doc/supplies/page_template.html +71 -0
  16. data/doc/thanks.txt +29 -0
  17. data/doc/tutorial.txt +469 -0
  18. data/examples/NeHe/nehe_lesson02.rb +117 -0
  19. data/examples/NeHe/nehe_lesson03.rb +122 -0
  20. data/examples/NeHe/nehe_lesson04.rb +133 -0
  21. data/examples/NeHe/nehe_lesson05.rb +186 -0
  22. data/examples/NeHe/nehe_lesson36.rb +303 -0
  23. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  24. data/examples/OrangeBook/brick.frag +36 -0
  25. data/examples/OrangeBook/brick.rb +376 -0
  26. data/examples/OrangeBook/brick.vert +41 -0
  27. data/examples/OrangeBook/particle.frag +17 -0
  28. data/examples/OrangeBook/particle.rb +406 -0
  29. data/examples/OrangeBook/particle.vert +38 -0
  30. data/examples/README +16 -0
  31. data/examples/RedBook/aapoly.rb +142 -0
  32. data/examples/RedBook/aargb.rb +119 -0
  33. data/examples/RedBook/accanti.rb +162 -0
  34. data/examples/RedBook/accpersp.rb +215 -0
  35. data/examples/RedBook/alpha.rb +123 -0
  36. data/examples/RedBook/alpha3D.rb +158 -0
  37. data/examples/RedBook/bezcurve.rb +105 -0
  38. data/examples/RedBook/bezmesh.rb +137 -0
  39. data/examples/RedBook/checker.rb +124 -0
  40. data/examples/RedBook/clip.rb +95 -0
  41. data/examples/RedBook/colormat.rb +135 -0
  42. data/examples/RedBook/cube.rb +69 -0
  43. data/examples/RedBook/depthcue.rb +99 -0
  44. data/examples/RedBook/dof.rb +205 -0
  45. data/examples/RedBook/double.rb +105 -0
  46. data/examples/RedBook/drawf.rb +91 -0
  47. data/examples/RedBook/feedback.rb +145 -0
  48. data/examples/RedBook/fog.rb +167 -0
  49. data/examples/RedBook/font.rb +151 -0
  50. data/examples/RedBook/hello.rb +79 -0
  51. data/examples/RedBook/image.rb +137 -0
  52. data/examples/RedBook/jitter.rb +207 -0
  53. data/examples/RedBook/lines.rb +128 -0
  54. data/examples/RedBook/list.rb +111 -0
  55. data/examples/RedBook/material.rb +275 -0
  56. data/examples/RedBook/mipmap.rb +156 -0
  57. data/examples/RedBook/model.rb +113 -0
  58. data/examples/RedBook/movelight.rb +132 -0
  59. data/examples/RedBook/pickdepth.rb +179 -0
  60. data/examples/RedBook/planet.rb +108 -0
  61. data/examples/RedBook/quadric.rb +158 -0
  62. data/examples/RedBook/robot.rb +115 -0
  63. data/examples/RedBook/select.rb +196 -0
  64. data/examples/RedBook/smooth.rb +95 -0
  65. data/examples/RedBook/stencil.rb +163 -0
  66. data/examples/RedBook/stroke.rb +167 -0
  67. data/examples/RedBook/surface.rb +166 -0
  68. data/examples/RedBook/teaambient.rb +132 -0
  69. data/examples/RedBook/teapots.rb +182 -0
  70. data/examples/RedBook/tess.rb +183 -0
  71. data/examples/RedBook/texbind.rb +147 -0
  72. data/examples/RedBook/texgen.rb +169 -0
  73. data/examples/RedBook/texturesurf.rb +128 -0
  74. data/examples/RedBook/varray.rb +159 -0
  75. data/examples/RedBook/wrap.rb +148 -0
  76. data/examples/misc/OGLBench.rb +337 -0
  77. data/examples/misc/anisotropic.rb +194 -0
  78. data/examples/misc/fbo_test.rb +356 -0
  79. data/examples/misc/font-glut.rb +46 -0
  80. data/examples/misc/glfwtest.rb +30 -0
  81. data/examples/misc/plane.rb +161 -0
  82. data/examples/misc/readpixel.rb +65 -0
  83. data/examples/misc/sdltest.rb +34 -0
  84. data/examples/misc/trislam.rb +828 -0
  85. data/ext/common/common.h +448 -0
  86. data/ext/common/conv.h +234 -0
  87. data/ext/common/funcdef.h +280 -0
  88. data/ext/common/gl-enums.h +10031 -0
  89. data/ext/common/gl-error.h +23 -0
  90. data/ext/common/gl-types.h +67 -0
  91. data/ext/common/glu-enums.h +463 -0
  92. data/ext/gl/extconf.rb +43 -0
  93. data/ext/gl/gl-1.0-1.1.c +2811 -0
  94. data/ext/gl/gl-1.2.c +814 -0
  95. data/ext/gl/gl-1.3.c +443 -0
  96. data/ext/gl/gl-1.4.c +348 -0
  97. data/ext/gl/gl-1.5.c +225 -0
  98. data/ext/gl/gl-2.0.c +657 -0
  99. data/ext/gl/gl-2.1.c +57 -0
  100. data/ext/gl/gl-enums.c +3354 -0
  101. data/ext/gl/gl-error.c +104 -0
  102. data/ext/gl/gl-ext-3dfx.c +27 -0
  103. data/ext/gl/gl-ext-arb.c +866 -0
  104. data/ext/gl/gl-ext-ati.c +41 -0
  105. data/ext/gl/gl-ext-ext.c +889 -0
  106. data/ext/gl/gl-ext-gremedy.c +41 -0
  107. data/ext/gl/gl-ext-nv.c +679 -0
  108. data/ext/gl/gl.c +216 -0
  109. data/ext/glu/extconf.rb +51 -0
  110. data/ext/glu/glu-enums.c +164 -0
  111. data/ext/glu/glu.c +1530 -0
  112. data/ext/glut/extconf.rb +67 -0
  113. data/ext/glut/glut.c +1624 -0
  114. data/lib/opengl.rb +89 -0
  115. data/test/README +10 -0
  116. data/test/tc_common.rb +98 -0
  117. data/test/tc_ext_arb.rb +467 -0
  118. data/test/tc_ext_ati.rb +33 -0
  119. data/test/tc_ext_ext.rb +551 -0
  120. data/test/tc_ext_gremedy.rb +36 -0
  121. data/test/tc_ext_nv.rb +357 -0
  122. data/test/tc_func_10_11.rb +1281 -0
  123. data/test/tc_func_12.rb +186 -0
  124. data/test/tc_func_13.rb +229 -0
  125. data/test/tc_func_14.rb +197 -0
  126. data/test/tc_func_15.rb +270 -0
  127. data/test/tc_func_20.rb +346 -0
  128. data/test/tc_func_21.rb +541 -0
  129. data/test/tc_glu.rb +310 -0
  130. data/test/tc_include_gl.rb +35 -0
  131. data/test/tc_misc.rb +54 -0
  132. data/test/tc_require_gl.rb +34 -0
  133. data/utils/README +11 -0
  134. data/utils/enumgen.rb +112 -0
  135. data/utils/extlistgen.rb +90 -0
  136. data/utils/mkdn2html.rb +59 -0
  137. data/utils/post-mkdn2html.rb +91 -0
  138. data/website/images/ogl.jpg +0 -0
  139. data/website/images/tab_bottom.gif +0 -0
  140. data/website/style.css +198 -0
  141. metadata +274 -0
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env ruby -rubygems
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 "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
+
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)
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
+ glEnd
73
+
74
+ # Move right 3 units
75
+ glTranslatef(3.0, 0.0, 0.0)
76
+
77
+ # Draw a rectangle
78
+ glBegin(GL_QUADS)
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
+ glEnd
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
+ glutDisplayFunc(method(:draw_gl_scene).to_proc);
113
+ glutReshapeFunc(method(:reshape).to_proc);
114
+ glutIdleFunc(method(:idle).to_proc);
115
+ glutKeyboardFunc(keyboard);
116
+ init_gl_window(640, 480)
117
+ glutMainLoop();
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env ruby -rubygems
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 "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
+
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)
69
+ glColor3f(1.0, 0.0, 0.0)
70
+ glVertex3f( 0.0, 1.0, 0.0)
71
+ glColor3f(0.0, 1.0, 0.0)
72
+ glVertex3f( 1.0, -1.0, 0.0)
73
+ glColor3f(0.0, 0.0, 1.0)
74
+ glVertex3f(-1.0, -1.0, 0.0)
75
+ glEnd
76
+
77
+ # Move right 3 units
78
+ glTranslatef(3.0, 0.0, 0.0)
79
+
80
+ # Draw a rectangle
81
+ # Set it to a blue color one time only
82
+ glColor3f(0.5, 0.5, 1.0)
83
+ glBegin(GL_QUADS)
84
+ glVertex3f(-1.0, 1.0, 0.0)
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
+ glEnd
89
+
90
+ # Swap buffers for display
91
+ glutSwapBuffers
92
+ end
93
+
94
+ # The idle function to handle
95
+ def idle
96
+ glutPostRedisplay
97
+ end
98
+
99
+ # Keyboard handler to exit when ESC is typed
100
+ keyboard = lambda do |key, x, y|
101
+ case(key)
102
+ when ?\e
103
+ glutDestroyWindow(window)
104
+ exit(0)
105
+ end
106
+ glutPostRedisplay
107
+ end
108
+
109
+
110
+ # Initliaze our GLUT code
111
+ glutInit;
112
+ # Setup a double buffer, RGBA color, alpha components and depth buffer
113
+ glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
114
+ glutInitWindowSize(640, 480);
115
+ glutInitWindowPosition(0, 0);
116
+ window = glutCreateWindow("NeHe Lesson 03 - ruby-opengl version");
117
+ glutDisplayFunc(method(:draw_gl_scene).to_proc);
118
+ glutReshapeFunc(method(:reshape).to_proc);
119
+ glutIdleFunc(method(:idle).to_proc);
120
+ glutKeyboardFunc(keyboard);
121
+ init_gl_window(640, 480)
122
+ glutMainLoop();
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env ruby -rubygems
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
+
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
+ $triangle_angle = 0
21
+ # Angle for the quadrilateral (Global)
22
+ $quad_angle = 0
23
+
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
44
+ end
45
+
46
+ #reshape = Proc.new do |width, height|
47
+ def reshape(width, height)
48
+ height = 1 if height == 0
49
+
50
+ # Reset current viewpoint and perspective transformation
51
+ glViewport(0, 0, width, height)
52
+
53
+ glMatrixMode(GL_PROJECTION)
54
+ glLoadIdentity
55
+
56
+ gluPerspective(45.0, width / height, 0.1, 100.0)
57
+ end
58
+
59
+ #draw_gl_scene = Proc.new do
60
+ 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
103
+ end
104
+
105
+ # The idle function to handle
106
+ def idle
107
+ glutPostRedisplay
108
+ end
109
+
110
+ # Keyboard handler to exit when ESC is typed
111
+ keyboard = lambda do |key, x, y|
112
+ case(key)
113
+ when ?\e
114
+ glutDestroyWindow($window)
115
+ exit(0)
116
+ end
117
+ glutPostRedisplay
118
+ end
119
+
120
+
121
+ # Initliaze our GLUT code
122
+ glutInit;
123
+ # 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();
@@ -0,0 +1,186 @@
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)
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
44
+ end
45
+
46
+ #reshape = Proc.new do |width, height|
47
+ def reshape(width, height)
48
+ height = 1 if height == 0
49
+
50
+ # Reset current viewpoint and perspective transformation
51
+ glViewport(0, 0, width, height)
52
+
53
+ glMatrixMode(GL_PROJECTION)
54
+ glLoadIdentity
55
+
56
+ gluPerspective(45.0, width / height, 0.1, 100.0)
57
+ end
58
+
59
+ #draw_gl_scene = Proc.new do
60
+ 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 pyramid on the Y-axis
72
+ glRotatef($pyramid_angle, 0.0, 1.0, 0.0)
73
+ # 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
104
+
105
+ glLoadIdentity
106
+ # Move right 3 units
107
+ glTranslatef(1.5, 0.0, -7.0)
108
+
109
+ # Draw a cube
110
+ # Rotate the cube on the X, Y and Z axis
111
+ glRotatef($cube_angle, 1.0, 1.0, 1.0)
112
+ # 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
155
+ glutSwapBuffers
156
+ end
157
+
158
+ # The idle function to handle
159
+ def idle
160
+ glutPostRedisplay
161
+ end
162
+
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
+ end
172
+
173
+
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();