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
data/examples/misc/OGLBench.rb
CHANGED
@@ -14,6 +14,8 @@
|
|
14
14
|
module OGLBench
|
15
15
|
|
16
16
|
require 'opengl'
|
17
|
+
require 'glu'
|
18
|
+
require 'glut'
|
17
19
|
include Gl,Glu,Glut
|
18
20
|
|
19
21
|
require 'getoptlong'
|
@@ -132,39 +134,39 @@ $KNOWN_RES = {
|
|
132
134
|
'whuxga' => [ 7680, 4800, 'Wide Hexadecatuple Ultra XGA' ],
|
133
135
|
}
|
134
136
|
|
135
|
-
def OGLBench.w_h_from_geometry(geom)
|
136
|
-
|
137
|
+
def OGLBench.w_h_from_geometry(geom)
|
138
|
+
geometry = geom.downcase
|
137
139
|
|
138
|
-
|
140
|
+
return $~[1,2] if geometry =~ /^(\d+)x(\d+)$/
|
139
141
|
|
140
142
|
dims = $KNOWN_RES[geometry] || [0, 0]
|
141
|
-
|
143
|
+
dims[0,2]
|
142
144
|
end
|
143
145
|
|
144
|
-
def OGLBench.show_known_geometries
|
145
|
-
|
146
|
+
def OGLBench.show_known_geometries
|
147
|
+
puts "Known geometries:"
|
146
148
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
149
|
+
# convert the hash to array, sort by resolution and iterate
|
150
|
+
$KNOWN_RES.sort {|a,b| a[1][0,2] <=> b[1][0,2] }.each do |row|
|
151
|
+
name, res = row
|
152
|
+
x,y,fullname = res
|
153
|
+
printf "%-10s %4d x %4d %s\n", name, x, y, fullname
|
154
|
+
end
|
153
155
|
end
|
154
156
|
|
155
157
|
def OGLBench.show_usage(conf = $CACHED[:conf])
|
156
|
-
|
158
|
+
usage = conf[:usage]
|
157
159
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
160
|
+
if (not conf[:extra_usage].empty?)
|
161
|
+
conf[:_USAGE_LABEL_GENERAL] = "\nGENERAL OPTIONS:"
|
162
|
+
usage = "#{conf[:usage]}\nOTHER OPTIONS:\n#{conf[:extra_usage]}"
|
163
|
+
else
|
164
|
+
conf[:_USAGE_LABEL_GENERAL] = ''
|
165
|
+
end
|
164
166
|
|
165
|
-
|
167
|
+
usage.gsub!(/\$(\w+)/) do conf[$1.to_sym] end
|
166
168
|
|
167
|
-
|
169
|
+
print usage
|
168
170
|
end
|
169
171
|
|
170
172
|
def OGLBench.show_basic_config(conf,gl_info,version)
|
@@ -181,11 +183,11 @@ CONFIG
|
|
181
183
|
end
|
182
184
|
|
183
185
|
def OGLBench.friendly_booleans(conf)
|
184
|
-
|
186
|
+
booleans = conf[:booleans].update(conf[:extra_booleans])
|
185
187
|
|
186
|
-
|
187
|
-
|
188
|
-
|
188
|
+
booleans.each_pair do |logical,readable|
|
189
|
+
conf[readable] = (conf[logical] ? 'yes' : 'no')
|
190
|
+
end
|
189
191
|
end
|
190
192
|
|
191
193
|
def OGLBench.basic_init(extra_conf = nil,extra_options = nil)
|
@@ -207,131 +209,130 @@ USAGE
|
|
207
209
|
# show_usage(conf)
|
208
210
|
# FIXME: $0 ?
|
209
211
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
212
|
+
conf = {
|
213
|
+
:title => 'Ruby-OpenGL Benchmark',
|
214
|
+
:usage => usage,
|
215
|
+
:extra_usage => '',
|
216
|
+
"0".to_sym => $0,
|
217
|
+
|
218
|
+
:frames => 100,
|
219
|
+
:seconds => 10,
|
220
|
+
:geometry => '300x300',
|
221
|
+
|
222
|
+
:fullscreen => false,
|
223
|
+
:known => false,
|
224
|
+
:help => false,
|
225
|
+
|
226
|
+
:booleans => {
|
227
|
+
:fullscreen => :fs,
|
228
|
+
:known => :show_known,
|
229
|
+
:help => :show_help,
|
230
|
+
},
|
231
|
+
:extra_booleans => {},
|
232
|
+
}
|
233
|
+
|
234
|
+
conf.update(extra_conf) if extra_conf
|
235
|
+
|
236
|
+
opts = GetoptLong.new(
|
237
|
+
[ "--frames", "-f", GetoptLong::REQUIRED_ARGUMENT ],
|
238
|
+
[ "--seconds", "-s", GetoptLong::REQUIRED_ARGUMENT ],
|
239
|
+
[ "--geometry", "-g", GetoptLong::REQUIRED_ARGUMENT ],
|
240
|
+
[ "--fullscreen", "--fs", GetoptLong::NO_ARGUMENT ],
|
241
|
+
[ "--known", "-k","--known-geometries", GetoptLong::NO_ARGUMENT ],
|
242
|
+
[ "--help", "-h", "-?", GetoptLong::NO_ARGUMENT ]
|
243
|
+
)
|
244
|
+
|
245
|
+
opts.each do |opt, arg|
|
246
|
+
name = opt.tr('-','')
|
247
|
+
if arg.empty?
|
248
|
+
conf[name.to_sym] = true
|
249
|
+
else
|
250
|
+
conf[name.to_sym] = arg
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
friendly_booleans(conf)
|
253
255
|
|
254
256
|
|
255
257
|
geometry = conf[:geometry]
|
256
258
|
w,h = w_h_from_geometry(geometry)
|
257
|
-
|
258
|
-
|
259
|
+
conf[:width] = w.to_i
|
260
|
+
conf[:height] = h.to_i
|
259
261
|
|
260
|
-
|
262
|
+
$stdout.sync = true
|
261
263
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
264
|
+
if (conf[:help])
|
265
|
+
show_usage(conf)
|
266
|
+
exit(0)
|
267
|
+
end
|
266
268
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
269
|
+
if (conf[:known])
|
270
|
+
show_known_geometries()
|
271
|
+
exit(0)
|
272
|
+
end
|
271
273
|
|
272
274
|
|
273
|
-
|
274
|
-
|
275
|
+
app = init_opengl(conf)
|
276
|
+
gl_info = get_gl_info(app)
|
275
277
|
|
276
|
-
|
278
|
+
[conf, app, gl_info]
|
277
279
|
end
|
278
280
|
|
279
281
|
|
280
282
|
def OGLBench.init_opengl(conf)
|
281
|
-
|
283
|
+
w,h = conf[:width], conf[:height]
|
282
284
|
|
283
|
-
|
285
|
+
raise "Could not determine sane width and height from '#{conf[:geometry]}'.\n" unless w > 0 && h > 0;
|
284
286
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
287
|
+
glutInit()
|
288
|
+
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH)
|
289
|
+
glutInitWindowSize(w,h)
|
290
|
+
app = glutCreateWindow(conf[:title])
|
291
|
+
glViewport(0, 0, w, h)
|
290
292
|
|
291
|
-
|
292
|
-
|
293
|
+
glMatrixMode(GL_PROJECTION)
|
294
|
+
glLoadIdentity
|
293
295
|
|
294
|
-
|
295
|
-
|
296
|
+
glMatrixMode(GL_MODELVIEW)
|
297
|
+
glLoadIdentity
|
296
298
|
|
297
|
-
|
298
|
-
|
299
|
+
$CACHED[:conf] = conf
|
300
|
+
$CACHED[:app] = app
|
299
301
|
|
300
|
-
|
302
|
+
app
|
301
303
|
end
|
302
304
|
|
303
305
|
def OGLBench.get_gl_info(app = $CACHED[:app])
|
304
|
-
|
306
|
+
gl_info = {}
|
305
307
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
308
|
+
# These values are faked
|
309
|
+
conf = $CACHED[:conf]
|
310
|
+
gl_info[:r] = 8
|
311
|
+
gl_info[:g] = 8
|
312
|
+
gl_info[:b] = 8
|
313
|
+
gl_info[:a] = 0
|
314
|
+
gl_info[:d] = 24
|
313
315
|
|
314
|
-
|
316
|
+
$CACHED[:gl_info] = gl_info
|
315
317
|
|
316
|
-
|
318
|
+
gl_info
|
317
319
|
end
|
318
320
|
|
319
321
|
def OGLBench.fade_to_white(frac)
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
322
|
+
glColor4f(frac, frac, frac, 1)
|
323
|
+
glClearColor(frac, frac, frac, 1)
|
324
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
325
|
+
glFinish
|
324
326
|
end
|
325
327
|
|
326
328
|
def OGLBench.draw_string(font_style,str,x,y)
|
327
329
|
glRasterPos2i(x,y)
|
328
|
-
|
330
|
+
str.each_byte do |char|
|
329
331
|
glutBitmapCharacter(font_style, char)
|
330
|
-
|
332
|
+
end
|
331
333
|
end
|
332
334
|
|
333
335
|
# def init_bitmap_font
|
334
336
|
# def texture_from_texels
|
335
337
|
|
336
338
|
end # end module
|
337
|
-
|
@@ -18,165 +18,167 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require 'opengl'
|
21
|
+
require 'glu'
|
22
|
+
require 'glut'
|
21
23
|
include Gl,Glu,Glut
|
22
24
|
|
23
25
|
# extend Array class with new function
|
24
26
|
class Array
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
def rotate!
|
28
|
+
self << self.shift
|
29
|
+
end
|
28
30
|
end
|
29
31
|
|
30
32
|
class App
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
33
|
+
@@filters = [[GL_NEAREST,"None"],[GL_LINEAR_MIPMAP_NEAREST,"Bilinear"],[GL_LINEAR_MIPMAP_LINEAR,"Trilinear"]]
|
34
|
+
@@anisotropy = [1,2,4,8,16,32]
|
35
|
+
@@color_tint = ["Off","On"]
|
36
|
+
|
37
|
+
def checker_texture(size,divide,color_a,color_b)
|
38
|
+
strip_a = color_a * (size/divide)
|
39
|
+
strip_b = color_b * (size/divide)
|
40
|
+
line_strip_a = (strip_a + strip_b) * (size/2)
|
41
|
+
line_strip_b = (strip_b + strip_a) * (size/2)
|
42
|
+
(line_strip_a + line_strip_b) * (divide/2)
|
43
|
+
end
|
44
|
+
|
45
|
+
def printGlutBitmapFont(string, font, x,y, r,g,b)
|
46
|
+
glDisable(GL_TEXTURE_2D)
|
47
|
+
glColor3f(r, g, b)
|
48
|
+
glRasterPos2i(x, y)
|
49
|
+
string.each_byte do |x|
|
50
|
+
glutBitmapCharacter(font, x)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def ortho(w,h)
|
55
|
+
glMatrixMode(GL_PROJECTION)
|
56
|
+
glLoadIdentity()
|
57
|
+
gluOrtho2D(0,w,0,h)
|
58
|
+
glScalef(1,-1,1)
|
59
|
+
glTranslatef(0,-h,0)
|
60
|
+
|
61
|
+
glMatrixMode(GL_MODELVIEW)
|
62
|
+
glLoadIdentity()
|
63
|
+
end
|
64
|
+
|
65
|
+
def persp(w,h)
|
66
|
+
glMatrixMode(GL_PROJECTION)
|
67
|
+
glLoadIdentity
|
68
|
+
gluPerspective(90,w.to_f/h.to_f,1,100)
|
69
|
+
|
70
|
+
glMatrixMode(GL_MODELVIEW)
|
71
|
+
glLoadIdentity
|
72
|
+
end
|
73
|
+
|
74
|
+
def reshape(w,h)
|
75
|
+
@@w,@@h = w,h
|
76
|
+
glViewport(0, 0, w, h)
|
77
|
+
persp(w,h)
|
78
|
+
end
|
79
|
+
|
80
|
+
def initialize
|
81
|
+
if (not Gl.is_available?("GL_EXT_texture_filter_anisotropic"))
|
82
|
+
puts "This program needs GL_EXT_texture_filter_anisotropic extension"
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
@@w,@@h = glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT)
|
86
|
+
|
87
|
+
@t = glGenTextures(2)
|
88
|
+
|
89
|
+
# default checkerboard texture
|
90
|
+
glBindTexture(GL_TEXTURE_2D,@t[0])
|
91
|
+
data = checker_texture(64,4,[1,1,1],[0,0,0])
|
92
|
+
gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,64,64,GL_RGB,GL_FLOAT,data.pack("f*"))
|
93
|
+
|
94
|
+
# second texture with color tinted mipmaps
|
95
|
+
glBindTexture(GL_TEXTURE_2D,@t[1])
|
96
|
+
data = checker_texture(64,4,[1,1,1],[0,0,0])
|
97
|
+
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,64,64,0,GL_RGB,GL_FLOAT,data.pack("f*"))
|
98
|
+
data = checker_texture(32,4,[1,0,0],[0,0,0])
|
99
|
+
glTexImage2D(GL_TEXTURE_2D,1,GL_RGBA,32,32,0,GL_RGB,GL_FLOAT,data.pack("f*"))
|
100
|
+
data = checker_texture(16,4,[0,1,0],[0,0,0])
|
101
|
+
glTexImage2D(GL_TEXTURE_2D,2,GL_RGBA,16,16,0,GL_RGB,GL_FLOAT,data.pack("f*"))
|
102
|
+
data = checker_texture(8,4,[0,0,1],[0,0,0])
|
103
|
+
glTexImage2D(GL_TEXTURE_2D,3,GL_RGBA,8,8,0,GL_RGB,GL_FLOAT,data.pack("f*"))
|
104
|
+
data = checker_texture(4,4,[1,1,0],[0,0,0])
|
105
|
+
glTexImage2D(GL_TEXTURE_2D,4,GL_RGBA,4,4,0,GL_RGB,GL_FLOAT,data.pack("f*"))
|
106
|
+
data = checker_texture(2,2,[1,0,1],[0,0,0])
|
107
|
+
glTexImage2D(GL_TEXTURE_2D,5,GL_RGBA,2,2,0,GL_RGB,GL_FLOAT,data.pack("f*"))
|
108
|
+
data = [0.5,0.5,0.5] # single pixel texture, just average it
|
109
|
+
glTexImage2D(GL_TEXTURE_2D,6,GL_RGBA,1,1,0,GL_RGB,GL_FLOAT,data.pack("f*"))
|
110
|
+
end
|
111
|
+
|
112
|
+
def display_text
|
113
|
+
ortho(@@w,@@h)
|
114
|
+
printGlutBitmapFont("Texture Filtering ('f'): #{@@filters[0][1]}", GLUT_BITMAP_9_BY_15, 20, 20, 1.0, 1.0, 1.0)
|
115
|
+
printGlutBitmapFont("Anisotropy factor ('a'): #{@@anisotropy[0]}x", GLUT_BITMAP_9_BY_15, 20, 40, 1.0, 1.0, 1.0)
|
116
|
+
printGlutBitmapFont("Colored Mipmaps ('c'): #{@@color_tint[0]}", GLUT_BITMAP_9_BY_15, 20, 60, 1.0, 1.0, 1.0)
|
117
|
+
persp(@@w,@@h)
|
118
|
+
end
|
119
|
+
|
120
|
+
def display_plane()
|
121
|
+
glEnable(GL_TEXTURE_2D)
|
122
|
+
t_repeat = 16
|
123
|
+
# x,y,z,u,v
|
124
|
+
quad = [[-4,-1,1, 0,t_repeat],[4,-1,1, t_repeat,t_repeat],[4,1,-8, t_repeat,0],[-4,1,-8, 0,0]]
|
125
|
+
glBegin(GL_QUADS)
|
126
|
+
quad.each do |v|
|
127
|
+
glTexCoord2f(v[3],v[4])
|
128
|
+
glVertex3f(v[0],v[1],v[2])
|
129
|
+
end
|
130
|
+
glEnd()
|
131
|
+
glDisable(GL_TEXTURE_2D)
|
132
|
+
end
|
133
|
+
|
134
|
+
def display
|
135
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
136
|
+
|
137
|
+
persp(@@w,@@h)
|
138
|
+
|
139
|
+
# move back from scene
|
140
|
+
glTranslatef(0,0,-2)
|
141
|
+
|
142
|
+
# set anisotropy
|
143
|
+
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,@@anisotropy[0])
|
144
|
+
|
145
|
+
# set color tint
|
146
|
+
if (@@color_tint[0] == "On")
|
147
|
+
glBindTexture(GL_TEXTURE_2D,@t[1])
|
148
|
+
else
|
149
|
+
glBindTexture(GL_TEXTURE_2D,@t[0])
|
150
|
+
end
|
151
|
+
|
152
|
+
# set filters
|
153
|
+
f = @@filters[0][0]
|
154
|
+
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,f)
|
155
|
+
|
156
|
+
# draw scene
|
157
|
+
display_plane()
|
158
|
+
display_text()
|
159
|
+
|
160
|
+
sleep(0.001) # microsleep to avoid consuming all CPU time
|
161
|
+
glutSwapBuffers()
|
162
|
+
end
|
163
|
+
|
164
|
+
def idle
|
165
|
+
glutPostRedisplay()
|
166
|
+
end
|
167
|
+
|
168
|
+
def keyboard(key,x,y)
|
169
|
+
case (key)
|
170
|
+
when ?f
|
171
|
+
@@filters.rotate!
|
172
|
+
when ?a
|
173
|
+
max_anisotropy = glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
|
174
|
+
begin @@anisotropy.rotate! end until @@anisotropy[0]<=max_anisotropy
|
175
|
+
when ?c
|
176
|
+
@@color_tint.rotate!
|
177
|
+
when ?\e # Escape
|
178
|
+
exit(0)
|
179
|
+
end
|
180
|
+
glutPostRedisplay()
|
181
|
+
end
|
180
182
|
end
|
181
183
|
|
182
184
|
# main
|