opengl 0.9.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +3 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +29 -0
  5. data/.gemtest +0 -0
  6. data/.gitignore +6 -0
  7. data/.travis.yml +19 -0
  8. data/History.rdoc +77 -0
  9. data/MIT-LICENSE +18 -0
  10. data/Manifest.txt +138 -0
  11. data/README.rdoc +102 -0
  12. data/Rakefile +60 -0
  13. data/examples/NeHe/NeHe.png +0 -0
  14. data/examples/NeHe/crate.png +0 -0
  15. data/examples/NeHe/glass.png +0 -0
  16. data/examples/NeHe/nehe_lesson02.rb +117 -0
  17. data/examples/NeHe/nehe_lesson03.rb +123 -0
  18. data/examples/NeHe/nehe_lesson04.rb +132 -0
  19. data/examples/NeHe/nehe_lesson05.rb +182 -0
  20. data/examples/NeHe/nehe_lesson06.rb +186 -0
  21. data/examples/NeHe/nehe_lesson07.rb +240 -0
  22. data/examples/NeHe/nehe_lesson08.rb +255 -0
  23. data/examples/NeHe/nehe_lesson09.rb +203 -0
  24. data/examples/NeHe/nehe_lesson11.rb +176 -0
  25. data/examples/NeHe/nehe_lesson12.rb +203 -0
  26. data/examples/NeHe/nehe_lesson16.rb +211 -0
  27. data/examples/NeHe/nehe_lesson19.rb +209 -0
  28. data/examples/NeHe/nehe_lesson36.rb +308 -0
  29. data/examples/NeHe/particle.png +0 -0
  30. data/examples/NeHe/star.png +0 -0
  31. data/examples/NeHe/tim.png +0 -0
  32. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  33. data/examples/OrangeBook/brick.frag +36 -0
  34. data/examples/OrangeBook/brick.rb +378 -0
  35. data/examples/OrangeBook/brick.vert +41 -0
  36. data/examples/OrangeBook/particle.frag +17 -0
  37. data/examples/OrangeBook/particle.rb +408 -0
  38. data/examples/OrangeBook/particle.vert +38 -0
  39. data/examples/README +16 -0
  40. data/examples/RedBook/aapoly.rb +143 -0
  41. data/examples/RedBook/aargb.rb +121 -0
  42. data/examples/RedBook/accanti.rb +164 -0
  43. data/examples/RedBook/accpersp.rb +217 -0
  44. data/examples/RedBook/alpha.rb +125 -0
  45. data/examples/RedBook/alpha3D.rb +160 -0
  46. data/examples/RedBook/bezcurve.rb +107 -0
  47. data/examples/RedBook/bezmesh.rb +139 -0
  48. data/examples/RedBook/checker.rb +126 -0
  49. data/examples/RedBook/clip.rb +97 -0
  50. data/examples/RedBook/colormat.rb +137 -0
  51. data/examples/RedBook/cube.rb +71 -0
  52. data/examples/RedBook/depthcue.rb +101 -0
  53. data/examples/RedBook/dof.rb +206 -0
  54. data/examples/RedBook/double.rb +107 -0
  55. data/examples/RedBook/drawf.rb +93 -0
  56. data/examples/RedBook/feedback.rb +147 -0
  57. data/examples/RedBook/fog.rb +168 -0
  58. data/examples/RedBook/font.rb +153 -0
  59. data/examples/RedBook/hello.rb +81 -0
  60. data/examples/RedBook/image.rb +139 -0
  61. data/examples/RedBook/jitter.rb +207 -0
  62. data/examples/RedBook/light.rb +155 -0
  63. data/examples/RedBook/lines.rb +130 -0
  64. data/examples/RedBook/list.rb +113 -0
  65. data/examples/RedBook/material.rb +276 -0
  66. data/examples/RedBook/mipmap.rb +158 -0
  67. data/examples/RedBook/model.rb +115 -0
  68. data/examples/RedBook/movelight.rb +134 -0
  69. data/examples/RedBook/pickdepth.rb +181 -0
  70. data/examples/RedBook/planet.rb +110 -0
  71. data/examples/RedBook/quadric.rb +160 -0
  72. data/examples/RedBook/robot.rb +117 -0
  73. data/examples/RedBook/select.rb +198 -0
  74. data/examples/RedBook/smooth.rb +97 -0
  75. data/examples/RedBook/stencil.rb +165 -0
  76. data/examples/RedBook/stroke.rb +169 -0
  77. data/examples/RedBook/surface.rb +168 -0
  78. data/examples/RedBook/teaambient.rb +134 -0
  79. data/examples/RedBook/teapots.rb +184 -0
  80. data/examples/RedBook/tess.rb +185 -0
  81. data/examples/RedBook/texbind.rb +149 -0
  82. data/examples/RedBook/texgen.rb +171 -0
  83. data/examples/RedBook/texturesurf.rb +130 -0
  84. data/examples/RedBook/varray.rb +161 -0
  85. data/examples/RedBook/wrap.rb +150 -0
  86. data/examples/misc/OGLBench.rb +338 -0
  87. data/examples/misc/anisotropic.rb +196 -0
  88. data/examples/misc/fbo_test.rb +357 -0
  89. data/examples/misc/font-glut.rb +47 -0
  90. data/examples/misc/glfwtest.rb +30 -0
  91. data/examples/misc/plane.rb +161 -0
  92. data/examples/misc/readpixel.rb +66 -0
  93. data/examples/misc/sdltest.rb +36 -0
  94. data/examples/misc/trislam.rb +829 -0
  95. data/ext/opengl/common.h +428 -0
  96. data/ext/opengl/conv.h +244 -0
  97. data/ext/opengl/extconf.rb +47 -0
  98. data/ext/opengl/funcdef.h +313 -0
  99. data/ext/opengl/gl-1.0-1.1.c +3075 -0
  100. data/ext/opengl/gl-1.2.c +155 -0
  101. data/ext/opengl/gl-1.3.c +443 -0
  102. data/ext/opengl/gl-1.4.c +348 -0
  103. data/ext/opengl/gl-1.5.c +224 -0
  104. data/ext/opengl/gl-2.0.c +667 -0
  105. data/ext/opengl/gl-2.1.c +57 -0
  106. data/ext/opengl/gl-3.0.c +493 -0
  107. data/ext/opengl/gl-enums.c +4873 -0
  108. data/ext/opengl/gl-enums.h +14588 -0
  109. data/ext/opengl/gl-error.c +112 -0
  110. data/ext/opengl/gl-error.h +28 -0
  111. data/ext/opengl/gl-ext-3dfx.c +27 -0
  112. data/ext/opengl/gl-ext-arb.c +875 -0
  113. data/ext/opengl/gl-ext-ati.c +41 -0
  114. data/ext/opengl/gl-ext-ext.c +889 -0
  115. data/ext/opengl/gl-ext-gremedy.c +41 -0
  116. data/ext/opengl/gl-ext-nv.c +680 -0
  117. data/ext/opengl/gl-types.h +67 -0
  118. data/ext/opengl/gl.c +220 -0
  119. data/ext/opengl/gl_buffer.c +177 -0
  120. data/ext/opengl/opengl.c +7 -0
  121. data/lib/gl.rb +1 -0
  122. data/lib/opengl.rb +53 -0
  123. data/lib/opengl/2.0/opengl.so +0 -0
  124. data/lib/opengl/2.1/opengl.so +0 -0
  125. data/lib/opengl/test_case.rb +86 -0
  126. data/test/dummy.xorg.conf +140 -0
  127. data/test/test_gl.rb +38 -0
  128. data/test/test_gl_10_11.rb +1363 -0
  129. data/test/test_gl_12.rb +71 -0
  130. data/test/test_gl_13.rb +221 -0
  131. data/test/test_gl_14.rb +218 -0
  132. data/test/test_gl_15.rb +258 -0
  133. data/test/test_gl_20.rb +417 -0
  134. data/test/test_gl_21.rb +436 -0
  135. data/test/test_gl_ext_arb.rb +508 -0
  136. data/test/test_gl_ext_ati.rb +28 -0
  137. data/test/test_gl_ext_ext.rb +608 -0
  138. data/test/test_gl_ext_gremedy.rb +29 -0
  139. data/test/test_gl_ext_nv.rb +349 -0
  140. data/test/test_opengl_buffer.rb +120 -0
  141. data/utils/README +6 -0
  142. data/utils/enumgen.rb +108 -0
  143. data/utils/extlistgen.rb +90 -0
  144. metadata +319 -0
  145. metadata.gz.sig +1 -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,408 @@
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
+ require 'glu'
35
+ require 'glut'
36
+ include Gl,Glu,Glut
37
+
38
+ $particleTime = 0
39
+
40
+ # Movement variables
41
+ $fXDiff = 206
42
+ $fYDiff = 16
43
+ $fZDiff = 10
44
+ $xLastIncr = 0
45
+ $yLastIncr = 0
46
+ $fXInertia = -0.5
47
+ $fYInertia = 0
48
+ $fXInertiaOld
49
+ $fYInertiaOld
50
+ $fScale = 0.25
51
+ $ftime = 0
52
+ $xLast = -1
53
+ $yLast = -1
54
+ $bmModifiers = 0
55
+ $rotate = 1
56
+
57
+ $programObject = 0
58
+ $vertexShaderObject = 0
59
+ $fragmentShaderObject = 0
60
+
61
+ # Rotation defines
62
+ INERTIA_THRESHOLD = 1.0
63
+ INERTIA_FACTOR = 0.5
64
+ SCALE_FACTOR = 0.01
65
+ SCALE_INCREMENT = 0.5
66
+ TIMER_FREQUENCY_MILLIS = 20
67
+
68
+ VELOCITY_ARRAY = 5
69
+ START_TIME_ARRAY = 4
70
+
71
+ $clearColor = [[0,0,0,1], [0.2,0.2,0.3,1], [0.7,0.7,0.7,1]]
72
+
73
+ $arrayWidth = 0, $arrayHeight = 0
74
+ $verts = []
75
+ $colors = []
76
+ $velocities = []
77
+ $startTimes = []
78
+
79
+ def nextClearColor
80
+ glClearColor($clearColor[0][0],
81
+ $clearColor[0][1],
82
+ $clearColor[0][2],
83
+ $clearColor[0][3])
84
+ $clearColor << $clearColor.shift # rotate
85
+ end
86
+
87
+ def getUniLoc(program, name)
88
+ loc = glGetUniformLocation(program, name)
89
+
90
+ if (loc == -1)
91
+ puts "No such uniform named #{name}"
92
+ end
93
+ return loc
94
+ end
95
+
96
+ def updateAnim
97
+ location = getUniLoc($programObject,"Time")
98
+
99
+ $particleTime += 0.002
100
+ if $particleTime > 15.0
101
+ $particleTime = 0.0
102
+ end
103
+
104
+ glUniform1f(location,$particleTime)
105
+ end
106
+
107
+ def drawPoints
108
+ glPointSize(2.0)
109
+ glVertexPointer(3, GL_FLOAT, 0, $verts)
110
+ glColorPointer(3, GL_FLOAT, 0, $colors)
111
+ glVertexAttribPointer(VELOCITY_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, $velocities)
112
+ glVertexAttribPointer(START_TIME_ARRAY, 1, GL_FLOAT, GL_FALSE, 0, $startTimes)
113
+
114
+ glEnableClientState(GL_VERTEX_ARRAY)
115
+ glEnableClientState(GL_COLOR_ARRAY)
116
+ glEnableVertexAttribArray(VELOCITY_ARRAY)
117
+ glEnableVertexAttribArray(START_TIME_ARRAY)
118
+
119
+ glDrawArrays(GL_POINTS, 0, $arrayWidth * $arrayHeight)
120
+
121
+ glDisableClientState(GL_VERTEX_ARRAY)
122
+ glDisableClientState(GL_COLOR_ARRAY)
123
+ glDisableVertexAttribArray(VELOCITY_ARRAY)
124
+ glDisableVertexAttribArray(START_TIME_ARRAY)
125
+ end
126
+
127
+ def createPoints(w,h)
128
+ $verts = []
129
+ $colors = []
130
+ $velocities = []
131
+ $startTimes = []
132
+
133
+ i = 0.5 / w - 0.5
134
+ while (i<0.5)
135
+ j = 0.5 / h - 0.5
136
+ while (j<0.5)
137
+ $verts << i
138
+ $verts << 0.0
139
+ $verts << j
140
+
141
+ $colors << rand() * 0.5 + 0.5
142
+ $colors << rand() * 0.5 + 0.5
143
+ $colors << rand() * 0.5 + 0.5
144
+
145
+ $velocities << rand() + 3.0
146
+ $velocities << rand() * 10.0
147
+ $velocities << rand() + 3.0
148
+
149
+ $startTimes << rand() * 10.0
150
+
151
+ j += 1.0/h
152
+ end
153
+ i += 1.0/w
154
+ end
155
+ # convert from ruby Array to memory representation of float data that
156
+ # will be passed as array pointers to GL
157
+ $verts = $verts.pack("f*")
158
+ $colors = $colors.pack("f*")
159
+ $velocities = $velocities.pack("f*")
160
+ $startTimes = $startTimes.pack("f*")
161
+
162
+ $arrayWidth = w
163
+ $arrayHeight = h
164
+ end
165
+
166
+ play = lambda do
167
+ thisTime = glutGet(GLUT_ELAPSED_TIME)
168
+ updateAnim()
169
+ glutPostRedisplay()
170
+ end
171
+
172
+ display = lambda do
173
+ glLoadIdentity()
174
+ glTranslatef(0.0, 0.0, -5.0)
175
+
176
+ glRotatef($fYDiff, 1,0,0)
177
+ glRotatef($fXDiff, 0,1,0)
178
+ glRotatef($fZDiff, 0,0,1)
179
+
180
+ glScalef($fScale, $fScale, $fScale)
181
+
182
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
183
+
184
+ drawPoints()
185
+
186
+ glFlush()
187
+ glutSwapBuffers()
188
+ end
189
+
190
+ key = lambda do |key,x,y|
191
+ $particleTime = 0
192
+
193
+ case(key)
194
+ when ?b
195
+ nextClearColor()
196
+ when ?q, ?\e # esc
197
+ exit(0)
198
+ when ?\s # space
199
+ $rotate = !$rotate
200
+
201
+ if ($rotate==false)
202
+ $fXInertiaOld = $fXInertia
203
+ $fYInertiaOld = $fYInertia
204
+ else
205
+ $fXInertia = $fXInertiaOld
206
+ $fYInertia = $fYInertiaOld
207
+
208
+ # To prevent confusion, force some rotation
209
+ if ($fXInertia == 0 && $fYInertia == 0)
210
+ $fXInertia = -0.5
211
+ end
212
+ end
213
+ when ?+
214
+ $fScale += SCALE_INCREMENT
215
+ when ?-
216
+ $fScale -= SCALE_INCREMENT
217
+ else
218
+ puts "Keyboard commands:\n"
219
+ puts "b - Toggle among background clear colors"
220
+ puts "q, <esc> - Quit"
221
+ puts "? - Help"
222
+ puts "<home> - reset zoom and rotation"
223
+ puts "<space> or <click> - stop rotation"
224
+ puts "<+>, <-> or <ctrl + drag> - zoom model"
225
+ puts "<arrow keys> or <drag> - rotate model\n"
226
+ end
227
+ end
228
+
229
+ reshape = lambda do |w,h|
230
+ vp = 0.8
231
+ aspect = w/h
232
+
233
+ glViewport(0, 0, w, h)
234
+ glMatrixMode(GL_PROJECTION)
235
+ glLoadIdentity()
236
+
237
+ glFrustum(-vp, vp, -vp / aspect, vp / aspect, 3, 10.0)
238
+
239
+ glMatrixMode(GL_MODELVIEW)
240
+ glLoadIdentity()
241
+ glTranslatef(0.0, 0.0, -5.0)
242
+ end
243
+
244
+ motion = lambda do |x,y|
245
+ if ($xLast != -1 || $yLast != -1)
246
+ $xLastIncr = x - $xLast
247
+ $yLastIncr = y - $yLast
248
+ if ($bmModifiers & GLUT_ACTIVE_CTRL != 0)
249
+ if ($xLast != -1)
250
+ $fZDiff += $xLastIncr
251
+ $fScale += $yLastIncr*SCALE_FACTOR
252
+ end
253
+ else
254
+ if ($xLast != -1)
255
+ $fXDiff += $xLastIncr
256
+ $fYDiff += $yLastIncr
257
+ end
258
+ end
259
+ end
260
+ $xLast = x
261
+ $yLast = y
262
+ end
263
+
264
+ mouse = lambda do |button,state,x,y|
265
+ $bmModifiers = glutGetModifiers()
266
+ if (button == GLUT_LEFT_BUTTON)
267
+ if (state == GLUT_UP)
268
+ $xLast = -1
269
+ $yLast = -1
270
+ if $xLastIncr > INERTIA_THRESHOLD
271
+ $fXInertia = ($xLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
272
+ end
273
+ if -$xLastIncr > INERTIA_THRESHOLD
274
+ $fXInertia = ($xLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
275
+ end
276
+
277
+ if $yLastIncr > INERTIA_THRESHOLD
278
+ $fYInertia = ($yLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
279
+ end
280
+ if -$yLastIncr > INERTIA_THRESHOLD
281
+ $fYInertia = ($yLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
282
+ end
283
+ else
284
+ $fXInertia = 0
285
+ $fYInertia = 0
286
+ end
287
+ $xLastIncr = 0
288
+ $yLastIncr = 0
289
+ end
290
+ end
291
+
292
+ special = lambda do |key,x,y|
293
+ case key
294
+ when GLUT_KEY_HOME
295
+ $fXDiff = 206
296
+ $fYDiff = 16
297
+ $fZDiff = 10
298
+ $xLastIncr = 0
299
+ $yLastIncr = 0
300
+ $fXInertia = -0.5
301
+ $fYInertia = 0
302
+ $fScale = 0.25
303
+ $particleTime = 0
304
+ when GLUT_KEY_LEFT
305
+ $fXDiff -= 1
306
+ when GLUT_KEY_RIGHT
307
+ $fXDiff += 1
308
+ when GLUT_KEY_UP
309
+ $fYDiff -= 1
310
+ when GLUT_KEY_DOWN
311
+ $fYDiff += 1
312
+ end
313
+ end
314
+
315
+ timer = lambda do |value|
316
+ $ftime += 0.01
317
+ if $rotate
318
+ $fXDiff += $fXInertia
319
+ $fYDiff += $fYInertia
320
+ end
321
+ glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
322
+ end
323
+
324
+ def installParticleShaders(vs_name,fs_name)
325
+ # Create a vertex shader object and a fragment shader object
326
+ $vertexShaderObject = glCreateShader(GL_VERTEX_SHADER)
327
+ $fragmentShaderObject = glCreateShader(GL_FRAGMENT_SHADER)
328
+
329
+ # Load source code strings into shaders
330
+ glShaderSource($vertexShaderObject, File.read(vs_name))
331
+ glShaderSource($fragmentShaderObject, File.read(fs_name))
332
+
333
+ # Compile the particle vertex shader, and print out
334
+ # the compiler log file.
335
+ glCompileShader($vertexShaderObject)
336
+ vertCompiled = glGetShaderiv($vertexShaderObject, GL_COMPILE_STATUS)
337
+ puts "Shader InfoLog:\n#{glGetShaderInfoLog($vertexShaderObject)}\n"
338
+
339
+ # Compile the particle fragment shader, and print out
340
+ # the compiler log file.
341
+ glCompileShader($fragmentShaderObject)
342
+ fragCompiled = glGetShaderiv($fragmentShaderObject, GL_COMPILE_STATUS)
343
+ puts "Shader InfoLog:\n#{glGetShaderInfoLog($fragmentShaderObject)}\n"
344
+
345
+ return false if (vertCompiled == 0 || fragCompiled == 0)
346
+
347
+ # Create a program object and attach the two compiled shaders
348
+ $programObject = glCreateProgram()
349
+ glAttachShader($programObject, $vertexShaderObject)
350
+ glAttachShader($programObject, $fragmentShaderObject)
351
+
352
+ #Bind generic attribute indices to attribute variable names
353
+ glBindAttribLocation($programObject, VELOCITY_ARRAY, "Velocity")
354
+ glBindAttribLocation($programObject, START_TIME_ARRAY, "StartTime")
355
+
356
+ # Link the program object and print out the info log
357
+ glLinkProgram($programObject)
358
+ linked = glGetProgramiv($programObject, GL_LINK_STATUS)
359
+ puts "Program InfoLog:\n#{glGetProgramInfoLog($programObject)}\n"
360
+
361
+ return false if linked==0
362
+
363
+ # Install program object as part of current state
364
+ glUseProgram($programObject)
365
+
366
+ # Set up initial uniform values
367
+ glUniform4f(getUniLoc($programObject, "Background"), 0.0, 0.0, 0.0, 1.0)
368
+ glUniform1f(getUniLoc($programObject, "Time"), -5.0)
369
+
370
+ return true
371
+ end
372
+
373
+ # Main
374
+ glutInit()
375
+ glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE)
376
+ glutInitWindowSize(500, 500)
377
+ glutInitWindowPosition(100,100)
378
+ window = glutCreateWindow("3Dlabs OpenGL Shading Language Particle System Demo")
379
+
380
+ glutIdleFunc(play)
381
+ glutDisplayFunc(display)
382
+ glutKeyboardFunc(key)
383
+ glutReshapeFunc(reshape)
384
+ glutMotionFunc(motion)
385
+ glutMouseFunc(mouse)
386
+ glutSpecialFunc(special)
387
+ glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
388
+
389
+ # Make sure that OpenGL 2.0 is supported by the driver
390
+ if Gl.is_available?(2.0)==false
391
+ major,minor,*rest = glGetString(GL_VERSION).split(/\.| /)
392
+ puts "GL_VERSION major=#{major} minor=#{minor}"
393
+ puts "Support for OpenGL 2.0 is required for this demo...exiting"
394
+ exit(1)
395
+ end
396
+
397
+ createPoints(100, 100)
398
+
399
+ glDepthFunc(GL_LESS)
400
+ glEnable(GL_DEPTH_TEST)
401
+ nextClearColor()
402
+
403
+ key.call('?', 0, 0)
404
+
405
+ success = installParticleShaders("particle.vert", "particle.frag")
406
+ if (success)
407
+ glutMainLoop()
408
+ end