opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +2 -0
- data/.gitignore +2 -1
- data/.travis.yml +19 -0
- data/History.rdoc +26 -0
- data/Manifest.txt +3 -23
- data/README.rdoc +43 -37
- data/Rakefile +6 -62
- data/examples/NeHe/nehe_lesson02.rb +3 -2
- data/examples/NeHe/nehe_lesson03.rb +3 -2
- data/examples/NeHe/nehe_lesson04.rb +3 -1
- data/examples/NeHe/nehe_lesson05.rb +4 -1
- data/examples/NeHe/nehe_lesson06.rb +9 -6
- data/examples/NeHe/nehe_lesson07.rb +9 -6
- data/examples/NeHe/nehe_lesson08.rb +9 -6
- data/examples/NeHe/nehe_lesson09.rb +10 -6
- data/examples/NeHe/nehe_lesson11.rb +9 -6
- data/examples/NeHe/nehe_lesson12.rb +9 -6
- data/examples/NeHe/nehe_lesson16.rb +50 -47
- data/examples/NeHe/nehe_lesson19.rb +10 -7
- data/examples/NeHe/nehe_lesson36.rb +234 -229
- data/examples/OrangeBook/brick.rb +227 -225
- data/examples/OrangeBook/particle.rb +233 -231
- data/examples/RedBook/aapoly.rb +71 -70
- data/examples/RedBook/aargb.rb +54 -52
- data/examples/RedBook/accanti.rb +96 -94
- data/examples/RedBook/accpersp.rb +106 -104
- data/examples/RedBook/alpha.rb +54 -52
- data/examples/RedBook/alpha3D.rb +90 -88
- data/examples/RedBook/bezcurve.rb +48 -46
- data/examples/RedBook/bezmesh.rb +71 -69
- data/examples/RedBook/checker.rb +57 -55
- data/examples/RedBook/clip.rb +41 -39
- data/examples/RedBook/colormat.rb +72 -70
- data/examples/RedBook/cube.rb +39 -37
- data/examples/RedBook/depthcue.rb +37 -35
- data/examples/RedBook/dof.rb +110 -109
- data/examples/RedBook/double.rb +40 -38
- data/examples/RedBook/drawf.rb +30 -28
- data/examples/RedBook/feedback.rb +79 -77
- data/examples/RedBook/fog.rb +90 -89
- data/examples/RedBook/font.rb +78 -76
- data/examples/RedBook/hello.rb +29 -27
- data/examples/RedBook/image.rb +57 -55
- data/examples/RedBook/jitter.rb +131 -131
- data/examples/RedBook/light.rb +2 -1
- data/examples/RedBook/lines.rb +70 -68
- data/examples/RedBook/list.rb +48 -46
- data/examples/RedBook/material.rb +200 -199
- data/examples/RedBook/mipmap.rb +84 -82
- data/examples/RedBook/model.rb +55 -53
- data/examples/RedBook/movelight.rb +52 -50
- data/examples/RedBook/pickdepth.rb +103 -101
- data/examples/RedBook/planet.rb +46 -44
- data/examples/RedBook/quadric.rb +97 -95
- data/examples/RedBook/robot.rb +55 -53
- data/examples/RedBook/select.rb +118 -116
- data/examples/RedBook/smooth.rb +35 -33
- data/examples/RedBook/stencil.rb +96 -94
- data/examples/RedBook/stroke.rb +75 -73
- data/examples/RedBook/surface.rb +93 -91
- data/examples/RedBook/teaambient.rb +71 -69
- data/examples/RedBook/teapots.rb +105 -103
- data/examples/RedBook/tess.rb +96 -94
- data/examples/RedBook/texbind.rb +79 -77
- data/examples/RedBook/texgen.rb +88 -86
- data/examples/RedBook/texturesurf.rb +57 -55
- data/examples/RedBook/varray.rb +85 -83
- data/examples/RedBook/wrap.rb +76 -74
- data/examples/misc/OGLBench.rb +114 -113
- data/examples/misc/anisotropic.rb +154 -152
- data/examples/misc/fbo_test.rb +37 -36
- data/examples/misc/font-glut.rb +47 -46
- data/examples/misc/glfwtest.rb +16 -16
- data/examples/misc/plane.rb +13 -13
- data/examples/misc/readpixel.rb +66 -65
- data/examples/misc/sdltest.rb +21 -19
- data/examples/misc/trislam.rb +548 -547
- data/ext/opengl/common.h +16 -38
- data/ext/opengl/conv.h +39 -41
- data/ext/opengl/extconf.rb +4 -31
- data/ext/opengl/funcdef.h +126 -124
- data/ext/opengl/gl-1.0-1.1.c +1917 -1917
- data/ext/opengl/gl-1.2.c +4 -667
- data/ext/opengl/gl-1.3.c +9 -9
- data/ext/opengl/gl-1.4.c +8 -8
- data/ext/opengl/gl-1.5.c +1 -1
- data/ext/opengl/gl-2.0.c +392 -388
- data/ext/opengl/gl-3.0.c +493 -0
- data/ext/opengl/gl-enums.c +1523 -5
- data/ext/opengl/gl-enums.h +4679 -122
- data/ext/opengl/gl-error.c +7 -7
- data/ext/opengl/gl-error.h +4 -4
- data/ext/opengl/gl-ext-arb.c +468 -464
- data/ext/opengl/gl-ext-ext.c +18 -18
- data/ext/opengl/gl-ext-nv.c +15 -15
- data/ext/opengl/gl.c +2 -0
- data/ext/opengl/gl_buffer.c +92 -92
- data/ext/opengl/opengl.c +1 -7
- data/lib/opengl.rb +23 -59
- data/lib/opengl/1.9/opengl.so +0 -0
- data/lib/opengl/2.0/opengl.so +0 -0
- data/lib/opengl/2.1/opengl.so +0 -0
- data/lib/opengl/test_case.rb +1 -2
- data/test/dummy.xorg.conf +140 -0
- data/test/test_gl.rb +18 -22
- data/test/test_gl_10_11.rb +220 -220
- data/test/test_gl_12.rb +11 -122
- data/test/test_gl_13.rb +202 -210
- data/test/test_gl_14.rb +16 -19
- data/test/test_gl_15.rb +2 -4
- data/test/test_gl_20.rb +45 -58
- data/test/test_gl_21.rb +46 -163
- data/test/test_gl_ext_arb.rb +54 -72
- data/test/test_gl_ext_ati.rb +0 -2
- data/test/test_gl_ext_ext.rb +66 -66
- data/test/test_gl_ext_gremedy.rb +8 -15
- data/test/test_gl_ext_nv.rb +109 -112
- data/test/test_opengl_buffer.rb +8 -25
- data/utils/README +0 -5
- data/utils/enumgen.rb +72 -76
- data/utils/extlistgen.rb +55 -55
- metadata +90 -67
- metadata.gz.sig +0 -0
- data/Rakefile.cross +0 -107
- data/docs/build_install.txt +0 -119
- data/docs/extensions.txt.in +0 -348
- data/docs/history.txt +0 -66
- data/docs/requirements_and_design.txt +0 -117
- data/docs/roadmap.txt +0 -28
- data/docs/scientific_use.txt +0 -35
- data/docs/supplies/page_template.html +0 -71
- data/docs/thanks.txt +0 -29
- data/docs/tutorial.txt +0 -469
- data/ext/opengl/glu-enums.c +0 -164
- data/ext/opengl/glu-enums.h +0 -463
- data/ext/opengl/glu.c +0 -1534
- data/ext/opengl/glut.c +0 -1145
- data/ext/opengl/glut_callbacks.c +0 -845
- data/lib/glu.rb +0 -1
- data/lib/glut.rb +0 -1
- data/lib/opengl/opengl.so +0 -0
- data/test/test_glu.rb +0 -309
- data/utils/mkdn2html.rb +0 -59
- data/utils/post-mkdn2html.rb +0 -91
- data/website/images/ogl.jpg +0 -0
- data/website/images/tab_bottom.gif +0 -0
- data/website/style.css +0 -198
@@ -31,6 +31,8 @@
|
|
31
31
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
32
|
# POSSIBILITY OF SUCH DAMAGE.
|
33
33
|
require 'opengl'
|
34
|
+
require 'glu'
|
35
|
+
require 'glut'
|
34
36
|
include Gl,Glu,Glut
|
35
37
|
|
36
38
|
$particleTime = 0
|
@@ -63,7 +65,7 @@ SCALE_FACTOR = 0.01
|
|
63
65
|
SCALE_INCREMENT = 0.5
|
64
66
|
TIMER_FREQUENCY_MILLIS = 20
|
65
67
|
|
66
|
-
VELOCITY_ARRAY =
|
68
|
+
VELOCITY_ARRAY = 5
|
67
69
|
START_TIME_ARRAY = 4
|
68
70
|
|
69
71
|
$clearColor = [[0,0,0,1], [0.2,0.2,0.3,1], [0.7,0.7,0.7,1]]
|
@@ -75,158 +77,158 @@ $velocities = []
|
|
75
77
|
$startTimes = []
|
76
78
|
|
77
79
|
def nextClearColor
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
glClearColor($clearColor[0][0],
|
81
|
+
$clearColor[0][1],
|
82
|
+
$clearColor[0][2],
|
83
|
+
$clearColor[0][3])
|
84
|
+
$clearColor << $clearColor.shift # rotate
|
83
85
|
end
|
84
86
|
|
85
87
|
def getUniLoc(program, name)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
loc = glGetUniformLocation(program, name)
|
89
|
+
|
90
|
+
if (loc == -1)
|
91
|
+
puts "No such uniform named #{name}"
|
92
|
+
end
|
93
|
+
return loc
|
92
94
|
end
|
93
95
|
|
94
96
|
def updateAnim
|
95
|
-
|
97
|
+
location = getUniLoc($programObject,"Time")
|
96
98
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
99
|
+
$particleTime += 0.002
|
100
|
+
if $particleTime > 15.0
|
101
|
+
$particleTime = 0.0
|
102
|
+
end
|
101
103
|
|
102
|
-
|
104
|
+
glUniform1f(location,$particleTime)
|
103
105
|
end
|
104
106
|
|
105
107
|
def drawPoints
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
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)
|
123
125
|
end
|
124
126
|
|
125
127
|
def createPoints(w,h)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
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
|
162
164
|
end
|
163
165
|
|
164
166
|
play = lambda do
|
165
|
-
|
166
|
-
|
167
|
-
|
167
|
+
thisTime = glutGet(GLUT_ELAPSED_TIME)
|
168
|
+
updateAnim()
|
169
|
+
glutPostRedisplay()
|
168
170
|
end
|
169
171
|
|
170
172
|
display = lambda do
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
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()
|
186
188
|
end
|
187
189
|
|
188
190
|
key = lambda do |key,x,y|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
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
|
205
207
|
|
206
208
|
# To prevent confusion, force some rotation
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
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
|
225
227
|
end
|
226
228
|
|
227
229
|
reshape = lambda do |w,h|
|
228
230
|
vp = 0.8
|
229
|
-
|
231
|
+
aspect = w/h
|
230
232
|
|
231
233
|
glViewport(0, 0, w, h)
|
232
234
|
glMatrixMode(GL_PROJECTION)
|
@@ -240,132 +242,132 @@ reshape = lambda do |w,h|
|
|
240
242
|
end
|
241
243
|
|
242
244
|
motion = lambda do |x,y|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
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
|
260
262
|
end
|
261
263
|
|
262
264
|
mouse = lambda do |button,state,x,y|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
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
|
288
290
|
end
|
289
291
|
|
290
292
|
special = lambda do |key,x,y|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
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
|
311
313
|
end
|
312
314
|
|
313
315
|
timer = lambda do |value|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
316
|
+
$ftime += 0.01
|
317
|
+
if $rotate
|
318
|
+
$fXDiff += $fXInertia
|
319
|
+
$fYDiff += $fYInertia
|
320
|
+
end
|
321
|
+
glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
|
320
322
|
end
|
321
323
|
|
322
324
|
def installParticleShaders(vs_name,fs_name)
|
323
|
-
|
324
|
-
|
325
|
-
|
325
|
+
# Create a vertex shader object and a fragment shader object
|
326
|
+
$vertexShaderObject = glCreateShader(GL_VERTEX_SHADER)
|
327
|
+
$fragmentShaderObject = glCreateShader(GL_FRAGMENT_SHADER)
|
326
328
|
|
327
|
-
|
328
|
-
|
329
|
-
|
329
|
+
# Load source code strings into shaders
|
330
|
+
glShaderSource($vertexShaderObject, File.read(vs_name))
|
331
|
+
glShaderSource($fragmentShaderObject, File.read(fs_name))
|
330
332
|
|
331
|
-
|
332
|
-
|
333
|
-
|
333
|
+
# Compile the particle vertex shader, and print out
|
334
|
+
# the compiler log file.
|
335
|
+
glCompileShader($vertexShaderObject)
|
334
336
|
vertCompiled = glGetShaderiv($vertexShaderObject, GL_COMPILE_STATUS)
|
335
|
-
|
337
|
+
puts "Shader InfoLog:\n#{glGetShaderInfoLog($vertexShaderObject)}\n"
|
336
338
|
|
337
|
-
|
338
|
-
|
339
|
-
|
339
|
+
# Compile the particle fragment shader, and print out
|
340
|
+
# the compiler log file.
|
341
|
+
glCompileShader($fragmentShaderObject)
|
340
342
|
fragCompiled = glGetShaderiv($fragmentShaderObject, GL_COMPILE_STATUS)
|
341
|
-
|
343
|
+
puts "Shader InfoLog:\n#{glGetShaderInfoLog($fragmentShaderObject)}\n"
|
342
344
|
|
343
|
-
|
345
|
+
return false if (vertCompiled == 0 || fragCompiled == 0)
|
344
346
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
347
|
+
# Create a program object and attach the two compiled shaders
|
348
|
+
$programObject = glCreateProgram()
|
349
|
+
glAttachShader($programObject, $vertexShaderObject)
|
350
|
+
glAttachShader($programObject, $fragmentShaderObject)
|
349
351
|
|
350
|
-
|
351
|
-
|
352
|
-
|
352
|
+
#Bind generic attribute indices to attribute variable names
|
353
|
+
glBindAttribLocation($programObject, VELOCITY_ARRAY, "Velocity")
|
354
|
+
glBindAttribLocation($programObject, START_TIME_ARRAY, "StartTime")
|
353
355
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
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"
|
358
360
|
|
359
|
-
|
361
|
+
return false if linked==0
|
360
362
|
|
361
|
-
|
362
|
-
|
363
|
+
# Install program object as part of current state
|
364
|
+
glUseProgram($programObject)
|
363
365
|
|
364
|
-
|
365
|
-
|
366
|
-
|
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)
|
367
369
|
|
368
|
-
|
370
|
+
return true
|
369
371
|
end
|
370
372
|
|
371
373
|
# Main
|
@@ -374,7 +376,7 @@ glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE)
|
|
374
376
|
glutInitWindowSize(500, 500)
|
375
377
|
glutInitWindowPosition(100,100)
|
376
378
|
window = glutCreateWindow("3Dlabs OpenGL Shading Language Particle System Demo")
|
377
|
-
|
379
|
+
|
378
380
|
glutIdleFunc(play)
|
379
381
|
glutDisplayFunc(display)
|
380
382
|
glutKeyboardFunc(key)
|
@@ -386,10 +388,10 @@ glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
|
|
386
388
|
|
387
389
|
# Make sure that OpenGL 2.0 is supported by the driver
|
388
390
|
if Gl.is_available?(2.0)==false
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
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)
|
393
395
|
end
|
394
396
|
|
395
397
|
createPoints(100, 100)
|
@@ -402,5 +404,5 @@ key.call('?', 0, 0)
|
|
402
404
|
|
403
405
|
success = installParticleShaders("particle.vert", "particle.frag")
|
404
406
|
if (success)
|
405
|
-
|
407
|
+
glutMainLoop()
|
406
408
|
end
|