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,41 @@
1
+ //
2
+ // Vertex shader for procedural bricks
3
+ //
4
+ // Authors: Dave Baldwin, Steve Koren, Randi Rost
5
+ // based on a shader by Darwyn Peachey
6
+ //
7
+ // Copyright (c) 2002-2004 3Dlabs Inc. Ltd.
8
+ //
9
+ // See 3Dlabs-License.txt for license information
10
+ //
11
+
12
+ uniform vec3 LightPosition;
13
+
14
+ const float SpecularContribution = 0.3;
15
+ const float DiffuseContribution = 1.0 - SpecularContribution;
16
+
17
+ varying float LightIntensity;
18
+ varying vec2 MCposition;
19
+
20
+ void main(void)
21
+ {
22
+ vec3 ecPosition = vec3 (gl_ModelViewMatrix * gl_Vertex);
23
+ vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
24
+ vec3 lightVec = normalize(LightPosition - ecPosition);
25
+ vec3 reflectVec = reflect(-lightVec, tnorm);
26
+ vec3 viewVec = normalize(-ecPosition);
27
+ float diffuse = max(dot(lightVec, tnorm), 0.0);
28
+ float spec = 0.0;
29
+
30
+ if (diffuse > 0.0)
31
+ {
32
+ spec = max(dot(reflectVec, viewVec), 0.0);
33
+ spec = pow(spec, 16.0);
34
+ }
35
+
36
+ LightIntensity = DiffuseContribution * diffuse +
37
+ SpecularContribution * spec;
38
+
39
+ MCposition = gl_Vertex.xy;
40
+ gl_Position = ftransform();
41
+ }
@@ -0,0 +1,17 @@
1
+ //
2
+ // Fragment shader for rendering a "confetti cannon"
3
+ // via a partcle system
4
+ //
5
+ // Author: Randi Rost
6
+ //
7
+ // Copyright (c) 2003-2004: 3Dlabs, Inc.
8
+ //
9
+ // See 3Dlabs-License.txt for license information
10
+ //
11
+
12
+ varying vec4 Color;
13
+
14
+ void main (void)
15
+ {
16
+ gl_FragColor = Color;
17
+ }
@@ -0,0 +1,406 @@
1
+ #
2
+ # Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions
7
+ # are met:
8
+ #
9
+ # Redistributions of source code must retain the above copyright
10
+ # notice, this list of conditions and the following disclaimer.
11
+ #
12
+ # Redistributions in binary form must reproduce the above
13
+ # copyright notice, this list of conditions and the following
14
+ # disclaimer in the documentation and/or other materials provided
15
+ # with the distribution.
16
+ #
17
+ # Neither the name of 3Dlabs Inc. Ltd. nor the names of its
18
+ # contributors may be used to endorse or promote products derived
19
+ # from this software without specific prior written permission.
20
+ #
21
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
+ # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
+ # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
+ # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
+ # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
+ # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ require 'opengl'
34
+ include Gl,Glu,Glut
35
+
36
+ $particleTime = 0
37
+
38
+ # Movement variables
39
+ $fXDiff = 206
40
+ $fYDiff = 16
41
+ $fZDiff = 10
42
+ $xLastIncr = 0
43
+ $yLastIncr = 0
44
+ $fXInertia = -0.5
45
+ $fYInertia = 0
46
+ $fXInertiaOld
47
+ $fYInertiaOld
48
+ $fScale = 0.25
49
+ $ftime = 0
50
+ $xLast = -1
51
+ $yLast = -1
52
+ $bmModifiers = 0
53
+ $rotate = 1
54
+
55
+ $programObject = 0
56
+ $vertexShaderObject = 0
57
+ $fragmentShaderObject = 0
58
+
59
+ # Rotation defines
60
+ INERTIA_THRESHOLD = 1.0
61
+ INERTIA_FACTOR = 0.5
62
+ SCALE_FACTOR = 0.01
63
+ SCALE_INCREMENT = 0.5
64
+ TIMER_FREQUENCY_MILLIS = 20
65
+
66
+ VELOCITY_ARRAY = 3
67
+ START_TIME_ARRAY = 4
68
+
69
+ $clearColor = [[0,0,0,1], [0.2,0.2,0.3,1], [0.7,0.7,0.7,1]]
70
+
71
+ $arrayWidth = 0, $arrayHeight = 0
72
+ $verts = []
73
+ $colors = []
74
+ $velocities = []
75
+ $startTimes = []
76
+
77
+ def nextClearColor
78
+ glClearColor($clearColor[0][0],
79
+ $clearColor[0][1],
80
+ $clearColor[0][2],
81
+ $clearColor[0][3])
82
+ $clearColor << $clearColor.shift # rotate
83
+ end
84
+
85
+ def getUniLoc(program, name)
86
+ loc = glGetUniformLocation(program, name)
87
+
88
+ if (loc == -1)
89
+ puts "No such uniform named #{name}"
90
+ end
91
+ return loc
92
+ end
93
+
94
+ def updateAnim
95
+ location = getUniLoc($programObject,"Time")
96
+
97
+ $particleTime += 0.002
98
+ if $particleTime > 15.0
99
+ $particleTime = 0.0
100
+ end
101
+
102
+ glUniform1f(location,$particleTime)
103
+ end
104
+
105
+ def drawPoints
106
+ glPointSize(2.0)
107
+ glVertexPointer(3, GL_FLOAT, 0, $verts)
108
+ glColorPointer(3, GL_FLOAT, 0, $colors)
109
+ glVertexAttribPointer(VELOCITY_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, $velocities)
110
+ glVertexAttribPointer(START_TIME_ARRAY, 1, GL_FLOAT, GL_FALSE, 0, $startTimes)
111
+
112
+ glEnableClientState(GL_VERTEX_ARRAY)
113
+ glEnableClientState(GL_COLOR_ARRAY)
114
+ glEnableVertexAttribArray(VELOCITY_ARRAY)
115
+ glEnableVertexAttribArray(START_TIME_ARRAY)
116
+
117
+ glDrawArrays(GL_POINTS, 0, $arrayWidth * $arrayHeight)
118
+
119
+ glDisableClientState(GL_VERTEX_ARRAY)
120
+ glDisableClientState(GL_COLOR_ARRAY)
121
+ glDisableVertexAttribArray(VELOCITY_ARRAY)
122
+ glDisableVertexAttribArray(START_TIME_ARRAY)
123
+ end
124
+
125
+ def createPoints(w,h)
126
+ $verts = []
127
+ $colors = []
128
+ $velocities = []
129
+ $startTimes = []
130
+
131
+ i = 0.5 / w - 0.5
132
+ while (i<0.5)
133
+ j = 0.5 / h - 0.5
134
+ while (j<0.5)
135
+ $verts << i
136
+ $verts << 0.0
137
+ $verts << j
138
+
139
+ $colors << rand() * 0.5 + 0.5
140
+ $colors << rand() * 0.5 + 0.5
141
+ $colors << rand() * 0.5 + 0.5
142
+
143
+ $velocities << rand() + 3.0
144
+ $velocities << rand() * 10.0
145
+ $velocities << rand() + 3.0
146
+
147
+ $startTimes << rand() * 10.0
148
+
149
+ j += 1.0/h
150
+ end
151
+ i += 1.0/w
152
+ end
153
+ # convert from ruby Array to memory representation of float data that
154
+ # will be passed as array pointers to GL
155
+ $verts = $verts.pack("f*")
156
+ $colors = $colors.pack("f*")
157
+ $velocities = $velocities.pack("f*")
158
+ $startTimes = $startTimes.pack("f*")
159
+
160
+ $arrayWidth = w
161
+ $arrayHeight = h
162
+ end
163
+
164
+ play = lambda do
165
+ thisTime = glutGet(GLUT_ELAPSED_TIME)
166
+ updateAnim()
167
+ glutPostRedisplay()
168
+ end
169
+
170
+ display = lambda do
171
+ glLoadIdentity()
172
+ glTranslatef(0.0, 0.0, -5.0)
173
+
174
+ glRotatef($fYDiff, 1,0,0)
175
+ glRotatef($fXDiff, 0,1,0)
176
+ glRotatef($fZDiff, 0,0,1)
177
+
178
+ glScalef($fScale, $fScale, $fScale)
179
+
180
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
181
+
182
+ drawPoints()
183
+
184
+ glFlush()
185
+ glutSwapBuffers()
186
+ end
187
+
188
+ key = lambda do |key,x,y|
189
+ $particleTime = 0
190
+
191
+ case(key)
192
+ when ?b
193
+ nextClearColor()
194
+ when ?q, ?\e # esc
195
+ exit(0)
196
+ when ?\s # space
197
+ $rotate = !$rotate
198
+
199
+ if ($rotate==false)
200
+ $fXInertiaOld = $fXInertia
201
+ $fYInertiaOld = $fYInertia
202
+ else
203
+ $fXInertia = $fXInertiaOld
204
+ $fYInertia = $fYInertiaOld
205
+
206
+ # To prevent confusion, force some rotation
207
+ if ($fXInertia == 0 && $fYInertia == 0)
208
+ $fXInertia = -0.5
209
+ end
210
+ end
211
+ when ?+
212
+ $fScale += SCALE_INCREMENT
213
+ when ?-
214
+ $fScale -= SCALE_INCREMENT
215
+ else
216
+ puts "Keyboard commands:\n"
217
+ puts "b - Toggle among background clear colors"
218
+ puts "q, <esc> - Quit"
219
+ puts "? - Help"
220
+ puts "<home> - reset zoom and rotation"
221
+ puts "<space> or <click> - stop rotation"
222
+ puts "<+>, <-> or <ctrl + drag> - zoom model"
223
+ puts "<arrow keys> or <drag> - rotate model\n"
224
+ end
225
+ end
226
+
227
+ reshape = lambda do |w,h|
228
+ vp = 0.8
229
+ aspect = w/h
230
+
231
+ glViewport(0, 0, w, h)
232
+ glMatrixMode(GL_PROJECTION)
233
+ glLoadIdentity()
234
+
235
+ glFrustum(-vp, vp, -vp / aspect, vp / aspect, 3, 10.0)
236
+
237
+ glMatrixMode(GL_MODELVIEW)
238
+ glLoadIdentity()
239
+ glTranslatef(0.0, 0.0, -5.0)
240
+ end
241
+
242
+ motion = lambda do |x,y|
243
+ if ($xLast != -1 || $yLast != -1)
244
+ $xLastIncr = x - $xLast
245
+ $yLastIncr = y - $yLast
246
+ if ($bmModifiers & GLUT_ACTIVE_CTRL != 0)
247
+ if ($xLast != -1)
248
+ $fZDiff += $xLastIncr
249
+ $fScale += $yLastIncr*SCALE_FACTOR
250
+ end
251
+ else
252
+ if ($xLast != -1)
253
+ $fXDiff += $xLastIncr
254
+ $fYDiff += $yLastIncr
255
+ end
256
+ end
257
+ end
258
+ $xLast = x
259
+ $yLast = y
260
+ end
261
+
262
+ mouse = lambda do |button,state,x,y|
263
+ $bmModifiers = glutGetModifiers()
264
+ if (button == GLUT_LEFT_BUTTON)
265
+ if (state == GLUT_UP)
266
+ $xLast = -1
267
+ $yLast = -1
268
+ if $xLastIncr > INERTIA_THRESHOLD
269
+ $fXInertia = ($xLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
270
+ end
271
+ if -$xLastIncr > INERTIA_THRESHOLD
272
+ $fXInertia = ($xLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
273
+ end
274
+
275
+ if $yLastIncr > INERTIA_THRESHOLD
276
+ $fYInertia = ($yLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
277
+ end
278
+ if -$yLastIncr > INERTIA_THRESHOLD
279
+ $fYInertia = ($yLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
280
+ end
281
+ else
282
+ $fXInertia = 0
283
+ $fYInertia = 0
284
+ end
285
+ $xLastIncr = 0
286
+ $yLastIncr = 0
287
+ end
288
+ end
289
+
290
+ special = lambda do |key,x,y|
291
+ case key
292
+ when GLUT_KEY_HOME:
293
+ $fXDiff = 206
294
+ $fYDiff = 16
295
+ $fZDiff = 10
296
+ $xLastIncr = 0
297
+ $yLastIncr = 0
298
+ $fXInertia = -0.5
299
+ $fYInertia = 0
300
+ $fScale = 0.25
301
+ $particleTime = 0
302
+ when GLUT_KEY_LEFT:
303
+ $fXDiff -= 1
304
+ when GLUT_KEY_RIGHT:
305
+ $fXDiff += 1
306
+ when GLUT_KEY_UP:
307
+ $fYDiff -= 1
308
+ when GLUT_KEY_DOWN:
309
+ $fYDiff += 1
310
+ end
311
+ end
312
+
313
+ timer = lambda do |value|
314
+ $ftime += 0.01
315
+ if $rotate
316
+ $fXDiff += $fXInertia
317
+ $fYDiff += $fYInertia
318
+ end
319
+ glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
320
+ end
321
+
322
+ def installParticleShaders(vs_name,fs_name)
323
+ # Create a vertex shader object and a fragment shader object
324
+ $vertexShaderObject = glCreateShader(GL_VERTEX_SHADER)
325
+ $fragmentShaderObject = glCreateShader(GL_FRAGMENT_SHADER)
326
+
327
+ # Load source code strings into shaders
328
+ glShaderSource($vertexShaderObject, File.read(vs_name))
329
+ glShaderSource($fragmentShaderObject, File.read(fs_name))
330
+
331
+ # Compile the particle vertex shader, and print out
332
+ # the compiler log file.
333
+ glCompileShader($vertexShaderObject)
334
+ vertCompiled = glGetShaderiv($vertexShaderObject, GL_COMPILE_STATUS)
335
+ puts "Shader InfoLog:\n#{glGetShaderInfoLog($vertexShaderObject)}\n"
336
+
337
+ # Compile the particle fragment shader, and print out
338
+ # the compiler log file.
339
+ glCompileShader($fragmentShaderObject)
340
+ fragCompiled = glGetShaderiv($fragmentShaderObject, GL_COMPILE_STATUS)
341
+ puts "Shader InfoLog:\n#{glGetShaderInfoLog($fragmentShaderObject)}\n"
342
+
343
+ return false if (vertCompiled == 0 || fragCompiled == 0)
344
+
345
+ # Create a program object and attach the two compiled shaders
346
+ $programObject = glCreateProgram()
347
+ glAttachShader($programObject, $vertexShaderObject)
348
+ glAttachShader($programObject, $fragmentShaderObject)
349
+
350
+ #Bind generic attribute indices to attribute variable names
351
+ glBindAttribLocation($programObject, VELOCITY_ARRAY, "Velocity")
352
+ glBindAttribLocation($programObject, START_TIME_ARRAY, "StartTime");
353
+
354
+ # Link the program object and print out the info log
355
+ glLinkProgram($programObject)
356
+ linked = glGetProgramiv($programObject, GL_LINK_STATUS)
357
+ puts "Program InfoLog:\n#{glGetProgramInfoLog($programObject)}\n"
358
+
359
+ return false if linked==0
360
+
361
+ # Install program object as part of current state
362
+ glUseProgram($programObject)
363
+
364
+ # Set up initial uniform values
365
+ glUniform4f(getUniLoc($programObject, "Background"), 0.0, 0.0, 0.0, 1.0)
366
+ glUniform1f(getUniLoc($programObject, "Time"), -5.0)
367
+
368
+ return true
369
+ end
370
+
371
+ # Main
372
+ glutInit()
373
+ glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE)
374
+ glutInitWindowSize(500, 500)
375
+ glutInitWindowPosition(100,100)
376
+ window = glutCreateWindow("3Dlabs OpenGL Shading Language Particle System Demo")
377
+
378
+ glutIdleFunc(play)
379
+ glutDisplayFunc(display)
380
+ glutKeyboardFunc(key)
381
+ glutReshapeFunc(reshape)
382
+ glutMotionFunc(motion)
383
+ glutMouseFunc(mouse)
384
+ glutSpecialFunc(special)
385
+ glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
386
+
387
+ # Make sure that OpenGL 2.0 is supported by the driver
388
+ if Gl.is_available?(2.0)==false
389
+ major,minor,*rest = glGetString(GL_VERSION).split(/\.| /)
390
+ puts "GL_VERSION major=#{major} minor=#{minor}"
391
+ puts "Support for OpenGL 2.0 is required for this demo...exiting"
392
+ exit(1)
393
+ end
394
+
395
+ createPoints(100, 100)
396
+
397
+ glDepthFunc(GL_LESS)
398
+ glEnable(GL_DEPTH_TEST)
399
+ nextClearColor()
400
+
401
+ key.call('?', 0, 0)
402
+
403
+ success = installParticleShaders("particle.vert", "particle.frag")
404
+ if (success)
405
+ glutMainLoop()
406
+ end