ruby-opengl 0.40.1 → 0.50.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/Rakefile +2 -2
  2. data/doc/build_install.txt +48 -28
  3. data/doc/extensions.txt +361 -0
  4. data/doc/history.txt +8 -2
  5. data/doc/requirements_and_design.txt +0 -13
  6. data/doc/roadmap.txt +11 -13
  7. data/doc/supplies/page_template.html +11 -5
  8. data/doc/thanks.txt +2 -4
  9. data/doc/tutorial.txt +1 -4
  10. data/examples/{nehe_lesson02.rb → NeHe/nehe_lesson02.rb} +0 -0
  11. data/examples/{nehe_lesson03.rb → NeHe/nehe_lesson03.rb} +0 -0
  12. data/examples/{nehe_lesson04.rb → NeHe/nehe_lesson04.rb} +0 -0
  13. data/examples/{nehe_lesson05.rb → NeHe/nehe_lesson05.rb} +0 -0
  14. data/examples/NeHe/nehe_lesson36.rb +303 -0
  15. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  16. data/examples/OrangeBook/brick.frag +36 -0
  17. data/examples/OrangeBook/brick.rb +388 -0
  18. data/examples/OrangeBook/brick.vert +41 -0
  19. data/examples/OrangeBook/particle.frag +17 -0
  20. data/examples/OrangeBook/particle.rb +424 -0
  21. data/examples/OrangeBook/particle.vert +38 -0
  22. data/examples/README +13 -83
  23. data/examples/RedBook/aaindex.rb +97 -0
  24. data/examples/RedBook/aapoly.rb +142 -0
  25. data/examples/RedBook/aargb.rb +119 -0
  26. data/examples/RedBook/accanti.rb +162 -0
  27. data/examples/RedBook/accpersp.rb +215 -0
  28. data/examples/RedBook/alpha.rb +123 -0
  29. data/examples/RedBook/alpha3D.rb +158 -0
  30. data/examples/RedBook/bezcurve.rb +105 -0
  31. data/examples/RedBook/bezmesh.rb +137 -0
  32. data/examples/RedBook/checker.rb +124 -0
  33. data/examples/RedBook/clip.rb +95 -0
  34. data/examples/RedBook/colormat.rb +135 -0
  35. data/examples/RedBook/cube.rb +69 -0
  36. data/examples/RedBook/depthcue.rb +99 -0
  37. data/examples/RedBook/dof.rb +205 -0
  38. data/examples/{legacy → RedBook}/double.rb +59 -58
  39. data/examples/{legacy → RedBook}/drawf.rb +47 -54
  40. data/examples/RedBook/feedback.rb +145 -0
  41. data/examples/RedBook/fog.rb +167 -0
  42. data/examples/RedBook/font.rb +151 -0
  43. data/examples/RedBook/hello.rb +79 -0
  44. data/examples/RedBook/image.rb +137 -0
  45. data/examples/{legacy → RedBook}/jitter.rb +60 -62
  46. data/examples/RedBook/lines.rb +128 -0
  47. data/examples/RedBook/list.rb +111 -0
  48. data/examples/RedBook/material.rb +275 -0
  49. data/examples/RedBook/mipmap.rb +156 -0
  50. data/examples/{legacy → RedBook}/model.rb +66 -72
  51. data/examples/{legacy → RedBook}/movelight.rb +67 -75
  52. data/examples/RedBook/pickdepth.rb +179 -0
  53. data/examples/{legacy → RedBook}/planet.rb +62 -66
  54. data/examples/RedBook/quadric.rb +158 -0
  55. data/examples/RedBook/robot.rb +115 -0
  56. data/examples/RedBook/select.rb +196 -0
  57. data/examples/RedBook/smooth.rb +95 -0
  58. data/examples/RedBook/stencil.rb +163 -0
  59. data/examples/RedBook/stroke.rb +167 -0
  60. data/examples/RedBook/surface.rb +166 -0
  61. data/examples/RedBook/teaambient.rb +132 -0
  62. data/examples/RedBook/teapots.rb +182 -0
  63. data/examples/RedBook/tess.rb +183 -0
  64. data/examples/RedBook/texbind.rb +147 -0
  65. data/examples/RedBook/texgen.rb +169 -0
  66. data/examples/RedBook/texturesurf.rb +128 -0
  67. data/examples/RedBook/varray.rb +159 -0
  68. data/examples/RedBook/wrap.rb +148 -0
  69. data/examples/misc/anisotropic.rb +194 -0
  70. data/examples/misc/font-glut.rb +46 -0
  71. data/examples/{plane.rb → misc/plane.rb} +0 -0
  72. data/examples/misc/readpixel.rb +65 -0
  73. data/examples/{smooth.rb → misc/smooth.rb} +0 -0
  74. data/examples/{test.rb → misc/test.rb} +0 -0
  75. data/ext/common/common.h +252 -70
  76. data/ext/common/gl-enums.h +6102 -7334
  77. data/ext/common/gl-types.h +47 -0
  78. data/ext/common/glu-enums.h +469 -0
  79. data/ext/gl/gl-1.0-1.1.c +842 -2464
  80. data/ext/gl/gl-1.2.c +217 -281
  81. data/ext/gl/gl-1.3.c +113 -133
  82. data/ext/gl/gl-1.4.c +98 -334
  83. data/ext/gl/gl-1.5.c +28 -34
  84. data/ext/gl/gl-2.0.c +26 -235
  85. data/ext/gl/gl-2.1.c +31 -124
  86. data/ext/gl/gl-enums.c +786 -631
  87. data/ext/gl/gl-ext-arb.c +66 -0
  88. data/ext/gl/gl-ext-ext.c +218 -0
  89. data/ext/gl/gl.c +138 -31
  90. data/ext/gl/mkrf_conf.rb +1 -0
  91. data/ext/glu/glu-enums.c +163 -0
  92. data/ext/glu/glu.c +1003 -1205
  93. data/ext/glu/mkrf_conf.rb +1 -0
  94. data/ext/glut/glut.c +1056 -1175
  95. data/lib/opengl.rb +90 -3
  96. data/test/tc_common.rb +26 -13
  97. data/test/tc_ext_arb.rb +73 -0
  98. data/test/tc_ext_ext.rb +74 -0
  99. data/test/tc_func_12.rb +8 -8
  100. data/test/tc_func_13.rb +17 -11
  101. data/test/tc_func_14.rb +8 -8
  102. data/test/tc_func_15.rb +190 -2
  103. data/test/tc_func_20.rb +36 -10
  104. data/test/tc_func_21.rb +445 -2
  105. data/test/tc_glu.rb +305 -0
  106. data/test/tc_misc.rb +1 -0
  107. metadata +84 -68
  108. data/doc/screenshots.txt +0 -23
  109. data/examples/legacy/COPYRIGHT +0 -8
  110. data/examples/legacy/aaindex.rb +0 -98
  111. data/examples/legacy/aapoly.rb +0 -153
  112. data/examples/legacy/aargb.rb +0 -139
  113. data/examples/legacy/accanti.rb +0 -159
  114. data/examples/legacy/accpersp.rb +0 -216
  115. data/examples/legacy/alpha.rb +0 -133
  116. data/examples/legacy/alpha3D.rb +0 -165
  117. data/examples/legacy/bezcurve.rb +0 -107
  118. data/examples/legacy/bezmesh.rb +0 -131
  119. data/examples/legacy/checker.rb +0 -121
  120. data/examples/legacy/clip.rb +0 -104
  121. data/examples/legacy/colormat.rb +0 -145
  122. data/examples/legacy/cube.rb +0 -73
  123. data/examples/legacy/depthcue.rb +0 -101
  124. data/examples/legacy/dof.rb +0 -212
  125. data/examples/legacy/feedback.rb +0 -152
  126. data/examples/legacy/fog.rb +0 -172
  127. data/examples/legacy/font-glut.rb +0 -41
  128. data/examples/legacy/font.rb +0 -158
  129. data/examples/legacy/hello.rb +0 -75
  130. data/examples/legacy/image.rb +0 -145
  131. data/examples/legacy/lines.rb +0 -135
  132. data/examples/legacy/list.rb +0 -120
  133. data/examples/legacy/material.rb +0 -290
  134. data/examples/legacy/mipmap.rb +0 -159
  135. data/examples/legacy/pickdepth.rb +0 -180
  136. data/examples/legacy/quadric.rb +0 -180
  137. data/examples/legacy/readpixel.rb +0 -59
  138. data/examples/legacy/robot.rb +0 -120
  139. data/examples/legacy/select.rb +0 -207
  140. data/examples/legacy/smooth.rb +0 -41
  141. data/examples/legacy/stencil.rb +0 -154
  142. data/examples/legacy/stroke.rb +0 -170
  143. data/examples/legacy/surface.rb +0 -170
  144. data/examples/legacy/teaambient.rb +0 -132
  145. data/examples/legacy/teapots.rb +0 -188
  146. data/examples/legacy/tess.rb +0 -222
  147. data/examples/legacy/texbind.rb +0 -157
  148. data/examples/legacy/texgen.rb +0 -171
  149. data/examples/legacy/texturesurf.rb +0 -128
  150. data/examples/legacy/varray.rb +0 -167
  151. data/examples/legacy/wrap.rb +0 -158
  152. data/lib/gl_prev.rb +0 -46
  153. data/lib/glu_prev.rb +0 -46
  154. data/lib/glut_prev.rb +0 -45
@@ -1,216 +0,0 @@
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
- #/* accpersp.c
39
- # * Use the accumulation buffer to do full-scene antialiasing
40
- # * on a scene with perspective projection, using the special
41
- # * routines accFrustum() and accPerspective().
42
- # */
43
- require "gl_prev"
44
- require "glu_prev"
45
- require "glut_prev"
46
-
47
-
48
- $LOAD_PATH.push(File.dirname($0)) # Find jitter in script directory
49
-
50
- PI_=3.14159265358979323846
51
-
52
- #/* accFrustum()
53
- # * The first 6 arguments are identical to the glFrustum() call.
54
- # *
55
- # * pixdx and pixdy are anti-alias jitter in pixels.
56
- # * Set both equal to 0.0 for no anti-alias jitter.
57
- # * eyedx and eyedy are depth-of field jitter in pixels.
58
- # * Set both equal to 0.0 for no depth of field effects.
59
- # *
60
- # * focus is distance from eye to plane in focus.
61
- # * focus must be greater than, but not equal to 0.0.
62
- # *
63
- # * Note that accFrustum() calls glTranslatef(). You will
64
- # * probably want to insure that your ModelView matrix has been
65
- # * initialized to identity before calling accFrustum().
66
- # */
67
- def accFrustum(left, right, bottom, top, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
68
-
69
- viewport = GL::GetDoublev(GL::VIEWPORT);
70
-
71
- xwsize = right - left;
72
- ywsize = top - bottom;
73
-
74
- dx = -(pixdx*xwsize/viewport[2] + eyedx*nnear/focus);
75
- dy = -(pixdy*ywsize/viewport[3] + eyedy*nnear/focus);
76
-
77
- GL::MatrixMode(GL::PROJECTION);
78
- GL::LoadIdentity();
79
- GL::Frustum(left + dx, right + dx, bottom + dy, top + dy, nnear, ffar);
80
- GL::MatrixMode(GL::MODELVIEW);
81
- GL::LoadIdentity();
82
- GL::Translate(-eyedx, -eyedy, 0.0);
83
- end
84
-
85
- #/* accPerspective()
86
- # *
87
- # * The first 4 arguments are identical to the gluPerspective() call.
88
- # * pixdx and pixdy are anti-alias jitter in pixels.
89
- # * Set both equal to 0.0 for no anti-alias jitter.
90
- # * eyedx and eyedy are depth-of field jitter in pixels.
91
- # * Set both equal to 0.0 for no depth of field effects.
92
- # *
93
- # * focus is distance from eye to plane in focus.
94
- # * focus must be greater than, but not equal to 0.0.
95
- # *
96
- # * Note that accPerspective() calls accFrustum().
97
- # */
98
- def accPerspective(fovy, aspect, nnear, ffar, pixdx, pixdy, eyedx, eyedy, focus)
99
- fov2 = ((fovy*PI_) / 180.0) / 2.0;
100
-
101
- top = nnear / (Math::cos(fov2) / Math::sin(fov2));
102
- bottom = -top;
103
-
104
- right = top * aspect;
105
- left = -right;
106
-
107
- accFrustum(left, right, bottom, top, nnear, ffar,
108
- pixdx, pixdy, eyedx, eyedy, focus);
109
- end
110
-
111
- #/* Initialize lighting and other values.
112
- # */
113
- def init
114
- mat_ambient = [ 1.0, 1.0, 1.0, 1.0 ];
115
- mat_specular = [ 1.0, 1.0, 1.0, 1.0 ];
116
- light_position = [ 0.0, 0.0, 10.0, 1.0 ];
117
- lm_ambient = [ 0.2, 0.2, 0.2, 1.0 ];
118
-
119
- GL::Material(GL::FRONT, GL::AMBIENT, mat_ambient);
120
- GL::Material(GL::FRONT, GL::SPECULAR, mat_specular);
121
- GL::Material(GL::FRONT, GL::SHININESS, 50.0);
122
- GL::Light(GL::LIGHT0, GL::POSITION, light_position);
123
- GL::LightModel(GL::LIGHT_MODEL_AMBIENT, lm_ambient);
124
-
125
- GL::Enable(GL::LIGHTING);
126
- GL::Enable(GL::LIGHT0);
127
- GL::Enable(GL::DEPTH_TEST);
128
- GL::ShadeModel(GL::FLAT);
129
-
130
- GL::ClearColor(0.0, 0.0, 0.0, 0.0);
131
- GL::ClearAccum(0.0, 0.0, 0.0, 0.0);
132
- end
133
-
134
- def displayObjects
135
- torus_diffuse = [ 0.7, 0.7, 0.0, 1.0 ];
136
- cube_diffuse = [ 0.0, 0.7, 0.7, 1.0 ];
137
- sphere_diffuse = [ 0.7, 0.0, 0.7, 1.0 ];
138
- octa_diffuse = [ 0.7, 0.4, 0.4, 1.0 ];
139
-
140
- GL::PushMatrix();
141
- GL::Translate(0.0, 0.0, -5.0);
142
- GL::Rotate(30.0, 1.0, 0.0, 0.0);
143
-
144
- GL::PushMatrix();
145
- GL::Translate(-0.80, 0.35, 0.0);
146
- GL::Rotate(100.0, 1.0, 0.0, 0.0);
147
- GL::Material(GL::FRONT, GL::DIFFUSE, torus_diffuse);
148
- GLUT::SolidTorus(0.275, 0.85, 16, 16);
149
- GL::PopMatrix();
150
-
151
- GL::PushMatrix();
152
- GL::Translate(-0.75, -0.50, 0.0);
153
- GL::Rotate(45.0, 0.0, 0.0, 1.0);
154
- GL::Rotate(45.0, 1.0, 0.0, 0.0);
155
- GL::Material(GL::FRONT, GL::DIFFUSE, cube_diffuse);
156
- GLUT::SolidCube(1.5);
157
- GL::PopMatrix();
158
-
159
- GL::PushMatrix();
160
- GL::Translate(0.75, 0.60, 0.0);
161
- GL::Rotate(30.0, 1.0, 0.0, 0.0);
162
- GL::Material(GL::FRONT, GL::DIFFUSE, sphere_diffuse);
163
- GLUT::SolidSphere(1.0, 16, 16);
164
- GL::PopMatrix();
165
-
166
- GL::PushMatrix();
167
- GL::Translate(0.70, -0.90, 0.25);
168
- GL::Material(GL::FRONT, GL::DIFFUSE, octa_diffuse);
169
- GLUT::SolidOctahedron();
170
- GL::PopMatrix();
171
-
172
- GL::PopMatrix();
173
- end
174
-
175
- ACSIZE=8
176
-
177
- display = proc {
178
- viewport = GL::GetDoublev(GL::VIEWPORT);
179
-
180
- GL::Clear(GL::ACCUM_BUFFER_BIT);
181
- for jitter in 0...ACSIZE
182
- GL::Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
183
- accPerspective(50.0, viewport[2]/ viewport[3],
184
- 1.0, 15.0, $j8[jitter][0], $j8[jitter][1], 0.0, 0.0, 1.0);
185
- displayObjects();
186
- GL::Accum(GL::ACCUM, 1.0/ACSIZE);
187
- end
188
- GL::Accum(GL::RETURN, 1.0);
189
- GL::Flush();
190
- }
191
-
192
- reshape = proc {|w, h|
193
- GL::Viewport(0, 0, w, h);
194
- }
195
-
196
- # /* ARGSUSED1 */
197
- keyboard = proc {|key, x, y|
198
- case (key)
199
- when 27
200
- exit(0);
201
- end
202
- }
203
-
204
- #/* Main Loop
205
- # * Be certain you request an accumulation buffer.
206
- # */
207
- GLUT.Init
208
- GLUT::InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::ACCUM | GLUT::DEPTH);
209
- GLUT::InitWindowSize(250, 250);
210
- GLUT::InitWindowPosition(100, 100);
211
- GLUT::CreateWindow($0)
212
- init();
213
- GLUT::ReshapeFunc(reshape);
214
- GLUT::DisplayFunc(display);
215
- GLUT::KeyboardFunc(keyboard);
216
- GLUT::MainLoop();
@@ -1,133 +0,0 @@
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
- # * alpha.c
40
- # * This program draws several overlapping filled polygons
41
- # * to demonstrate the effect order has on alpha blending results.
42
- # * Use the 't' key to toggle the order of drawing polygons.
43
- # */
44
-
45
- require "gl_prev"
46
- require "glu_prev"
47
- require "glut_prev"
48
- require "mathn"
49
-
50
- $leftFirst = GL::TRUE;
51
-
52
- #/* Initialize alpha blending function.
53
- # */
54
- def init
55
- GL.Enable(GL::BLEND);
56
- GL.BlendFunc(GL::SRC_ALPHA, GL::ONE_MINUS_SRC_ALPHA);
57
- GL.ShadeModel(GL::FLAT);
58
- GL.ClearColor(0.0, 0.0, 0.0, 0.0);
59
- end
60
-
61
- def drawLeftTriangle
62
- #/* draw yellow triangle on LHS of screen */
63
-
64
- GL.Begin(GL::TRIANGLES);
65
- GL.Color(1.0, 1.0, 0.0, 0.75);
66
- GL.Vertex(0.1, 0.9, 0.0);
67
- GL.Vertex(0.1, 0.1, 0.0);
68
- GL.Vertex(0.7, 0.5, 0.0);
69
- GL.End();
70
- end
71
-
72
- def drawRightTriangle
73
- #/* draw cyan triangle on RHS of screen */
74
-
75
- GL.Begin(GL::TRIANGLES);
76
- GL.Color(0.0, 1.0, 1.0, 0.75);
77
- GL.Vertex(0.9, 0.9, 0.0);
78
- GL.Vertex(0.3, 0.5, 0.0);
79
- GL.Vertex(0.9, 0.1, 0.0);
80
- GL.End();
81
- end
82
-
83
- display = Proc.new {
84
- GL.Clear(GL::COLOR_BUFFER_BIT);
85
-
86
- if ($leftFirst)
87
- drawLeftTriangle();
88
- drawRightTriangle();
89
- else
90
- drawRightTriangle();
91
- drawLeftTriangle();
92
- end
93
-
94
- GL.Flush();
95
- }
96
-
97
- reshape = Proc.new {|w, h|
98
- GL.Viewport(0, 0, w, h);
99
- GL.MatrixMode(GL::PROJECTION);
100
- GL.LoadIdentity();
101
- if (w <= h)
102
- GLU.Ortho2D(0.0, 1.0, 0.0, 1.0*h/w);
103
- else
104
- GLU.Ortho2D(0.0, 1.0*w/h, 0.0, 1.0);
105
- end
106
- }
107
-
108
- # /* ARGSUSED1 */
109
- keyboard = Proc.new {|key, x, y|
110
- case (key)
111
- when 't'[0],'T'[0]
112
- $leftFirst = !$leftFirst;
113
- GLUT.PostRedisplay();
114
- when 27 # /* Escape key */
115
- exit(0);
116
- end
117
- }
118
-
119
- #/* Main Loop
120
- # * Open window with initial window size, title bar,
121
- # * RGBA display mode, and handle input events.
122
- # */
123
- #int main(int argc, char** argv)
124
- #{
125
- GLUT.Init
126
- GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
127
- GLUT.InitWindowSize(200, 200);
128
- GLUT.CreateWindow($0);
129
- init();
130
- GLUT.ReshapeFunc(reshape);
131
- GLUT.KeyboardFunc(keyboard);
132
- GLUT.DisplayFunc(display);
133
- GLUT.MainLoop();
@@ -1,165 +0,0 @@
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
- # * alpha3D.c
40
- # * This program demonstrates how to intermix opaque and
41
- # * alpha blended polygons in the same scene, by using
42
- # * glDepthMask. Press the 'a' key to animate moving the
43
- # * transparent object through the opaque object. Press
44
- # * the 'r' key to reset the scene.
45
- # */
46
- require "gl_prev"
47
- require "glu_prev"
48
- require "glut_prev"
49
-
50
-
51
- MAXZ=8.0
52
- MINZ=-8.0
53
- ZINC=0.4
54
-
55
- $solidZ = MAXZ;
56
- $transparentZ = MINZ;
57
- $sphereList=nil
58
- $cubeList=nil
59
-
60
- def init
61
- mat_specular = [ 1.0, 1.0, 1.0, 0.15 ];
62
- mat_shininess = [ 100.0 ];
63
- position = [ 0.5, 0.5, 1.0, 0.0 ];
64
-
65
- GL::Material(GL::FRONT, GL::SPECULAR, mat_specular);
66
- GL::Material(GL::FRONT, GL::SHININESS, mat_shininess);
67
- GL::Light(GL::LIGHT0, GL::POSITION, position);
68
-
69
- GL::Enable(GL::LIGHTING);
70
- GL::Enable(GL::LIGHT0);
71
- GL::Enable(GL::DEPTH_TEST);
72
-
73
- $sphereList = GL::GenLists(1);
74
- GL::NewList($sphereList, GL::COMPILE);
75
- GLUT::SolidSphere(0.4, 16, 16);
76
- GL::EndList();
77
-
78
- $cubeList = GL::GenLists(1);
79
- GL::NewList($cubeList, GL::COMPILE);
80
- GLUT::SolidCube(0.6);
81
- GL::EndList();
82
- end
83
-
84
- display = proc {
85
- mat_solid = [ 0.75, 0.75, 0.0, 1.0 ];
86
- mat_zero = [ 0.0, 0.0, 0.0, 1.0 ];
87
- mat_transparent = [ 0.0, 0.8, 0.8, 0.6 ];
88
- mat_emission = [ 0.0, 0.3, 0.3, 0.6 ];
89
-
90
- GL::Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
91
-
92
- GL::PushMatrix();
93
- GL::Translate(-0.15, -0.15, $solidZ);
94
- GL::Material(GL::FRONT, GL::EMISSION, mat_zero);
95
- GL::Material(GL::FRONT, GL::DIFFUSE, mat_solid);
96
- GL::CallList($sphereList);
97
- GL::PopMatrix();
98
-
99
- GL::PushMatrix();
100
- GL::Translate(0.15, 0.15, $transparentZ);
101
- GL::Rotate(15.0, 1.0, 1.0, 0.0);
102
- GL::Rotate(30.0, 0.0, 1.0, 0.0);
103
- GL::Material(GL::FRONT, GL::EMISSION, mat_emission);
104
- GL::Material(GL::FRONT, GL::DIFFUSE, mat_transparent);
105
- GL::Enable(GL::BLEND);
106
- GL::DepthMask(GL::FALSE);
107
- GL::BlendFunc(GL::SRC_ALPHA, GL::ONE);
108
- GL::CallList($cubeList);
109
- GL::DepthMask(GL::TRUE);
110
- GL::Disable(GL::BLEND);
111
- GL::PopMatrix();
112
-
113
- GL::Flush();
114
- }
115
-
116
- reshape = proc {|w, h|
117
- GL::Viewport(0, 0, w, h);
118
- GL::MatrixMode(GL::PROJECTION);
119
- GL::LoadIdentity();
120
- if (w <= h)
121
- GL::Ortho(-1.5, 1.5, -1.5*h.to_f/w,
122
- 1.5*h.to_f/w, -10.0, 10.0);
123
- else
124
- GL::Ortho(-1.5*w.to_f/h,
125
- 1.5*w.to_f/h, -1.5, 1.5, -10.0, 10.0);
126
- end
127
- GL::MatrixMode(GL::MODELVIEW);
128
- GL::LoadIdentity();
129
- }
130
-
131
- animate = proc {
132
- if ($solidZ <= MINZ || $transparentZ >= MAXZ)
133
- GLUT::IdleFunc(nil);
134
- else
135
- $solidZ -= ZINC;
136
- $transparentZ += ZINC;
137
- GLUT::PostRedisplay();
138
- end
139
- }
140
-
141
- # /* ARGSUSED1 */
142
- keyboard = proc {|key, x, y|
143
- case (key)
144
- when ?a,?A
145
- $solidZ = MAXZ;
146
- $transparentZ = MINZ;
147
- GLUT::IdleFunc(animate);
148
- when ?r, ?R
149
- $solidZ = MAXZ;
150
- $transparentZ = MINZ;
151
- GLUT::PostRedisplay();
152
- when 27
153
- exit(0);
154
- end
155
- }
156
-
157
- GLUT::Init()
158
- GLUT::InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
159
- GLUT::InitWindowSize(500, 500);
160
- GLUT::CreateWindow($0)
161
- init();
162
- GLUT::ReshapeFunc(reshape);
163
- GLUT::KeyboardFunc(keyboard);
164
- GLUT::DisplayFunc(display);
165
- GLUT::MainLoop();