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,290 +0,0 @@
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
-
@@ -1,159 +0,0 @@
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
- #/* mipmap.c
41
- # * This program demonstrates using mipmaps for texture maps.
42
- # * To overtly show the effect of mipmaps, each mipmap reduction
43
- # * level has a solidly colored, contrasting texture image.
44
- # * Thus, the quadrilateral which is drawn is drawn with several
45
- # * different colors.
46
- # */
47
-
48
- require "gl_prev"
49
- require "glu_prev"
50
- require "glut_prev"
51
- require "mathn"
52
-
53
- $mipmapImage32 = []
54
- $mipmapImage16 = []
55
- $mipmapImage8 = []
56
- $mipmapImage4 = []
57
- $mipmapImage2 = []
58
- $mipmapImage1 = []
59
-
60
- def makeImages
61
- for i in 0..31
62
- for j in 0..31
63
- $mipmapImage32[(j*32+i)*3+0] = 255;
64
- $mipmapImage32[(j*32+i)*3+1] = 255;
65
- $mipmapImage32[(j*32+i)*3+2] = 0;
66
- end
67
- end
68
- for i in 0..15
69
- for j in 0..15
70
- $mipmapImage16[(j*16+i)*3+0] = 255;
71
- $mipmapImage16[(j*16+i)*3+1] = 0;
72
- $mipmapImage16[(j*16+i)*3+2] = 255;
73
- end
74
- end
75
- for i in 0..7
76
- for j in 0..7
77
- $mipmapImage8[(j*8+i)*3+0] = 255;
78
- $mipmapImage8[(j*8+i)*3+1] = 0;
79
- $mipmapImage8[(j*8+i)*3+2] = 0;
80
- end
81
- end
82
- for i in 0..3
83
- for j in 0..3
84
- $mipmapImage4[(j*4+i)*3+0] = 0;
85
- $mipmapImage4[(j*4+i)*3+1] = 255;
86
- $mipmapImage4[(j*4+i)*3+2] = 0;
87
- end
88
- end
89
- for i in 0..1
90
- for j in 0..1
91
- $mipmapImage2[(j*2+i)*3+0] = 0;
92
- $mipmapImage2[(j*2+i)*3+1] = 0;
93
- $mipmapImage2[(j*2+i)*3+2] = 255;
94
- end
95
- end
96
- $mipmapImage1[0] = 255;
97
- $mipmapImage1[1] = 255;
98
- $mipmapImage1[2] = 255;
99
- end
100
-
101
- def myinit
102
- GL.Enable(GL::DEPTH_TEST);
103
- GL.DepthFunc(GL::LESS);
104
- GL.ShadeModel(GL::FLAT);
105
-
106
- GL.Translate(0.0, 0.0, -3.6);
107
- makeImages();
108
- GL.PixelStore(GL::UNPACK_ALIGNMENT, 1);
109
- GL.TexImage2D(GL::TEXTURE_2D, 0, 3, 32, 32, 0,
110
- GL::RGB, GL::UNSIGNED_BYTE, $mipmapImage32.pack("C*"));
111
- GL.TexImage2D(GL::TEXTURE_2D, 1, 3, 16, 16, 0,
112
- GL::RGB, GL::UNSIGNED_BYTE, $mipmapImage16.pack("C*"));
113
- GL.TexImage2D(GL::TEXTURE_2D, 2, 3, 8, 8, 0,
114
- GL::RGB, GL::UNSIGNED_BYTE, $mipmapImage8.pack("C*"));
115
- GL.TexImage2D(GL::TEXTURE_2D, 3, 3, 4, 4, 0,
116
- GL::RGB, GL::UNSIGNED_BYTE, $mipmapImage4.pack("C*"));
117
- GL.TexImage2D(GL::TEXTURE_2D, 4, 3, 2, 2, 0,
118
- GL::RGB, GL::UNSIGNED_BYTE, $mipmapImage2.pack("C*"));
119
- GL.TexImage2D(GL::TEXTURE_2D, 5, 3, 1, 1, 0,
120
- GL::RGB, GL::UNSIGNED_BYTE, $mipmapImage1.pack("C*"));
121
- GL.TexParameter(GL::TEXTURE_2D, GL::TEXTURE_WRAP_S, GL::REPEAT);
122
- GL.TexParameter(GL::TEXTURE_2D, GL::TEXTURE_WRAP_T, GL::REPEAT);
123
- GL.TexParameter(GL::TEXTURE_2D, GL::TEXTURE_MAG_FILTER, GL::NEAREST);
124
- GL.TexParameter(GL::TEXTURE_2D, GL::TEXTURE_MIN_FILTER,
125
- GL::NEAREST_MIPMAP_NEAREST);
126
- GL.TexEnv(GL::TEXTURE_ENV, GL::TEXTURE_ENV_MODE, GL::DECAL);
127
- GL.Enable(GL::TEXTURE_2D);
128
- end
129
-
130
- display = Proc.new {
131
- GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
132
- GL.Begin(GL::QUADS);
133
- GL.TexCoord(0.0, 0.0); GL.Vertex(-2.0, -1.0, 0.0);
134
- GL.TexCoord(0.0, 8.0); GL.Vertex(-2.0, 1.0, 0.0);
135
- GL.TexCoord(8.0, 8.0); GL.Vertex(2000.0, 1.0, -6000.0);
136
- GL.TexCoord(8.0, 0.0); GL.Vertex(2000.0, -1.0, -6000.0);
137
- GL.End();
138
- GL.Flush();
139
- }
140
-
141
- myReshape = Proc.new {|w, h|
142
- GL.Viewport(0, 0, w, h);
143
- GL.MatrixMode(GL::PROJECTION);
144
- GL.LoadIdentity();
145
- GLU.Perspective(60.0, 1.0*w/h, 1.0, 30000.0);
146
- GL.MatrixMode(GL::MODELVIEW);
147
- GL.LoadIdentity();
148
- }
149
-
150
- #int main(int argc, char** argv)
151
- #{
152
- GLUT.Init
153
- GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
154
- GLUT.InitWindowSize(500, 500);
155
- GLUT.CreateWindow($0);
156
- myinit();
157
- GLUT.ReshapeFunc(myReshape);
158
- GLUT.DisplayFunc(display);
159
- GLUT.MainLoop();
@@ -1,180 +0,0 @@
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
- # * pickdepth.c
42
- # * Picking is demonstrated in this program. In
43
- # * rendering mode, three overlapping rectangles are
44
- # * drawn. When the left mouse button is pressed,
45
- # * selection mode is entered with the picking matrix.
46
- # * Rectangles which are drawn under the cursor position
47
- # * are "picked." Pay special attention to the depth
48
- # * value range, which is returned.
49
- # */
50
-
51
- require "gl_prev"
52
- require "glu_prev"
53
- require "glut_prev"
54
-
55
-
56
- def myinit
57
- GL::ClearColor(0.0, 0.0, 0.0, 0.0);
58
- GL::DepthFunc(GL::LESS);
59
- GL::Enable(GL::DEPTH_TEST);
60
- GL::ShadeModel(GL::FLAT);
61
- GL::DepthRange(0.0, 1.0); #/* The default z mapping */
62
- end
63
-
64
- #/* The three rectangles are drawn. In selection mode,
65
- # * each rectangle is given the same name. Note that
66
- # * each rectangle is drawn with a different z value.
67
- # */
68
- def drawRects(mode)
69
- if (mode == GL::SELECT)
70
- GL::LoadName(1);
71
- end
72
- GL::Begin(GL::QUADS);
73
- GL::Color(1.0, 1.0, 0.0);
74
- GL::Vertex(2, 0, 0);
75
- GL::Vertex(2, 6, 0);
76
- GL::Vertex(6, 6, 0);
77
- GL::Vertex(6, 0, 0);
78
- GL::End();
79
- if (mode == GL::SELECT)
80
- GL::LoadName(2);
81
- end
82
- GL::Begin(GL::QUADS);
83
- GL::Color(0.0, 1.0, 1.0);
84
- GL::Vertex(3, 2, -1);
85
- GL::Vertex(3, 8, -1);
86
- GL::Vertex(8, 8, -1);
87
- GL::Vertex(8, 2, -1);
88
- GL::End();
89
- if (mode == GL::SELECT)
90
- GL::LoadName(3);
91
- end
92
- GL::Begin(GL::QUADS);
93
- GL::Color(1.0, 0.0, 1.0);
94
- GL::Vertex(0, 2, -2);
95
- GL::Vertex(0, 7, -2);
96
- GL::Vertex(5, 7, -2);
97
- GL::Vertex(5, 2, -2);
98
- GL::End();
99
- end
100
-
101
- #/* processHits() prints out the contents of the
102
- # * selection array.
103
- # */
104
- def processHits(hits, buffer)
105
- printf("hits = %d\n", hits);
106
- ptr = buffer.unpack("I*")
107
- p = 0
108
- for i in 0...hits #/* for each hit */
109
- names = ptr[p]
110
- printf(" number of names for hit = %d\n", names); p+=1;
111
- printf(" z1 is %g;", ptr[p].to_f/0xffffffff); p+=1;
112
- printf(" z2 is %g\n", ptr[p].to_f/0xffffffff); p+=1;
113
- printf(" the name is ");
114
- for j in 0...names # /* for each name */
115
- printf("%d ", ptr[p]); p+=1
116
- end
117
- printf("\n");
118
- end
119
- end
120
-
121
- #/* pickRects() sets up selection mode, name stack,
122
- # * and projection matrix for picking. Then the objects
123
- # * are drawn.
124
- # */
125
- BUFSIZE=512
126
-
127
- pickRects = proc {|button, state, x, y|
128
-
129
- if (button == GLUT::LEFT_BUTTON && state == GLUT::DOWN)
130
- viewport = GL::GetDoublev(GL::VIEWPORT);
131
-
132
- selectBuf = GL::SelectBuffer(BUFSIZE);
133
- GL::RenderMode(GL::SELECT);
134
-
135
- GL::InitNames();
136
- GL::PushName(~0);
137
-
138
- GL::MatrixMode(GL::PROJECTION);
139
- GL::PushMatrix();
140
- GL::LoadIdentity();
141
- #/* create 5x5 pixel picking region near cursor location */
142
- GLU::PickMatrix( x, viewport[3] - y, 5.0, 5.0, viewport);
143
- GL::Ortho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5);
144
- drawRects(GL::SELECT);
145
- GL::PopMatrix();
146
- GL::Flush();
147
-
148
- hits = GL::RenderMode(GL::RENDER);
149
- processHits(hits, selectBuf);
150
- end
151
- }
152
-
153
- display = proc {
154
- GL::Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
155
- drawRects(GL::RENDER);
156
- GLUT::SwapBuffers();
157
- }
158
-
159
- myReshape = proc {|w, h|
160
- GL::Viewport(0, 0, w, h);
161
- GL::MatrixMode(GL::PROJECTION);
162
- GL::LoadIdentity();
163
- GL::Ortho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5);
164
- GL::MatrixMode(GL::MODELVIEW);
165
- GL::LoadIdentity();
166
- }
167
-
168
- #/* Main Loop
169
- # * Open window with initial window size, title bar,
170
- # * RGBA display mode, depth buffer, and handle input events.
171
- # */
172
- GLUT::InitWindowSize(200, 200);
173
- GLUT::InitDisplayMode(GLUT::DOUBLE | GLUT::RGB | GLUT::DEPTH);
174
- GLUT::Init();
175
- GLUT::CreateWindow();
176
- myinit();
177
- GLUT::MouseFunc(pickRects);
178
- GLUT::ReshapeFunc(myReshape);
179
- GLUT::DisplayFunc(display);
180
- GLUT::MainLoop();