opengl 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +1 -0
- data.tar.gz.sig +0 -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/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 +87 -66
- metadata.gz.sig +2 -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/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
@@ -36,6 +36,8 @@
|
|
36
36
|
# .vert are vertex shaders, and files ending in .frag are fragment shaders.
|
37
37
|
|
38
38
|
require 'opengl'
|
39
|
+
require 'glu'
|
40
|
+
require 'glut'
|
39
41
|
include Gl,Glu,Glut
|
40
42
|
|
41
43
|
$rotl = 1 * Math::PI / 180
|
@@ -68,33 +70,33 @@ $gleModel = [:cube, :teapot,:torus,:sphere]
|
|
68
70
|
$clearColor = [[0,0,0,1], [0.2,0.2,0.3,1], [0.7,0.7,0.7,1]]
|
69
71
|
|
70
72
|
def drawCube
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
73
|
+
size = 1.0
|
74
|
+
scale = 0.2
|
75
|
+
delta = 0.1
|
76
|
+
|
77
|
+
v = [
|
78
|
+
[ size, size, size * scale + delta ],
|
79
|
+
[ size, size, -size * scale + delta ],
|
80
|
+
[ size, -size, -size * scale ],
|
81
|
+
[ size, -size, size * scale ],
|
82
|
+
[-size, size, size * scale + delta ],
|
83
|
+
[-size, size, -size * scale + delta ],
|
84
|
+
[-size, -size, -size * scale ],
|
85
|
+
[-size, -size, size * scale ]
|
86
|
+
]
|
87
|
+
|
88
|
+
cube = [
|
89
|
+
[ [1,0,0], v[3],v[2],v[1],v[0] ], # normal, vertices
|
90
|
+
[ [-1,0,0], v[6],v[7],v[4],v[5] ],
|
91
|
+
[ [0,0,-1], v[2],v[6],v[5],v[1] ],
|
92
|
+
[ [0,0,1], v[7],v[3],v[0],v[4] ],
|
93
|
+
[ [0,1,0], v[4],v[0],v[1],v[5] ],
|
94
|
+
[ [0,-1,0], v[6],v[2],v[3],v[7] ]
|
95
|
+
]
|
96
|
+
|
97
|
+
glBegin(GL_QUADS)
|
98
|
+
cube.each do |side|
|
99
|
+
glNormal3fv(side[0])
|
98
100
|
|
99
101
|
glTexCoord2f(1,1)
|
100
102
|
glVertex3fv(side[1])
|
@@ -104,240 +106,240 @@ def drawCube
|
|
104
106
|
glVertex3fv(side[3])
|
105
107
|
glTexCoord2f(1,0)
|
106
108
|
glVertex3fv(side[4])
|
107
|
-
|
108
|
-
|
109
|
+
end
|
110
|
+
glEnd()
|
109
111
|
end
|
110
112
|
|
111
113
|
def nextClearColor
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
114
|
+
glClearColor($clearColor[0][0],
|
115
|
+
$clearColor[0][1],
|
116
|
+
$clearColor[0][2],
|
117
|
+
$clearColor[0][3])
|
118
|
+
$clearColor << $clearColor.shift # rotate
|
117
119
|
end
|
118
120
|
|
119
121
|
|
120
122
|
play = lambda do
|
121
|
-
|
123
|
+
this_time = glutGet(GLUT_ELAPSED_TIME)
|
122
124
|
|
123
|
-
|
124
|
-
|
125
|
+
$rotl+=(this_time - $last_time) * -0.001
|
126
|
+
$last_time = this_time
|
125
127
|
|
126
|
-
|
128
|
+
glutPostRedisplay()
|
127
129
|
end
|
128
130
|
|
129
131
|
display = lambda do
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
132
|
+
glLoadIdentity()
|
133
|
+
glTranslatef(0.0, 0.0, -5.0)
|
134
|
+
|
135
|
+
glRotatef($fYDiff, 1,0,0)
|
136
|
+
glRotatef($fXDiff, 0,1,0)
|
137
|
+
glRotatef($fZDiff, 0,0,1)
|
138
|
+
|
139
|
+
glScalef($fScale, $fScale, $fScale)
|
140
|
+
|
141
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
142
|
+
|
143
|
+
case $gleModel[0]
|
144
|
+
when :teapot
|
145
|
+
glutSolidTeapot(0.6)
|
146
|
+
when :torus
|
147
|
+
glutSolidTorus(0.2, 0.6, 64, 64)
|
148
|
+
when :sphere
|
149
|
+
glutSolidSphere(0.6, 64, 64)
|
150
|
+
when :cube
|
151
|
+
drawCube()
|
152
|
+
end
|
153
|
+
glFlush()
|
154
|
+
glutSwapBuffers()
|
153
155
|
end
|
154
156
|
|
155
157
|
key = lambda do |key,x,y|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
158
|
+
case(key)
|
159
|
+
when ?b
|
160
|
+
nextClearColor()
|
161
|
+
when ?q, ?\e # esc
|
162
|
+
exit(0)
|
163
|
+
when ?t
|
164
|
+
$gleModel << $gleModel.shift # rotate the array
|
165
|
+
when ?\s # space
|
166
|
+
$rotate = !$rotate
|
167
|
+
|
168
|
+
if ($rotate==false)
|
169
|
+
$fXInertiaOld = $fXInertia
|
170
|
+
$fYInertiaOld = $fYInertia
|
171
|
+
else
|
172
|
+
$fXInertia = $fXInertiaOld
|
173
|
+
$fYInertia = $fYInertiaOld
|
172
174
|
|
173
175
|
# To prevent confusion, force some rotation
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
176
|
+
if ($fXInertia == 0 && $fYInertia == 0)
|
177
|
+
$fXInertia = -0.5
|
178
|
+
end
|
179
|
+
end
|
180
|
+
when ?+
|
181
|
+
$fScale += SCALE_INCREMENT
|
182
|
+
when ?-
|
183
|
+
$fScale -= SCALE_INCREMENT
|
184
|
+
else
|
185
|
+
puts "Keyboard commands:\n"
|
186
|
+
puts "b - Toggle among background clear colors"
|
187
|
+
puts "q, <esc> - Quit"
|
188
|
+
puts "t - Toggle among models to render"
|
189
|
+
puts "? - Help"
|
190
|
+
puts "<home> - reset zoom and rotation"
|
191
|
+
puts "<space> or <click> - stop rotation"
|
192
|
+
puts "<+>, <-> or <ctrl + drag> - zoom model"
|
193
|
+
puts "<arrow keys> or <drag> - rotate model\n"
|
194
|
+
end
|
193
195
|
end
|
194
196
|
|
195
197
|
reshape = lambda do |w,h|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
198
|
+
vp = 0.8
|
199
|
+
aspect = w.to_f/h.to_f
|
200
|
+
|
201
|
+
glViewport(0, 0, w, h)
|
202
|
+
glMatrixMode(GL_PROJECTION)
|
203
|
+
glLoadIdentity()
|
204
|
+
|
205
|
+
glFrustum(-vp, vp, -vp / aspect, vp / aspect, 3, 10)
|
206
|
+
|
207
|
+
glMatrixMode(GL_MODELVIEW)
|
208
|
+
glLoadIdentity()
|
209
|
+
glTranslatef(0.0, 0.0, -5.0)
|
208
210
|
end
|
209
211
|
|
210
212
|
motion = lambda do |x,y|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
213
|
+
if ($xLast != -1 || $yLast != -1)
|
214
|
+
$xLastIncr = x - $xLast
|
215
|
+
$yLastIncr = y - $yLast
|
216
|
+
if ($bmModifiers & GLUT_ACTIVE_CTRL != 0)
|
217
|
+
if ($xLast != -1)
|
218
|
+
$fZDiff += $xLastIncr
|
219
|
+
$fScale += $yLastIncr*SCALE_FACTOR
|
220
|
+
end
|
221
|
+
else
|
222
|
+
if ($xLast != -1)
|
223
|
+
$fXDiff += $xLastIncr
|
224
|
+
$fYDiff += $yLastIncr
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
$xLast = x
|
229
|
+
$yLast = y
|
228
230
|
end
|
229
231
|
|
230
232
|
mouse = lambda do |button,state,x,y|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
233
|
+
$bmModifiers = glutGetModifiers()
|
234
|
+
if (button == GLUT_LEFT_BUTTON)
|
235
|
+
if (state == GLUT_UP)
|
236
|
+
$xLast = -1
|
237
|
+
$yLast = -1
|
238
|
+
if $xLastIncr > INERTIA_THRESHOLD
|
239
|
+
$fXInertia = ($xLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
|
240
|
+
end
|
241
|
+
if -$xLastIncr > INERTIA_THRESHOLD
|
242
|
+
$fXInertia = ($xLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
|
243
|
+
end
|
244
|
+
|
245
|
+
if $yLastIncr > INERTIA_THRESHOLD
|
246
|
+
$fYInertia = ($yLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
|
247
|
+
end
|
248
|
+
if -$yLastIncr > INERTIA_THRESHOLD
|
249
|
+
$fYInertia = ($yLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
|
250
|
+
end
|
251
|
+
else
|
252
|
+
$fXInertia = 0
|
253
|
+
$fYInertia = 0
|
254
|
+
end
|
255
|
+
$xLastIncr = 0
|
256
|
+
$yLastIncr = 0
|
257
|
+
end
|
256
258
|
end
|
257
259
|
|
258
260
|
special = lambda do |key,x,y|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
261
|
+
case key
|
262
|
+
when GLUT_KEY_HOME
|
263
|
+
$fXDiff = 0
|
264
|
+
$fYDiff = 35
|
265
|
+
$fZDiff = 0
|
266
|
+
$xLastIncr = 0
|
267
|
+
$yLastIncr = 0
|
268
|
+
$fXInertia = -0.5
|
269
|
+
$fYInertia = 0
|
270
|
+
$fScale = 1.0
|
271
|
+
when GLUT_KEY_LEFT
|
272
|
+
$fXDiff -= 1
|
273
|
+
when GLUT_KEY_RIGHT
|
274
|
+
$fXDiff += 1
|
275
|
+
when GLUT_KEY_UP
|
276
|
+
$fYDiff -= 1
|
277
|
+
when GLUT_KEY_DOWN
|
278
|
+
$fYDiff += 1
|
279
|
+
end
|
278
280
|
end
|
279
281
|
|
280
282
|
timer = lambda do |value|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
283
|
+
$ftime += 0.01
|
284
|
+
if $rotate
|
285
|
+
$fXDiff += $fXInertia
|
286
|
+
$fYDiff += $fYInertia
|
287
|
+
end
|
288
|
+
glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
|
287
289
|
end
|
288
290
|
|
289
291
|
def getUniLoc(program, name)
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
292
|
+
loc = glGetUniformLocation(program, name)
|
293
|
+
|
294
|
+
if (loc == -1)
|
295
|
+
puts "No such uniform named #{name}"
|
296
|
+
end
|
297
|
+
return loc
|
296
298
|
end
|
297
299
|
|
298
300
|
def installBrickShaders(vs_fname,fs_fname)
|
299
|
-
|
300
|
-
|
301
|
-
|
301
|
+
# Create a vertex shader object and a fragment shader object
|
302
|
+
brickVS = glCreateShader(GL_VERTEX_SHADER)
|
303
|
+
brickFS = glCreateShader(GL_FRAGMENT_SHADER)
|
302
304
|
|
303
|
-
|
304
|
-
|
305
|
-
|
305
|
+
# Load source code strings into shaders
|
306
|
+
glShaderSource(brickVS, File.read(vs_fname))
|
307
|
+
glShaderSource(brickFS, File.read(fs_fname))
|
306
308
|
|
307
|
-
|
308
|
-
|
309
|
-
|
309
|
+
# Compile the brick vertex shader, and print out
|
310
|
+
# the compiler log file.
|
311
|
+
glCompileShader(brickVS)
|
310
312
|
vertCompiled = glGetShaderiv(brickVS, GL_COMPILE_STATUS)
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
313
|
+
puts "Shader InfoLog:\n#{glGetShaderInfoLog(brickVS)}\n"
|
314
|
+
|
315
|
+
# Compile the brick fragment shader, and print out
|
316
|
+
# the compiler log file.
|
317
|
+
glCompileShader(brickFS)
|
316
318
|
fragCompiled = glGetShaderiv(brickFS, GL_COMPILE_STATUS)
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
319
|
+
puts "Shader InfoLog:\n#{glGetShaderInfoLog(brickFS)}\n"
|
320
|
+
|
321
|
+
return false if (vertCompiled == 0 || fragCompiled == 0)
|
322
|
+
# Create a program object and attach the two compiled shaders
|
323
|
+
brickProg = glCreateProgram()
|
324
|
+
glAttachShader(brickProg,brickVS)
|
325
|
+
glAttachShader(brickProg,brickFS)
|
326
|
+
# Link the program object and print out the info log
|
327
|
+
glLinkProgram(brickProg)
|
328
|
+
linked = glGetProgramiv(brickProg,GL_LINK_STATUS)
|
329
|
+
puts "Program InfoLog:\n#{glGetProgramInfoLog(brickProg)}\n"
|
330
|
+
return false if linked==0
|
331
|
+
|
332
|
+
# Install program object as part of current state
|
333
|
+
glUseProgram(brickProg)
|
334
|
+
|
335
|
+
# Set up initial uniform values
|
336
|
+
glUniform3f(getUniLoc(brickProg, "BrickColor"), 1.0, 0.3, 0.2)
|
337
|
+
glUniform3f(getUniLoc(brickProg, "MortarColor"), 0.85, 0.86, 0.84)
|
338
|
+
glUniform2f(getUniLoc(brickProg, "BrickSize"), 0.30, 0.15)
|
339
|
+
glUniform2f(getUniLoc(brickProg, "BrickPct"), 0.90, 0.85)
|
340
|
+
glUniform3f(getUniLoc(brickProg, "LightPosition"), 0.0, 0.0, 4.0)
|
341
|
+
|
342
|
+
return true
|
341
343
|
end
|
342
344
|
|
343
345
|
# Main
|
@@ -356,13 +358,13 @@ glutMotionFunc(motion)
|
|
356
358
|
glutMouseFunc(mouse)
|
357
359
|
glutSpecialFunc(special)
|
358
360
|
glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
|
359
|
-
|
361
|
+
|
360
362
|
# Make sure that OpenGL 2.0 is supported by the driver
|
361
363
|
if Gl.is_available?(2.0)==false
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
364
|
+
major,minor,*rest = glGetString(GL_VERSION).split(/\.| /)
|
365
|
+
puts "GL_VERSION major=#{major} minor=#{minor}"
|
366
|
+
puts "Support for OpenGL 2.0 is required for this demo...exiting"
|
367
|
+
exit(1)
|
366
368
|
end
|
367
369
|
|
368
370
|
glDepthFunc(GL_LESS)
|
@@ -371,6 +373,6 @@ glEnable(GL_DEPTH_TEST)
|
|
371
373
|
nextClearColor()
|
372
374
|
|
373
375
|
key.call('?', 0, 0)
|
374
|
-
|
376
|
+
|
375
377
|
success = installBrickShaders("brick.vert","brick.frag")
|
376
378
|
glutMainLoop() if success == true
|