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,128 @@
1
+ #
2
+ # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
+ # any purpose and without fee is hereby granted, provided that the above
6
+ # copyright notice appear in all copies and that both the copyright notice
7
+ # and this permission notice appear in supporting documentation, and that
8
+ # the name of Silicon Graphics, Inc. not be used in advertising
9
+ # or publicity pertaining to distribution of the software without specific,
10
+ # written prior permission.
11
+ #
12
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
+ # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14
+ # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15
+ # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
16
+ # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
17
+ # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
18
+ # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
19
+ # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
20
+ # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
21
+ # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
+ # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
+ # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
+ #
25
+ # US Government Users Restricted Rights
26
+ # Use, duplication, or disclosure by the Government is subject to
27
+ # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
+ # (c)(1)(ii) of the Rights in Technical Data and Computer Software
29
+ # clause at DFARS 252.227-7013 and/or in similar or successor
30
+ # clauses in the FAR or the DOD or NASA FAR Supplement.
31
+ # Unpublished-- rights reserved under the copyright laws of the
32
+ # United States. Contractor/manufacturer is Silicon Graphics,
33
+ # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
+ #
35
+ # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
+ #
37
+ # lines.c
38
+ # This program demonstrates geometric primitives and
39
+ # their attributes.
40
+ require 'opengl'
41
+ require 'mathn'
42
+ include Gl,Glu,Glut
43
+
44
+ def drawOneLine(x1,y1,x2,y2)
45
+ glBegin(GL_LINES)
46
+ glVertex((x1),(y1))
47
+ glVertex((x2),(y2))
48
+ glEnd()
49
+ end
50
+
51
+ def init
52
+ glClearColor(0.0, 0.0, 0.0, 0.0)
53
+ glShadeModel(GL_FLAT)
54
+ end
55
+
56
+ display = Proc.new do
57
+ glClear(GL_COLOR_BUFFER_BIT)
58
+
59
+ # select white for all lines
60
+ glColor(1.0, 1.0, 1.0)
61
+
62
+ # in 1st row, 3 lines, each with a different stipple
63
+ glEnable(GL_LINE_STIPPLE)
64
+
65
+ glLineStipple(1, 0x0101) # dotted
66
+ drawOneLine(50.0, 125.0, 150.0, 125.0)
67
+ glLineStipple(1, 0x00FF) # dashed
68
+ drawOneLine(150.0, 125.0, 250.0, 125.0)
69
+ glLineStipple(1, 0x1C47) # dash/dot/dash
70
+ drawOneLine(250.0, 125.0, 350.0, 125.0)
71
+
72
+ # in 2nd row, 3 wide lines, each with different stipple
73
+ glLineWidth(5.0)
74
+ glLineStipple(1, 0x0101) # dotted
75
+ drawOneLine(50.0, 100.0, 150.0, 100.0)
76
+ glLineStipple(1, 0x00FF) # dashed
77
+ drawOneLine(150.0, 100.0, 250.0, 100.0)
78
+ glLineStipple(1, 0x1C47) # dash/dot/dash
79
+ drawOneLine(250.0, 100.0, 350.0, 100.0)
80
+ glLineWidth(1.0)
81
+
82
+ # in 3rd row, 6 lines, with dash/dot/dash stipple
83
+ # as part of a single connected line strip
84
+ glLineStipple(1, 0x1C47) # dash/dot/dash
85
+ glBegin(GL_LINE_STRIP)
86
+ for i in 0..6
87
+ glVertex(50.0 + (i * 50.0), 75.0)
88
+ end
89
+ glEnd()
90
+
91
+ # in 4th row, 6 independent lines with same stipple
92
+ for i in 0..5
93
+ drawOneLine(50.0 + (i * 50.0), 50.0, 50.0 + ((i+1) * 50.0), 50.0)
94
+ end
95
+
96
+ # in 5th row, 1 line, with dash/dot/dash stipple
97
+ # and a stipple repeat factor of 5
98
+ glLineStipple(5, 0x1C47) # dash/dot/dash
99
+ drawOneLine(50.0, 25.0, 350.0, 25.0)
100
+
101
+ glDisable(GL_LINE_STIPPLE)
102
+ glutSwapBuffers()
103
+ end
104
+
105
+ reshape = Proc.new do |w, h|
106
+ glViewport(0, 0, w, h)
107
+ glMatrixMode(GL_PROJECTION)
108
+ glLoadIdentity()
109
+ GLU.Ortho2D(0.0, w, 0.0, h)
110
+ end
111
+
112
+ keyboard = Proc.new do |key, x, y|
113
+ case (key)
114
+ when ?\e
115
+ exit(0)
116
+ end
117
+ end
118
+
119
+ glutInit
120
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
121
+ glutInitWindowSize(400, 150)
122
+ glutInitWindowPosition(100, 100)
123
+ glutCreateWindow($0)
124
+ init()
125
+ glutDisplayFunc(display)
126
+ glutReshapeFunc(reshape)
127
+ glutKeyboardFunc(keyboard)
128
+ glutMainLoop()
@@ -0,0 +1,111 @@
1
+ #
2
+ # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
+ # any purpose and without fee is hereby granted, provided that the above
6
+ # copyright notice appear in all copies and that both the copyright notice
7
+ # and this permission notice appear in supporting documentation, and that
8
+ # the name of Silicon Graphics, Inc. not be used in advertising
9
+ # or publicity pertaining to distribution of the software without specific,
10
+ # written prior permission.
11
+ #
12
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
+ # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14
+ # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15
+ # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
16
+ # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
17
+ # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
18
+ # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
19
+ # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
20
+ # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
21
+ # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
+ # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
+ # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
+ #
25
+ # US Government Users Restricted Rights
26
+ # Use, duplication, or disclosure by the Government is subject to
27
+ # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
+ # (c)(1)(ii) of the Rights in Technical Data and Computer Software
29
+ # clause at DFARS 252.227-7013 and/or in similar or successor
30
+ # clauses in the FAR or the DOD or NASA FAR Supplement.
31
+ # Unpublished-- rights reserved under the copyright laws of the
32
+ # United States. Contractor/manufacturer is Silicon Graphics,
33
+ # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
+ #
35
+ # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
+ #
37
+ # list.c
38
+ # This program demonstrates how to make and execute a
39
+ # display list. Note that attributes, such as current
40
+ # color and matrix, are changed.
41
+ require 'opengl'
42
+ require 'mathn'
43
+ include Gl,Glu,Glut
44
+
45
+ $listName = 0
46
+
47
+ def init
48
+ $listName = glGenLists(1)
49
+ glNewList($listName, GL_COMPILE)
50
+ glColor(1.0, 0.0, 0.0) # /* current color red */
51
+ glBegin(GL_TRIANGLES)
52
+ glVertex(0.0, 0.0)
53
+ glVertex(1.0, 0.0)
54
+ glVertex(0.0, 1.0)
55
+ glEnd()
56
+ glTranslate(1.5, 0.0, 0.0) # /* move position */
57
+ glEndList()
58
+ glShadeModel(GL_FLAT)
59
+ end
60
+
61
+ def drawLine
62
+ glBegin(GL_LINES)
63
+ glVertex(0.0, 0.5)
64
+ glVertex(15.0, 0.5)
65
+ glEnd()
66
+ end
67
+
68
+ display = Proc.new do
69
+ glClear(GL_COLOR_BUFFER_BIT)
70
+ glColor(0.0, 1.0, 0.0) # current color green
71
+ for i in (0..9 ) # draw 10 triangles
72
+ glCallList($listName)
73
+ end
74
+ drawLine() # is this line green? NO!
75
+ # where is the line drawn?
76
+ glutSwapBuffers()
77
+ end
78
+
79
+ reshape = Proc.new do |w, h|
80
+ glViewport(0, 0, w, h)
81
+ glMatrixMode(GL_PROJECTION)
82
+ glLoadIdentity()
83
+ if (w <= h)
84
+ GLU.Ortho2D(0.0, 2.0, -0.5 * h/w, 1.5 * h/w)
85
+ else
86
+ GLU.Ortho2D(0.0, 2.0 * w/h, -0.5, 1.5)
87
+ end
88
+ glMatrixMode(GL_MODELVIEW)
89
+ glLoadIdentity()
90
+ end
91
+
92
+ keyboard = Proc.new do |key, x, y|
93
+ case (key)
94
+ when ?\e
95
+ exit(0)
96
+ end
97
+ end
98
+
99
+ # Main Loop
100
+ # Open window with initial window size, title bar,
101
+ # RGBA display mode, and handle input events.
102
+ glutInit
103
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
104
+ glutInitWindowSize(650, 100)
105
+ glutInitWindowPosition(100, 100)
106
+ glutCreateWindow($0)
107
+ init()
108
+ glutReshapeFunc(reshape)
109
+ glutDisplayFunc(display)
110
+ glutKeyboardFunc(keyboard)
111
+ glutMainLoop()
@@ -0,0 +1,275 @@
1
+ #
2
+ # Copyright (c) Mark J. Kilgard, 1994.
3
+ #
4
+ # (c) Copyright 1993, Silicon Graphics, Inc.
5
+ # ALL RIGHTS RESERVED
6
+ # Permission to use, copy, modify, and distribute this software for
7
+ # any purpose and without fee is hereby granted, provided that the above
8
+ # copyright notice appear in all copies and that both the copyright notice
9
+ # and this permission notice appear in supporting documentation, and that
10
+ # the name of Silicon Graphics, Inc. not be used in advertising
11
+ # or publicity pertaining to distribution of the software without specific,
12
+ # written prior permission.
13
+ #
14
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
15
+ # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
16
+ # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
17
+ # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
18
+ # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
19
+ # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
20
+ # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
21
+ # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
22
+ # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
23
+ # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
24
+ # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
25
+ # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
26
+ #
27
+ # US Government Users Restricted Rights
28
+ # Use, duplication, or disclosure by the Government is subject to
29
+ # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
30
+ # (c)(1)(ii) of the Rights in Technical Data and Computer Software
31
+ # clause at DFARS 252.227-7013 and/or in similar or successor
32
+ # clauses in the FAR or the DOD or NASA FAR Supplement.
33
+ # Unpublished-- rights reserved under the copyright laws of the
34
+ # United States. Contractor/manufacturer is Silicon Graphics,
35
+ # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
36
+ #
37
+ # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
38
+ #
39
+ # material.c
40
+ # This program demonstrates the use of the GL lighting model.
41
+ # Several objects are drawn using different material characteristics.
42
+ # A single light source illuminates the objects.
43
+ require 'opengl'
44
+ include Gl,Glu,Glut
45
+
46
+ # Initialize z-buffer, projection matrix, light source,
47
+ # and lighting model. Do not specify a material property here.
48
+ def myinit
49
+ ambient = [ 0.0, 0.0, 0.0, 1.0 ]
50
+ diffuse = [ 1.0, 1.0, 1.0, 1.0 ]
51
+ position = [ 0.0, 3.0, 2.0, 0.0 ]
52
+ lmodel_ambient = [ 0.4, 0.4, 0.4, 1.0 ]
53
+ local_view = [ 0.0 ]
54
+
55
+ glEnable(GL_DEPTH_TEST)
56
+ glDepthFunc(GL_LESS)
57
+
58
+ glLight(GL_LIGHT0, GL_AMBIENT, ambient)
59
+ glLight(GL_LIGHT0, GL_DIFFUSE, diffuse)
60
+ glLight(GL_LIGHT0, GL_POSITION, position)
61
+ glLightModel(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient)
62
+ glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
63
+
64
+ glEnable(GL_LIGHTING)
65
+ glEnable(GL_LIGHT0)
66
+
67
+ glClearColor(0.0, 0.1, 0.1, 0.0)
68
+ end
69
+
70
+ # Draw twelve spheres in 3 rows with 4 columns.
71
+ # The spheres in the first row have materials with no ambient reflection.
72
+ # The second row has materials with significant ambient reflection.
73
+ # The third row has materials with colored ambient reflection.
74
+ #
75
+ # The first column has materials with blue, diffuse reflection only.
76
+ # The second column has blue diffuse reflection, as well as specular
77
+ # reflection with a low shininess exponent.
78
+ # The third column has blue diffuse reflection, as well as specular
79
+ # reflection with a high shininess exponent (a more concentrated highlight).
80
+ # The fourth column has materials which also include an emissive component.
81
+ #
82
+ # glTranslatef() is used to move spheres to their appropriate locations.
83
+ display = proc do
84
+ no_mat = [ 0.0, 0.0, 0.0, 1.0 ]
85
+ mat_ambient = [ 0.7, 0.7, 0.7, 1.0 ]
86
+ mat_ambient_color = [ 0.8, 0.8, 0.2, 1.0 ]
87
+ mat_diffuse = [ 0.1, 0.5, 0.8, 1.0 ]
88
+ mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
89
+ no_shininess = [ 0.0 ]
90
+ low_shininess = [ 5.0 ]
91
+ high_shininess = [ 100.0 ]
92
+ mat_emission = [0.3, 0.2, 0.2, 0.0]
93
+
94
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
95
+
96
+ # draw sphere in first row, first column
97
+ # diffuse reflection only no ambient or specular
98
+ glPushMatrix()
99
+ glTranslate(-3.75, 3.0, 0.0)
100
+ glMaterial(GL_FRONT, GL_AMBIENT, no_mat)
101
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
102
+ glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
103
+ glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
104
+ glMaterial(GL_FRONT, GL_EMISSION, no_mat)
105
+ glutSolidSphere(1.0, 16, 16)
106
+ glPopMatrix()
107
+
108
+ # draw sphere in first row, second column
109
+ # diffuse and specular reflection low shininess no ambient
110
+ glPushMatrix()
111
+ glTranslate(-1.25, 3.0, 0.0)
112
+ glMaterial(GL_FRONT, GL_AMBIENT, no_mat)
113
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
114
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
115
+ glMaterial(GL_FRONT, GL_SHININESS, low_shininess)
116
+ glMaterial(GL_FRONT, GL_EMISSION, no_mat)
117
+ glutSolidSphere(1.0, 16, 16)
118
+ glPopMatrix()
119
+
120
+ # draw sphere in first row, third column
121
+ # diffuse and specular reflection high shininess no ambient
122
+ glPushMatrix()
123
+ glTranslate(1.25, 3.0, 0.0)
124
+ glMaterial(GL_FRONT, GL_AMBIENT, no_mat)
125
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
126
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
127
+ glMaterial(GL_FRONT, GL_SHININESS, high_shininess)
128
+ glMaterial(GL_FRONT, GL_EMISSION, no_mat)
129
+ glutSolidSphere(1.0, 16, 16)
130
+ glPopMatrix()
131
+
132
+ # draw sphere in first row, fourth column
133
+ # diffuse reflection emission no ambient or specular reflection
134
+ glPushMatrix()
135
+ glTranslate(3.75, 3.0, 0.0)
136
+ glMaterial(GL_FRONT, GL_AMBIENT, no_mat)
137
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
138
+ glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
139
+ glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
140
+ glMaterial(GL_FRONT, GL_EMISSION, mat_emission)
141
+ glutSolidSphere(1.0, 16, 16)
142
+ glPopMatrix()
143
+
144
+ # draw sphere in second row, first column
145
+ # ambient and diffuse reflection no specular
146
+ glPushMatrix()
147
+ glTranslate(-3.75, 0.0, 0.0)
148
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
149
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
150
+ glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
151
+ glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
152
+ glMaterial(GL_FRONT, GL_EMISSION, no_mat)
153
+ glutSolidSphere(1.0, 16, 16)
154
+ glPopMatrix()
155
+
156
+ # draw sphere in second row, second column
157
+ # ambient, diffuse and specular reflection low shininess
158
+ glPushMatrix()
159
+ glTranslate(-1.25, 0.0, 0.0)
160
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
161
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
162
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
163
+ glMaterial(GL_FRONT, GL_SHININESS, low_shininess)
164
+ glMaterial(GL_FRONT, GL_EMISSION, no_mat)
165
+ glutSolidSphere(1.0, 16, 16)
166
+ glPopMatrix()
167
+
168
+ # draw sphere in second row, third column
169
+ # ambient, diffuse and specular reflection high shininess
170
+ glPushMatrix()
171
+ glTranslate(1.25, 0.0, 0.0)
172
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
173
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
174
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
175
+ glMaterial(GL_FRONT, GL_SHININESS, high_shininess)
176
+ glMaterial(GL_FRONT, GL_EMISSION, no_mat)
177
+ glutSolidSphere(1.0, 16, 16)
178
+ glPopMatrix()
179
+
180
+ # draw sphere in second row, fourth column
181
+ # ambient and diffuse reflection emission no specular
182
+ glPushMatrix()
183
+ glTranslate(3.75, 0.0, 0.0)
184
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient)
185
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
186
+ glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
187
+ glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
188
+ glMaterial(GL_FRONT, GL_EMISSION, mat_emission)
189
+ glutSolidSphere(1.0, 16, 16)
190
+ glPopMatrix()
191
+
192
+ # draw sphere in third row, first column
193
+ # colored ambient and diffuse reflection no specular
194
+ glPushMatrix()
195
+ glTranslate(-3.75, -3.0, 0.0)
196
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient_color)
197
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
198
+ glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
199
+ glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
200
+ glMaterial(GL_FRONT, GL_EMISSION, no_mat)
201
+ glutSolidSphere(1.0, 16, 16)
202
+ glPopMatrix()
203
+
204
+ # draw sphere in third row, second column
205
+ # colored ambient, diffuse and specular reflection low shininess
206
+ glPushMatrix()
207
+ glTranslate(-1.25, -3.0, 0.0)
208
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient_color)
209
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
210
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
211
+ glMaterial(GL_FRONT, GL_SHININESS, low_shininess)
212
+ glMaterial(GL_FRONT, GL_EMISSION, no_mat)
213
+ glutSolidSphere(1.0, 16, 16)
214
+ glPopMatrix()
215
+
216
+ # draw sphere in third row, third column
217
+ # colored ambient, diffuse and specular reflection high shininess
218
+ glPushMatrix()
219
+ glTranslate(1.25, -3.0, 0.0)
220
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient_color)
221
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
222
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
223
+ glMaterial(GL_FRONT, GL_SHININESS, high_shininess)
224
+ glMaterial(GL_FRONT, GL_EMISSION, no_mat)
225
+ glutSolidSphere(1.0, 16, 16)
226
+ glPopMatrix()
227
+
228
+ # draw sphere in third row, fourth column
229
+ # colored ambient and diffuse reflection emission no specular
230
+ glPushMatrix()
231
+ glTranslate(3.75, -3.0, 0.0)
232
+ glMaterial(GL_FRONT, GL_AMBIENT, mat_ambient_color)
233
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
234
+ glMaterial(GL_FRONT, GL_SPECULAR, no_mat)
235
+ glMaterial(GL_FRONT, GL_SHININESS, no_shininess)
236
+ glMaterial(GL_FRONT, GL_EMISSION, mat_emission)
237
+ glutSolidSphere(1.0, 16, 16)
238
+ glPopMatrix()
239
+
240
+ glutSwapBuffers()
241
+ end
242
+
243
+ myReshape = proc do |w, h|
244
+ glViewport(0, 0, w, h)
245
+ glMatrixMode(GL_PROJECTION)
246
+ glLoadIdentity()
247
+ if (w <= (h * 2))
248
+ glOrtho(-6.0, 6.0, -3.0*(h.to_f*2)/w, 3.0*(h.to_f*2)/w, -10.0, 10.0)
249
+ else
250
+ glOrtho(-6.0*w.to_f/(h*2), 6.0*w.to_f/(h*2), -3.0, 3.0, -10.0, 10.0)
251
+ end
252
+ glMatrixMode(GL_MODELVIEW)
253
+ end
254
+
255
+ keyboard = Proc.new do |key, x, y|
256
+ case (key)
257
+ when ?\e
258
+ exit(0);
259
+ end
260
+ end
261
+
262
+ # Main Loop
263
+ # Open window with initial window size, title bar,
264
+ # RGBA display mode, and handle input events.
265
+ glutInit()
266
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
267
+ glutInitWindowSize(600, 600)
268
+ glutInitWindowPosition(100, 100)
269
+ glutCreateWindow()
270
+ myinit()
271
+ glutReshapeFunc(myReshape)
272
+ glutDisplayFunc(display)
273
+ glutKeyboardFunc(keyboard)
274
+ glutMainLoop()
275
+