ruby-opengl 0.33.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. data/Rakefile +42 -15
  2. data/doc/build_install.txt +70 -25
  3. data/doc/history.txt +4 -0
  4. data/doc/requirements_and_design.txt +2 -3
  5. data/doc/roadmap.txt +15 -2
  6. data/doc/screenshots.txt +23 -0
  7. data/doc/supplies/page_template.html +2 -1
  8. data/doc/thanks.txt +3 -0
  9. data/doc/tutorial.txt +5 -3
  10. data/examples/README +57 -7
  11. data/examples/legacy/COPYRIGHT +8 -0
  12. data/examples/{aaindex.rb → legacy/aaindex.rb} +6 -5
  13. data/examples/legacy/aapoly.rb +153 -0
  14. data/examples/legacy/aargb.rb +139 -0
  15. data/examples/legacy/accanti.rb +159 -0
  16. data/examples/legacy/accpersp.rb +216 -0
  17. data/examples/legacy/alpha.rb +133 -0
  18. data/examples/legacy/alpha3D.rb +165 -0
  19. data/examples/legacy/bezcurve.rb +107 -0
  20. data/examples/legacy/bezmesh.rb +131 -0
  21. data/examples/legacy/checker.rb +121 -0
  22. data/examples/legacy/clip.rb +104 -0
  23. data/examples/legacy/colormat.rb +145 -0
  24. data/examples/legacy/cube.rb +73 -0
  25. data/examples/legacy/depthcue.rb +101 -0
  26. data/examples/legacy/dof.rb +212 -0
  27. data/examples/legacy/double.rb +104 -0
  28. data/examples/legacy/drawf.rb +98 -0
  29. data/examples/legacy/feedback.rb +152 -0
  30. data/examples/legacy/fog.rb +172 -0
  31. data/examples/legacy/font-glut.rb +41 -0
  32. data/examples/legacy/font.rb +158 -0
  33. data/examples/legacy/hello.rb +75 -0
  34. data/examples/legacy/image.rb +145 -0
  35. data/examples/legacy/jitter.rb +209 -0
  36. data/examples/legacy/lines.rb +135 -0
  37. data/examples/legacy/list.rb +120 -0
  38. data/examples/legacy/material.rb +290 -0
  39. data/examples/legacy/mipmap.rb +159 -0
  40. data/examples/legacy/model.rb +119 -0
  41. data/examples/legacy/movelight.rb +140 -0
  42. data/examples/legacy/pickdepth.rb +180 -0
  43. data/examples/legacy/planet.rb +112 -0
  44. data/examples/legacy/quadric.rb +180 -0
  45. data/examples/legacy/readpixel.rb +59 -0
  46. data/examples/legacy/robot.rb +120 -0
  47. data/examples/legacy/select.rb +207 -0
  48. data/examples/{smooth_prev.rb → legacy/smooth.rb} +3 -2
  49. data/examples/legacy/stencil.rb +154 -0
  50. data/examples/legacy/stroke.rb +170 -0
  51. data/examples/legacy/surface.rb +170 -0
  52. data/examples/legacy/teaambient.rb +132 -0
  53. data/examples/legacy/teapots.rb +188 -0
  54. data/examples/legacy/tess.rb +222 -0
  55. data/examples/legacy/texbind.rb +157 -0
  56. data/examples/legacy/texgen.rb +171 -0
  57. data/examples/legacy/texturesurf.rb +128 -0
  58. data/examples/legacy/varray.rb +167 -0
  59. data/examples/legacy/wrap.rb +158 -0
  60. data/examples/nehe_lesson02.rb +117 -0
  61. data/examples/nehe_lesson03.rb +122 -0
  62. data/examples/nehe_lesson04.rb +133 -0
  63. data/examples/nehe_lesson05.rb +186 -0
  64. data/examples/plane.rb +1 -1
  65. data/examples/smooth.rb +4 -2
  66. data/examples/test.rb +3 -2
  67. data/ext/common/{rbogl.c → common.h} +99 -32
  68. data/ext/common/gl-enums.h +39 -1
  69. data/ext/gl/gl-1.0-1.1.c +350 -305
  70. data/ext/gl/gl-1.2.c +933 -38
  71. data/ext/gl/gl-1.3.c +725 -0
  72. data/ext/gl/gl-1.4.c +647 -0
  73. data/ext/gl/gl-1.5.c +362 -0
  74. data/ext/gl/gl-2.0.c +1632 -0
  75. data/ext/gl/gl-2.1.c +154 -0
  76. data/ext/gl/gl-enums.c +1 -2
  77. data/ext/gl/gl.c +58 -2
  78. data/ext/gl/mkrf_conf.rb +4 -1
  79. data/ext/glu/glu.c +5 -4
  80. data/ext/glu/mkrf_conf.rb +4 -1
  81. data/ext/glut/glut.c +7 -1
  82. data/ext/glut/mkrf_conf.rb +5 -0
  83. data/lib/gl_prev.rb +4 -3
  84. data/lib/glu_prev.rb +4 -3
  85. data/lib/glut_prev.rb +3 -3
  86. data/{examples/all_tests.rb → lib/opengl.rb} +9 -12
  87. data/test/README +5 -18
  88. data/test/tc_common.rb +79 -0
  89. data/test/tc_func_10_11.rb +1255 -0
  90. data/test/tc_func_12.rb +186 -0
  91. data/test/tc_func_13.rb +203 -0
  92. data/test/tc_func_14.rb +197 -0
  93. data/test/tc_func_15.rb +82 -0
  94. data/test/tc_func_20.rb +320 -0
  95. data/test/tc_func_21.rb +67 -0
  96. data/test/tc_include_gl.rb +1 -1
  97. data/test/{tc_opengl_namespace.rb → tc_misc.rb} +20 -20
  98. data/test/tc_require_gl.rb +1 -1
  99. metadata +99 -27
  100. data/ext/common/Rakefile +0 -39
  101. data/ext/common/rbogl.h +0 -52
  102. data/test/runtests.sh +0 -7
  103. data/test/tc_gl_vertex.rb +0 -180
@@ -0,0 +1,135 @@
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
+ #
38
+ #/*
39
+ # * lines.c
40
+ # * This program demonstrates geometric primitives and
41
+ # * their attributes.
42
+ # */
43
+
44
+ require "gl_prev"
45
+ require "glu_prev"
46
+ require "glut_prev"
47
+ require "mathn"
48
+
49
+ def drawOneLine(x1,y1,x2,y2)
50
+ GL.Begin(GL::LINES);
51
+ GL.Vertex((x1),(y1)); GL.Vertex((x2),(y2)); GL.End();
52
+ end
53
+
54
+ def init
55
+ GL.ClearColor(0.0, 0.0, 0.0, 0.0);
56
+ GL.ShadeModel(GL::FLAT);
57
+ end
58
+
59
+ display = Proc.new {
60
+
61
+ GL.Clear(GL::COLOR_BUFFER_BIT);
62
+
63
+ #/* select white for all lines */
64
+ GL.Color(1.0, 1.0, 1.0);
65
+
66
+ #/* in 1st row, 3 lines, each with a different stipple */
67
+ GL.Enable(GL::LINE_STIPPLE);
68
+
69
+ GL.LineStipple(1, 0x0101); # /* dotted */
70
+ drawOneLine(50.0, 125.0, 150.0, 125.0);
71
+ GL.LineStipple(1, 0x00FF); # /* dashed */
72
+ drawOneLine(150.0, 125.0, 250.0, 125.0);
73
+ GL.LineStipple(1, 0x1C47); #/* dash/dot/dash */
74
+ drawOneLine(250.0, 125.0, 350.0, 125.0);
75
+
76
+ #/* in 2nd row, 3 wide lines, each with different stipple */
77
+ GL.LineWidth (5.0);
78
+ GL.LineStipple(1, 0x0101); # /* dotted */
79
+ drawOneLine(50.0, 100.0, 150.0, 100.0);
80
+ GL.LineStipple(1, 0x00FF); # /* dashed */
81
+ drawOneLine(150.0, 100.0, 250.0, 100.0);
82
+ GL.LineStipple(1, 0x1C47); # /* dash/dot/dash */
83
+ drawOneLine(250.0, 100.0, 350.0, 100.0);
84
+ GL.LineWidth(1.0);
85
+
86
+ # /* in 3rd row, 6 lines, with dash/dot/dash stipple */
87
+ # /* as part of a single connected line strip */
88
+ GL.LineStipple(1, 0x1C47); # /* dash/dot/dash */
89
+ GL.Begin(GL::LINE_STRIP);
90
+ for i in 0..6
91
+ GL.Vertex(50.0 + (i * 50.0), 75.0);
92
+ end
93
+ GL.End();
94
+
95
+ #/* in 4th row, 6 independent lines with same stipple */
96
+ for i in 0..5
97
+ drawOneLine(50.0 + (i * 50.0), 50.0, 50.0 + ((i+1) * 50.0), 50.0);
98
+ end
99
+
100
+ # /* in 5th row, 1 line, with dash/dot/dash stipple */
101
+ # /* and a stipple repeat factor of 5 */
102
+ GL.LineStipple(5, 0x1C47); #/* dash/dot/dash */
103
+ drawOneLine(50.0, 25.0, 350.0, 25.0);
104
+
105
+ GL.Disable(GL::LINE_STIPPLE);
106
+ GL.Flush();
107
+ }
108
+
109
+ reshape = Proc.new {|w, h|
110
+ GL.Viewport(0, 0, w, h);
111
+ GL.MatrixMode(GL::PROJECTION);
112
+ GL.LoadIdentity();
113
+ GLU.Ortho2D(0.0, w, 0.0, h);
114
+ }
115
+
116
+ # /* ARGSUSED1 */
117
+ keyboard = Proc.new {|key, x, y|
118
+ case (key)
119
+ when 27
120
+ exit(0);
121
+ end
122
+ }
123
+
124
+ # int main(int argc, char** argv)
125
+ # {
126
+ GLUT.Init
127
+ GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
128
+ GLUT.InitWindowSize(400, 150);
129
+ GLUT.InitWindowPosition(100, 100);
130
+ GLUT.CreateWindow($0);
131
+ init();
132
+ GLUT.DisplayFunc(display);
133
+ GLUT.ReshapeFunc(reshape);
134
+ GLUT.KeyboardFunc(keyboard);
135
+ GLUT.MainLoop();
@@ -0,0 +1,120 @@
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
+ #
38
+ #/*
39
+ # * list.c
40
+ # * This program demonstrates how to make and execute a
41
+ # * display list. Note that attributes, such as current
42
+ # * color and matrix, are changed.
43
+ # */
44
+ require "gl_prev"
45
+ require "glu_prev"
46
+ require "glut_prev"
47
+ require "mathn"
48
+
49
+ $listName = 0;
50
+
51
+ def init
52
+ $listName = GL.GenLists(1);
53
+ GL.NewList($listName, GL::COMPILE);
54
+ GL.Color(1.0, 0.0, 0.0); # /* current color red */
55
+ GL.Begin(GL::TRIANGLES);
56
+ GL.Vertex(0.0, 0.0);
57
+ GL.Vertex(1.0, 0.0);
58
+ GL.Vertex(0.0, 1.0);
59
+ GL.End();
60
+ GL.Translate(1.5, 0.0, 0.0); # /* move position */
61
+ GL.EndList();
62
+ GL.ShadeModel(GL::FLAT);
63
+ end
64
+
65
+ def drawLine
66
+ GL.Begin(GL::LINES);
67
+ GL.Vertex(0.0, 0.5);
68
+ GL.Vertex(15.0, 0.5);
69
+ GL.End();
70
+ end
71
+
72
+ display = Proc.new {
73
+ GL.Clear(GL::COLOR_BUFFER_BIT);
74
+ GL.Color(0.0, 1.0, 0.0); # /* current color green */
75
+ for i in (0..9 ) # /* draw 10 triangles */
76
+ GL.CallList($listName);
77
+ end
78
+ drawLine(); # /* is this line green? NO! */
79
+ # /* where is the line drawn? */
80
+ GL.Flush();
81
+ }
82
+
83
+ reshape = Proc.new {|w, h|
84
+ GL.Viewport(0, 0, w, h);
85
+ GL.MatrixMode(GL::PROJECTION);
86
+ GL.LoadIdentity();
87
+ if (w <= h)
88
+ GLU.Ortho2D(0.0, 2.0, -0.5 * h/w, 1.5 * h/w);
89
+ else
90
+ GLU.Ortho2D(0.0, 2.0 * w/h, -0.5, 1.5);
91
+ end
92
+ GL.MatrixMode(GL::MODELVIEW);
93
+ GL.LoadIdentity();
94
+ }
95
+
96
+ # /* ARGSUSED1 */
97
+ keyboard = Proc.new {|key, x, y|
98
+ case (key)
99
+ when 27
100
+ exit(0);
101
+ end
102
+ }
103
+
104
+ # /* Main Loop
105
+ # * Open window with initial window size, title bar,
106
+ # * RGBA display mode, and handle input events.
107
+ # */
108
+ # int main(int argc, char** argv)
109
+ # {
110
+ GLUT.Init
111
+ GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
112
+ GLUT.InitWindowSize(650, 50);
113
+ GLUT.CreateWindow($0);
114
+ init();
115
+ GLUT.ReshapeFunc(reshape);
116
+ GLUT.DisplayFunc(display);
117
+ GLUT.KeyboardFunc(keyboard);
118
+ GLUT.MainLoop();
119
+ # return 0;
120
+ #}
@@ -0,0 +1,290 @@
1
+ #
2
+ #/* Copyright (c) Mark J. Kilgard, 1994. */
3
+ #
4
+ #/*
5
+ # * (c) Copyright 1993, Silicon Graphics, Inc.
6
+ # * ALL RIGHTS RESERVED
7
+ # * Permission to use, copy, modify, and distribute this software for
8
+ # * any purpose and without fee is hereby granted, provided that the above
9
+ # * copyright notice appear in all copies and that both the copyright notice
10
+ # * and this permission notice appear in supporting documentation, and that
11
+ # * the name of Silicon Graphics, Inc. not be used in advertising
12
+ # * or publicity pertaining to distribution of the software without specific,
13
+ # * written prior permission.
14
+ # *
15
+ # * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
16
+ # * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
17
+ # * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
18
+ # * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19
+ # * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
20
+ # * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
21
+ # * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
22
+ # * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
23
+ # * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
24
+ # * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
25
+ # * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
26
+ # * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
27
+ # *
28
+ # * US Government Users Restricted Rights
29
+ # * Use, duplication, or disclosure by the Government is subject to
30
+ # * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
31
+ # * (c)(1)(ii) of the Rights in Technical Data and Computer Software
32
+ # * clause at DFARS 252.227-7013 and/or in similar or successor
33
+ # * clauses in the FAR or the DOD or NASA FAR Supplement.
34
+ # * Unpublished-- rights reserved under the copyright laws of the
35
+ # * United States. Contractor/manufacturer is Silicon Graphics,
36
+ # * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
37
+ # *
38
+ # * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
39
+ # */
40
+ #/*
41
+ # * material.c
42
+ # * This program demonstrates the use of the GL lighting model.
43
+ # * Several objects are drawn using different material characteristics.
44
+ # * A single light source illuminates the objects.
45
+ # */
46
+
47
+ require "gl_prev"
48
+ require "glu_prev"
49
+ require "glut_prev"
50
+
51
+
52
+ #/* Initialize z-buffer, projection matrix, light source,
53
+ # * and lighting model. Do not specify a material property here.
54
+ # */
55
+ def myinit
56
+ ambient = [ 0.0, 0.0, 0.0, 1.0 ];
57
+ diffuse = [ 1.0, 1.0, 1.0, 1.0 ];
58
+ position = [ 0.0, 3.0, 2.0, 0.0 ];
59
+ lmodel_ambient = [ 0.4, 0.4, 0.4, 1.0 ];
60
+ local_view = [ 0.0 ];
61
+
62
+ GL::Enable(GL::DEPTH_TEST);
63
+ GL::DepthFunc(GL::LESS);
64
+
65
+ GL::Light(GL::LIGHT0, GL::AMBIENT, ambient);
66
+ GL::Light(GL::LIGHT0, GL::DIFFUSE, diffuse);
67
+ GL::Light(GL::LIGHT0, GL::POSITION, position);
68
+ GL::LightModel(GL::LIGHT_MODEL_AMBIENT, lmodel_ambient);
69
+ GL::LightModel(GL::LIGHT_MODEL_LOCAL_VIEWER, local_view);
70
+
71
+ GL::Enable(GL::LIGHTING);
72
+ GL::Enable(GL::LIGHT0);
73
+
74
+ GL::ClearColor(0.0, 0.1, 0.1, 0.0);
75
+ end
76
+
77
+ #/* Draw twelve spheres in 3 rows with 4 columns.
78
+ # * The spheres in the first row have materials with no ambient reflection.
79
+ # * The second row has materials with significant ambient reflection.
80
+ # * The third row has materials with colored ambient reflection.
81
+ # *
82
+ # * The first column has materials with blue, diffuse reflection only.
83
+ # * The second column has blue diffuse reflection, as well as specular
84
+ # * reflection with a low shininess exponent.
85
+ # * The third column has blue diffuse reflection, as well as specular
86
+ # * reflection with a high shininess exponent (a more concentrated highlight).
87
+ # * The fourth column has materials which also include an emissive component.
88
+ # *
89
+ # * GL::Translatef() is used to move spheres to their appropriate locations.
90
+ # */
91
+ #
92
+ display = proc {
93
+ no_mat = [ 0.0, 0.0, 0.0, 1.0 ];
94
+ mat_ambient = [ 0.7, 0.7, 0.7, 1.0 ];
95
+ mat_ambient_color = [ 0.8, 0.8, 0.2, 1.0 ];
96
+ mat_diffuse = [ 0.1, 0.5, 0.8, 1.0 ];
97
+ mat_specular = [ 1.0, 1.0, 1.0, 1.0 ];
98
+ no_shininess = [ 0.0 ];
99
+ low_shininess = [ 5.0 ];
100
+ high_shininess = [ 100.0 ];
101
+ mat_emission = [0.3, 0.2, 0.2, 0.0];
102
+
103
+ GL::Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
104
+
105
+ #/* draw sphere in first row, first column
106
+ # * diffuse reflection only; no ambient or specular
107
+ # */
108
+ GL::PushMatrix();
109
+ GL::Translate(-3.75, 3.0, 0.0);
110
+ GL::Material(GL::FRONT, GL::AMBIENT, no_mat);
111
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
112
+ GL::Material(GL::FRONT, GL::SPECULAR, no_mat);
113
+ GL::Material(GL::FRONT, GL::SHININESS, no_shininess);
114
+ GL::Material(GL::FRONT, GL::EMISSION, no_mat);
115
+ GLUT::SolidSphere(1.0, 16, 16);
116
+ GL::PopMatrix();
117
+
118
+ #/* draw sphere in first row, second column
119
+ # * diffuse and specular reflection; low shininess; no ambient
120
+ # */
121
+ GL::PushMatrix();
122
+ GL::Translate(-1.25, 3.0, 0.0);
123
+ GL::Material(GL::FRONT, GL::AMBIENT, no_mat);
124
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
125
+ GL::Material(GL::FRONT, GL::SPECULAR, mat_specular);
126
+ GL::Material(GL::FRONT, GL::SHININESS, low_shininess);
127
+ GL::Material(GL::FRONT, GL::EMISSION, no_mat);
128
+ GLUT::SolidSphere(1.0, 16, 16);
129
+ GL::PopMatrix();
130
+
131
+ #/* draw sphere in first row, third column
132
+ # * diffuse and specular reflection; high shininess; no ambient
133
+ # */
134
+ GL::PushMatrix();
135
+ GL::Translate(1.25, 3.0, 0.0);
136
+ GL::Material(GL::FRONT, GL::AMBIENT, no_mat);
137
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
138
+ GL::Material(GL::FRONT, GL::SPECULAR, mat_specular);
139
+ GL::Material(GL::FRONT, GL::SHININESS, high_shininess);
140
+ GL::Material(GL::FRONT, GL::EMISSION, no_mat);
141
+ GLUT::SolidSphere(1.0, 16, 16);
142
+ GL::PopMatrix();
143
+
144
+ #/* draw sphere in first row, fourth column
145
+ # * diffuse reflection; emission; no ambient or specular reflection
146
+ # */
147
+ GL::PushMatrix();
148
+ GL::Translate(3.75, 3.0, 0.0);
149
+ GL::Material(GL::FRONT, GL::AMBIENT, no_mat);
150
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
151
+ GL::Material(GL::FRONT, GL::SPECULAR, no_mat);
152
+ GL::Material(GL::FRONT, GL::SHININESS, no_shininess);
153
+ GL::Material(GL::FRONT, GL::EMISSION, mat_emission);
154
+ GLUT::SolidSphere(1.0, 16, 16);
155
+ GL::PopMatrix();
156
+
157
+ #/* draw sphere in second row, first column
158
+ # * ambient and diffuse reflection; no specular
159
+ # */
160
+ GL::PushMatrix();
161
+ GL::Translate(-3.75, 0.0, 0.0);
162
+ GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient);
163
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
164
+ GL::Material(GL::FRONT, GL::SPECULAR, no_mat);
165
+ GL::Material(GL::FRONT, GL::SHININESS, no_shininess);
166
+ GL::Material(GL::FRONT, GL::EMISSION, no_mat);
167
+ GLUT::SolidSphere(1.0, 16, 16);
168
+ GL::PopMatrix();
169
+
170
+ #/* draw sphere in second row, second column
171
+ # * ambient, diffuse and specular reflection; low shininess
172
+ # */
173
+ GL::PushMatrix();
174
+ GL::Translate(-1.25, 0.0, 0.0);
175
+ GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient);
176
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
177
+ GL::Material(GL::FRONT, GL::SPECULAR, mat_specular);
178
+ GL::Material(GL::FRONT, GL::SHININESS, low_shininess);
179
+ GL::Material(GL::FRONT, GL::EMISSION, no_mat);
180
+ GLUT::SolidSphere(1.0, 16, 16);
181
+ GL::PopMatrix();
182
+
183
+ #/* draw sphere in second row, third column
184
+ # * ambient, diffuse and specular reflection; high shininess
185
+ # */
186
+ GL::PushMatrix();
187
+ GL::Translate(1.25, 0.0, 0.0);
188
+ GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient);
189
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
190
+ GL::Material(GL::FRONT, GL::SPECULAR, mat_specular);
191
+ GL::Material(GL::FRONT, GL::SHININESS, high_shininess);
192
+ GL::Material(GL::FRONT, GL::EMISSION, no_mat);
193
+ GLUT::SolidSphere(1.0, 16, 16);
194
+ GL::PopMatrix();
195
+
196
+ #/* draw sphere in second row, fourth column
197
+ # * ambient and diffuse reflection; emission; no specular
198
+ # */
199
+ GL::PushMatrix();
200
+ GL::Translate(3.75, 0.0, 0.0);
201
+ GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient);
202
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
203
+ GL::Material(GL::FRONT, GL::SPECULAR, no_mat);
204
+ GL::Material(GL::FRONT, GL::SHININESS, no_shininess);
205
+ GL::Material(GL::FRONT, GL::EMISSION, mat_emission);
206
+ GLUT::SolidSphere(1.0, 16, 16);
207
+ GL::PopMatrix();
208
+
209
+ #/* draw sphere in third row, first column
210
+ # * colored ambient and diffuse reflection; no specular
211
+ # */
212
+ GL::PushMatrix();
213
+ GL::Translate(-3.75, -3.0, 0.0);
214
+ GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient_color);
215
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
216
+ GL::Material(GL::FRONT, GL::SPECULAR, no_mat);
217
+ GL::Material(GL::FRONT, GL::SHININESS, no_shininess);
218
+ GL::Material(GL::FRONT, GL::EMISSION, no_mat);
219
+ GLUT::SolidSphere(1.0, 16, 16);
220
+ GL::PopMatrix();
221
+
222
+ #/* draw sphere in third row, second column
223
+ # * colored ambient, diffuse and specular reflection; low shininess
224
+ # */
225
+ GL::PushMatrix();
226
+ GL::Translate(-1.25, -3.0, 0.0);
227
+ GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient_color);
228
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
229
+ GL::Material(GL::FRONT, GL::SPECULAR, mat_specular);
230
+ GL::Material(GL::FRONT, GL::SHININESS, low_shininess);
231
+ GL::Material(GL::FRONT, GL::EMISSION, no_mat);
232
+ GLUT::SolidSphere(1.0, 16, 16);
233
+ GL::PopMatrix();
234
+
235
+ #/* draw sphere in third row, third column
236
+ # * colored ambient, diffuse and specular reflection; high shininess
237
+ # */
238
+ GL::PushMatrix();
239
+ GL::Translate(1.25, -3.0, 0.0);
240
+ GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient_color);
241
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
242
+ GL::Material(GL::FRONT, GL::SPECULAR, mat_specular);
243
+ GL::Material(GL::FRONT, GL::SHININESS, high_shininess);
244
+ GL::Material(GL::FRONT, GL::EMISSION, no_mat);
245
+ GLUT::SolidSphere(1.0, 16, 16);
246
+ GL::PopMatrix();
247
+
248
+ #/* draw sphere in third row, fourth column
249
+ # * colored ambient and diffuse reflection; emission; no specular
250
+ # */
251
+ GL::PushMatrix();
252
+ GL::Translate(3.75, -3.0, 0.0);
253
+ GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient_color);
254
+ GL::Material(GL::FRONT, GL::DIFFUSE, mat_diffuse);
255
+ GL::Material(GL::FRONT, GL::SPECULAR, no_mat);
256
+ GL::Material(GL::FRONT, GL::SHININESS, no_shininess);
257
+ GL::Material(GL::FRONT, GL::EMISSION, mat_emission);
258
+ GLUT::SolidSphere(1.0, 16, 16);
259
+ GL::PopMatrix();
260
+
261
+ GL::Flush();
262
+ }
263
+
264
+ myReshape = proc {|w, h|
265
+ GL::Viewport(0, 0, w, h);
266
+ GL::MatrixMode(GL::PROJECTION);
267
+ GL::LoadIdentity();
268
+ if (w <= (h * 2))
269
+ GL::Ortho(-6.0, 6.0, -3.0*(h.to_f*2)/w,
270
+ 3.0*(h.to_f*2)/w, -10.0, 10.0);
271
+ else
272
+ GL::Ortho(-6.0*w.to_f/(h*2),
273
+ 6.0*w.to_f/(h*2), -3.0, 3.0, -10.0, 10.0);
274
+ end
275
+ GL::MatrixMode(GL::MODELVIEW);
276
+ }
277
+
278
+ #/* Main Loop
279
+ # * Open window with initial window size, title bar,
280
+ # * RGBA display mode, and handle input events.
281
+ # */
282
+ GLUT::Init();
283
+ GLUT::InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
284
+ GLUT::InitWindowSize(600, 450);
285
+ GLUT::CreateWindow();
286
+ myinit();
287
+ GLUT::ReshapeFunc(myReshape);
288
+ GLUT::DisplayFunc(display);
289
+ GLUT::MainLoop();
290
+