ruby-opengl 0.50.0 → 0.60.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +15 -11
- data/doc/build_install.txt +10 -6
- data/doc/extensions.txt.in +348 -0
- data/doc/history.txt +4 -0
- data/doc/roadmap.txt +4 -6
- data/doc/scientific_use.txt +7 -0
- data/doc/supplies/page_template.html +2 -1
- data/doc/thanks.txt +5 -0
- data/doc/tutorial.txt +431 -121
- data/examples/NeHe/nehe_lesson02.rb +1 -1
- data/examples/NeHe/nehe_lesson03.rb +1 -1
- data/examples/NeHe/nehe_lesson04.rb +1 -1
- data/examples/NeHe/nehe_lesson05.rb +1 -1
- data/examples/NeHe/nehe_lesson36.rb +1 -1
- data/examples/OrangeBook/brick.rb +3 -15
- data/examples/OrangeBook/particle.rb +2 -20
- data/examples/RedBook/aapoly.rb +1 -1
- data/examples/RedBook/aargb.rb +2 -2
- data/examples/RedBook/accanti.rb +1 -1
- data/examples/RedBook/accpersp.rb +1 -1
- data/examples/RedBook/alpha.rb +2 -2
- data/examples/RedBook/alpha3D.rb +1 -1
- data/examples/RedBook/bezcurve.rb +1 -1
- data/examples/RedBook/bezmesh.rb +1 -1
- data/examples/RedBook/checker.rb +1 -1
- data/examples/RedBook/clip.rb +1 -1
- data/examples/RedBook/colormat.rb +1 -1
- data/examples/RedBook/cube.rb +1 -1
- data/examples/RedBook/depthcue.rb +1 -1
- data/examples/RedBook/dof.rb +1 -1
- data/examples/RedBook/double.rb +1 -1
- data/examples/RedBook/drawf.rb +1 -1
- data/examples/RedBook/feedback.rb +1 -1
- data/examples/RedBook/fog.rb +1 -1
- data/examples/RedBook/font.rb +2 -2
- data/examples/RedBook/hello.rb +1 -1
- data/examples/RedBook/image.rb +4 -4
- data/examples/RedBook/lines.rb +1 -1
- data/examples/RedBook/list.rb +1 -1
- data/examples/RedBook/material.rb +1 -1
- data/examples/RedBook/mipmap.rb +1 -1
- data/examples/RedBook/model.rb +1 -1
- data/examples/RedBook/movelight.rb +1 -1
- data/examples/RedBook/pickdepth.rb +1 -1
- data/examples/RedBook/planet.rb +5 -5
- data/examples/RedBook/quadric.rb +1 -1
- data/examples/RedBook/robot.rb +5 -5
- data/examples/RedBook/select.rb +1 -1
- data/examples/RedBook/smooth.rb +1 -1
- data/examples/RedBook/stencil.rb +1 -1
- data/examples/RedBook/stroke.rb +2 -2
- data/examples/RedBook/surface.rb +1 -1
- data/examples/RedBook/teaambient.rb +1 -1
- data/examples/RedBook/teapots.rb +1 -1
- data/examples/RedBook/tess.rb +1 -1
- data/examples/RedBook/texbind.rb +1 -1
- data/examples/RedBook/texgen.rb +5 -5
- data/examples/RedBook/texturesurf.rb +1 -1
- data/examples/RedBook/varray.rb +1 -1
- data/examples/RedBook/wrap.rb +5 -5
- data/examples/misc/OGLBench.rb +337 -0
- data/examples/misc/anisotropic.rb +1 -1
- data/examples/misc/fbo_test.rb +356 -0
- data/examples/misc/font-glut.rb +1 -1
- data/examples/misc/glfwtest.rb +30 -0
- data/examples/misc/md2model.rb +15 -0
- data/examples/misc/plane.rb +1 -1
- data/examples/misc/readpixel.rb +1 -1
- data/examples/misc/sdltest.rb +34 -0
- data/examples/misc/trislam.rb +828 -0
- data/ext/common/common.h +126 -218
- data/ext/common/conv.h +244 -0
- data/ext/common/funcdef.h +280 -0
- data/ext/common/gl-error.h +23 -0
- data/ext/common/gl-types.h +14 -0
- data/ext/gl/gl-1.0-1.1.c +497 -1255
- data/ext/gl/gl-1.2.c +121 -304
- data/ext/gl/gl-1.3.c +78 -339
- data/ext/gl/gl-1.4.c +102 -164
- data/ext/gl/gl-1.5.c +42 -173
- data/ext/gl/gl-2.0.c +273 -1039
- data/ext/gl/gl-2.1.c +15 -19
- data/ext/gl/gl-enums.c +3 -2
- data/ext/gl/gl-error.c +104 -0
- data/ext/gl/gl-ext-3dfx.c +27 -0
- data/ext/gl/gl-ext-arb.c +812 -12
- data/ext/gl/gl-ext-ati.c +41 -0
- data/ext/gl/gl-ext-ext.c +791 -119
- data/ext/gl/gl-ext-gremedy.c +41 -0
- data/ext/gl/gl-ext-nv.c +679 -0
- data/ext/gl/gl.c +48 -28
- data/ext/gl/mkrf_conf.rb +13 -10
- data/ext/glu/glu-enums.c +3 -2
- data/ext/glu/glu.c +136 -41
- data/ext/glu/mkrf_conf.rb +15 -12
- data/ext/glut/glut.c +37 -80
- data/ext/glut/mkrf_conf.rb +17 -13
- data/lib/opengl.rb +29 -53
- data/test/tc_common.rb +9 -3
- data/test/tc_ext_arb.rb +397 -3
- data/test/tc_ext_ati.rb +33 -0
- data/test/tc_ext_ext.rb +479 -2
- data/test/tc_ext_gremedy.rb +36 -0
- data/test/tc_ext_nv.rb +357 -0
- data/test/tc_func_10_11.rb +93 -67
- data/test/tc_func_12.rb +11 -11
- data/test/tc_func_13.rb +38 -18
- data/test/tc_func_14.rb +2 -2
- data/test/tc_func_15.rb +10 -10
- data/test/tc_func_20.rb +20 -20
- data/test/tc_func_21.rb +53 -22
- data/test/tc_glu.rb +9 -4
- data/test/tc_misc.rb +15 -2
- metadata +22 -8
- data/doc/extensions.txt +0 -361
- data/examples/RedBook/aaindex.rb +0 -97
- data/examples/misc/smooth.rb +0 -42
- data/examples/misc/test.rb +0 -65
data/examples/RedBook/list.rb
CHANGED
data/examples/RedBook/mipmap.rb
CHANGED
data/examples/RedBook/model.rb
CHANGED
data/examples/RedBook/planet.rb
CHANGED
@@ -79,19 +79,19 @@ end
|
|
79
79
|
|
80
80
|
keyboard = Proc.new do |key, x, y|
|
81
81
|
case (key)
|
82
|
-
when
|
82
|
+
when ?d
|
83
83
|
$day = ($day + 10) % 360
|
84
84
|
glutPostRedisplay()
|
85
|
-
when
|
85
|
+
when ?D
|
86
86
|
$day = ($day - 10) % 360
|
87
87
|
glutPostRedisplay()
|
88
|
-
when
|
88
|
+
when ?y
|
89
89
|
$year = ($year + 5) % 360
|
90
90
|
glutPostRedisplay()
|
91
|
-
when
|
91
|
+
when ?Y
|
92
92
|
$year = ($year - 5) % 360
|
93
93
|
glutPostRedisplay()
|
94
|
-
when
|
94
|
+
when ?\e
|
95
95
|
exit(0)
|
96
96
|
end
|
97
97
|
end
|
data/examples/RedBook/quadric.rb
CHANGED
data/examples/RedBook/robot.rb
CHANGED
@@ -86,19 +86,19 @@ end
|
|
86
86
|
|
87
87
|
keyboard = Proc.new do|key, x, y|
|
88
88
|
case (key)
|
89
|
-
when
|
89
|
+
when ?s
|
90
90
|
$shoulder = ($shoulder + 5) % 360
|
91
91
|
glutPostRedisplay()
|
92
|
-
when
|
92
|
+
when ?S
|
93
93
|
$shoulder = ($shoulder - 5) % 360
|
94
94
|
glutPostRedisplay()
|
95
|
-
when
|
95
|
+
when ?e
|
96
96
|
$elbow = ($elbow + 5) % 360
|
97
97
|
glutPostRedisplay()
|
98
|
-
when
|
98
|
+
when ?E
|
99
99
|
$elbow = ($elbow - 5) % 360
|
100
100
|
glutPostRedisplay()
|
101
|
-
when
|
101
|
+
when ?\e
|
102
102
|
exit(0)
|
103
103
|
end
|
104
104
|
end
|
data/examples/RedBook/select.rb
CHANGED
data/examples/RedBook/smooth.rb
CHANGED
data/examples/RedBook/stencil.rb
CHANGED
data/examples/RedBook/stroke.rb
CHANGED
@@ -117,7 +117,7 @@ $test1 = "A SPARE SERAPE APPEARS AS"
|
|
117
117
|
$test2 = "APES PREPARE RARE PEPPERS"
|
118
118
|
|
119
119
|
def printStrokedString(s)
|
120
|
-
glCallLists(
|
120
|
+
glCallLists(GL_BYTE,s)
|
121
121
|
end
|
122
122
|
|
123
123
|
display = Proc.new do
|
@@ -147,7 +147,7 @@ end
|
|
147
147
|
|
148
148
|
keyboard = Proc.new do |key, x, y|
|
149
149
|
case (key)
|
150
|
-
when
|
150
|
+
when ?\e
|
151
151
|
exit(0);
|
152
152
|
end
|
153
153
|
end
|
data/examples/RedBook/surface.rb
CHANGED
data/examples/RedBook/teapots.rb
CHANGED
data/examples/RedBook/tess.rb
CHANGED
data/examples/RedBook/texbind.rb
CHANGED
data/examples/RedBook/texgen.rb
CHANGED
@@ -131,27 +131,27 @@ end
|
|
131
131
|
|
132
132
|
keyboard = Proc.new do |key, x, y|
|
133
133
|
case (key)
|
134
|
-
when
|
134
|
+
when ?e,?E
|
135
135
|
$currentGenMode = GL_EYE_LINEAR
|
136
136
|
$currentPlane = GL_EYE_PLANE
|
137
137
|
glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
|
138
138
|
glTexGen(GL_S, $currentPlane, $currentCoeff)
|
139
139
|
glutPostRedisplay()
|
140
|
-
when
|
140
|
+
when ?o, ?O
|
141
141
|
$currentGenMode = GL_OBJECT_LINEAR
|
142
142
|
$currentPlane = GL_OBJECT_PLANE
|
143
143
|
glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
|
144
144
|
glTexGen(GL_S, $currentPlane, $currentCoeff)
|
145
145
|
glutPostRedisplay()
|
146
|
-
when
|
146
|
+
when ?s,?S
|
147
147
|
$currentCoeff = $slanted
|
148
148
|
glTexGen(GL_S, $currentPlane, $currentCoeff)
|
149
149
|
glutPostRedisplay()
|
150
|
-
when
|
150
|
+
when ?x,?X
|
151
151
|
$currentCoeff = $xequalzero
|
152
152
|
glTexGen(GL_S, $currentPlane, $currentCoeff)
|
153
153
|
glutPostRedisplay()
|
154
|
-
when
|
154
|
+
when ?\e
|
155
155
|
exit(0)
|
156
156
|
end
|
157
157
|
end
|
data/examples/RedBook/varray.rb
CHANGED
data/examples/RedBook/wrap.rb
CHANGED
@@ -119,19 +119,19 @@ end
|
|
119
119
|
|
120
120
|
keyboard = Proc.new do |key, x, y|
|
121
121
|
case (key)
|
122
|
-
when
|
122
|
+
when ?s
|
123
123
|
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
|
124
124
|
glutPostRedisplay()
|
125
|
-
when
|
125
|
+
when ?S
|
126
126
|
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
|
127
127
|
glutPostRedisplay()
|
128
|
-
when
|
128
|
+
when ?t
|
129
129
|
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
|
130
130
|
glutPostRedisplay()
|
131
|
-
when
|
131
|
+
when ?T
|
132
132
|
glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
|
133
133
|
glutPostRedisplay()
|
134
|
-
when
|
134
|
+
when ?\e
|
135
135
|
exit(0)
|
136
136
|
end
|
137
137
|
end
|
@@ -0,0 +1,337 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Purpose: Factor out and clean up common code from OpenGL benchmarks
|
4
|
+
|
5
|
+
# Copyright (c) 2006, Geoff Broadwell; this module is released
|
6
|
+
# as open source and may be distributed and modified under the terms
|
7
|
+
# of either the Artistic License or the GNU General Public License,
|
8
|
+
# in the same manner as Perl itself. These licenses should have been
|
9
|
+
# distributed to you as part of your Perl distribution, and can be
|
10
|
+
# read using `perldoc perlartistic` and `perldoc perlgpl` respectively.
|
11
|
+
|
12
|
+
# Conversion to ruby by Jan Dvorak <jan.dvorak@kraxnet.cz>
|
13
|
+
|
14
|
+
module OGLBench
|
15
|
+
|
16
|
+
require 'opengl'
|
17
|
+
include Gl,Glu,Glut
|
18
|
+
|
19
|
+
require 'getoptlong'
|
20
|
+
|
21
|
+
$VERSION = '0.1.4'
|
22
|
+
|
23
|
+
# Cached config and state, for simpler API
|
24
|
+
$CACHED = {}
|
25
|
+
|
26
|
+
# All resolutions listed in landscape orientation,
|
27
|
+
# even for natively portrait devices such as handhelds.
|
28
|
+
# Also, 'q' is annoyingly used as a prefix to mean both
|
29
|
+
# 'quarter' and 'quad'.
|
30
|
+
$KNOWN_RES = {
|
31
|
+
'qqvga' => [ 160, 120, 'Quarter Quarter VGA' ],
|
32
|
+
'palm' => [ 160, 160, 'Original Palm OS Devices' ],
|
33
|
+
'eigthvga' => [ 240, 160, '1/8 VGA' ],
|
34
|
+
'vcrntsc' => [ 240, 480, 'VCR NTSC' ],
|
35
|
+
'vcrpal' => [ 240, 576, 'VCR PAL' ],
|
36
|
+
'qcif' => [ 176, 144, 'Quarter CIF' ],
|
37
|
+
'gears' => [ 300, 300, 'OpenGL Gears Benchmark' ],
|
38
|
+
'glxgears' => [ 300, 300, 'OpenGL Gears Benchmark' ],
|
39
|
+
'cga' => [ 320, 200, 'IBM PC CGA (Color Graphics Adapter)' ],
|
40
|
+
'atarist16' => [ 320, 200, 'Atari ST 16 Color' ],
|
41
|
+
'qvga' => [ 320, 240, 'Quarter VGA' ],
|
42
|
+
'modex' => [ 320, 240, 'VGA Mode X' ],
|
43
|
+
'pocketpc' => [ 320, 240, 'Common Pocket PCs' ],
|
44
|
+
'clie' => [ 320, 320, 'Sony Clie (Palm OS)' ],
|
45
|
+
'vcdntsc' => [ 352, 240, 'VCD (Video CD) NTSC' ],
|
46
|
+
'vcdpal' => [ 352, 288, 'VCD (Video CD) PAL' ],
|
47
|
+
'cif' => [ 352, 288, 'CIF (Common Image Format)' ],
|
48
|
+
'tweakvga' => [ 360, 480, 'Highest 256-color mode for VGA monitors' ],
|
49
|
+
'svhsntsc' => [ 400, 480, 'S-VHS NTSC' ],
|
50
|
+
'svhspal' => [ 400, 576, 'S-VHS PAL' ],
|
51
|
+
'tungsten' => [ 480, 320, 'Tungsten (Palm OS)' ],
|
52
|
+
'bwmac9' => [ 512, 342, 'Black & White 9" Mac' ],
|
53
|
+
'maclc' => [ 512, 384, 'Mac LC' ],
|
54
|
+
'ldntsc' => [ 560, 480, 'Laserdisc NTSC' ],
|
55
|
+
'ldpal' => [ 560, 576, 'Laserdisc PAL' ],
|
56
|
+
'atarist4' => [ 640, 200, 'Atari ST 4 Color' ],
|
57
|
+
'ega' => [ 640, 350, 'IBM PC-AT EGA (Extended Graphics Adapter)' ],
|
58
|
+
'atarist2' => [ 640, 400, 'Atari ST 2 Color' ],
|
59
|
+
'qcga' => [ 640, 400, 'Quad CGA' ],
|
60
|
+
'vga400' => [ 640, 400, 'VGA 400 Line' ],
|
61
|
+
'pgc' => [ 640, 480, 'Professional Graphics Controller' ],
|
62
|
+
'mcga' => [ 640, 480, 'IBM PS/2 MultiColor Graphics Adapter' ],
|
63
|
+
'vga' => [ 640, 480, 'IBM PS/2 VGA (Video Graphics Array)' ],
|
64
|
+
'edtv1' => [ 640, 480, 'EDTV 1' ],
|
65
|
+
'edtv2' => [ 704, 480, 'EDTV 2' ],
|
66
|
+
'hgc' => [ 720, 348, 'Hercules Graphics Controller' ],
|
67
|
+
'mda' => [ 720, 350, 'IBM PC MDA (Monochrome Display Adapter)' ],
|
68
|
+
'lisa' => [ 720, 360, 'Apple Lisa' ],
|
69
|
+
'dv525' => [ 720, 480, 'Digital Video 525/60 (D-1 NTSC, DVD NTSC)' ],
|
70
|
+
'd1ntsc' => [ 720, 480, 'Digital Video 525/60 (D-1 NTSC, DVD NTSC)' ],
|
71
|
+
'dvdntsc' => [ 720, 480, 'Digital Video 525/60 (D-1 NTSC, DVD NTSC)' ],
|
72
|
+
'sp525' => [ 720, 540, 'Digital Video 525/60 (D-1 NTSC Square Pix)' ],
|
73
|
+
'spd1ntsc' => [ 720, 540, 'Digital Video 525/60 (D-1 NTSC Square Pix)' ],
|
74
|
+
'dv625' => [ 720, 576, 'Digital Video 625/50 (PAL, DVD PAL)' ],
|
75
|
+
'dvpal' => [ 720, 576, 'Digital Video 625/50 (PAL, DVD PAL)' ],
|
76
|
+
'dvdpal' => [ 720, 576, 'Digital Video 625/50 (PAL, DVD PAL)' ],
|
77
|
+
'ns525' => [ 768, 483, 'Non-Standard DV 525/60' ],
|
78
|
+
'sp625' => [ 768, 576, 'Square Pixel DV 625/50' ],
|
79
|
+
'wga' => [ 800, 480, 'Wide VGA' ],
|
80
|
+
'svga' => [ 800, 600, 'Super VGA' ],
|
81
|
+
'edtv3' => [ 852, 480, 'EDTV 3' ],
|
82
|
+
'ws480' => [ 854, 480, 'Wide Screen 480 Line' ],
|
83
|
+
'ns625' => [ 948, 576, 'Non-Standard DV 625/60' ],
|
84
|
+
'aacsict' => [ 960, 540, 'AACS Image Constraint Token, Degraded 1080' ],
|
85
|
+
'ws576' => [ 1024, 576, 'Wide Screen 576 Line' ],
|
86
|
+
'8514' => [ 1024, 768, 'IBM 8514/A' ],
|
87
|
+
'8514a' => [ 1024, 768, 'IBM 8514/A' ],
|
88
|
+
'evga' => [ 1024, 768, 'VESA Extended VGA' ],
|
89
|
+
'xga' => [ 1024, 768, 'IBM XGA (eXtended Graphics Array)' ],
|
90
|
+
'nextcube' => [ 1120, 832, 'NeXT Cube' ],
|
91
|
+
'apple1mp' => [ 1152, 864, 'Apple "1 Megapixel"' ],
|
92
|
+
'xga+' => [ 1152, 864, 'XGA+' ],
|
93
|
+
'olpcmono' => [ 1200, 900, 'One Laptop Per Child Mono Mode (true res)' ],
|
94
|
+
'olpc' => [ 1200, 900, 'One Laptop Per Child Mono Mode (true res)' ],
|
95
|
+
'720i' => [ 1280, 720, 'HDTV 720 Line Interlaced' ],
|
96
|
+
'720p' => [ 1280, 720, 'HDTV 720 Line Progressive' ],
|
97
|
+
'hd720' => [ 1280, 720, 'HDTV 720 Line' ],
|
98
|
+
'xga43' => [ 1280, 960, '4:3 XGA Alternative' ],
|
99
|
+
'xga960' => [ 1280, 960, '4:3 XGA Alternative' ],
|
100
|
+
'sxga' => [ 1280, 1024, 'Super XGA' ],
|
101
|
+
'wxga' => [ 1366, 768, 'Wide XGA' ],
|
102
|
+
'wxga768' => [ 1366, 768, 'Wide XGA' ],
|
103
|
+
'wsxga' => [ 1440, 900, 'Wide Super XGA (Low Variant)' ],
|
104
|
+
'wsxga1' => [ 1440, 900, 'Wide Super XGA (Low Variant)' ],
|
105
|
+
'wxga+' => [ 1440, 900, 'Wide XGA+' ],
|
106
|
+
'sxga+' => [ 1440, 1050, 'Super XGA+' ],
|
107
|
+
'wsxga2' => [ 1600, 1024, 'Wide Super XGA (High Variant)' ],
|
108
|
+
'uxga' => [ 1600, 1200, 'Ultra XGA' ],
|
109
|
+
'wsxga+' => [ 1680, 1050, 'Wide Super XGA+' ],
|
110
|
+
'academy2k' => [ 1828, 1332, 'Digital Film Academy 1.375:1 @ 2K' ],
|
111
|
+
'1080i' => [ 1920, 1080, 'HDTV 1080 Line Interlaced' ],
|
112
|
+
'1080p' => [ 1920, 1080, 'HDTV 1080 Line Progressive' ],
|
113
|
+
'hd1080' => [ 1920, 1080, 'HDTV 1080 Line' ],
|
114
|
+
'wuxga' => [ 1920, 1200, 'Wide Ultra XGA' ],
|
115
|
+
'dc2k1' => [ 1998, 1080, 'Digital Film Digital Cinema 1.85:1 @ 2K ' ],
|
116
|
+
'dc2k2' => [ 2048, 858, 'Digital Film Digital Cinema 2.39:1 @ 2K ' ],
|
117
|
+
'eurohd' => [ 2048, 1152, 'European HDTV' ],
|
118
|
+
'qxga' => [ 2048, 1536, 'Quad XGA' ],
|
119
|
+
'wqxga' => [ 2560, 1600, 'Wide Quad XGA' ],
|
120
|
+
'qsxga' => [ 2560, 2048, 'Quad Super XGA' ],
|
121
|
+
'wqsxga' => [ 3200, 2048, 'Wide Quad Super XGA' ],
|
122
|
+
'quxga' => [ 3200, 2400, 'Quad Ultra XGA' ],
|
123
|
+
'academy4k' => [ 3656, 2664, 'Digital Film Academy 1.375:1 @ 4K' ],
|
124
|
+
'wquxga' => [ 3840, 2400, 'Wide Quad Ultra XGA' ],
|
125
|
+
'dc4k1' => [ 3996, 2160, 'Digital Film Digital Cinema 1.85:1 @ 4K ' ],
|
126
|
+
'dc4k2' => [ 4096, 1714, 'Digital Film Digital Cinema 2.39:1 @ 4K ' ],
|
127
|
+
'hxga' => [ 4096, 3072, 'Hexadecatuple XGA' ],
|
128
|
+
'whxga' => [ 5120, 3200, 'Wide Hexadecatuple XGA' ],
|
129
|
+
'hsxga' => [ 5120, 4096, 'Hexadecatuple Super XGA' ],
|
130
|
+
'whsxga' => [ 6400, 4096, 'Wide Hexadecatuple Super XGA' ],
|
131
|
+
'huxga' => [ 6400, 4800, 'Hexadecatuple Ultra XGA' ],
|
132
|
+
'whuxga' => [ 7680, 4800, 'Wide Hexadecatuple Ultra XGA' ],
|
133
|
+
}
|
134
|
+
|
135
|
+
def OGLBench.w_h_from_geometry(geom)
|
136
|
+
geometry = geom.downcase
|
137
|
+
|
138
|
+
return $~[1,2] if geometry =~ /^(\d+)x(\d+)$/
|
139
|
+
|
140
|
+
dims = $KNOWN_RES[geometry] || [0, 0]
|
141
|
+
dims[0,2]
|
142
|
+
end
|
143
|
+
|
144
|
+
def OGLBench.show_known_geometries
|
145
|
+
puts "Known geometries:"
|
146
|
+
|
147
|
+
# convert the hash to array, sort by resolution and iterate
|
148
|
+
$KNOWN_RES.sort {|a,b| a[1][0,2] <=> b[1][0,2] }.each do |row|
|
149
|
+
name, res = row
|
150
|
+
x,y,fullname = res
|
151
|
+
printf "%-10s %4d x %4d %s\n", name, x, y, fullname
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def OGLBench.show_usage(conf = $CACHED[:conf])
|
156
|
+
usage = conf[:usage]
|
157
|
+
|
158
|
+
if (not conf[:extra_usage].empty?)
|
159
|
+
conf[:_USAGE_LABEL_GENERAL] = "\nGENERAL OPTIONS:"
|
160
|
+
usage = "#{conf[:usage]}\nOTHER OPTIONS:\n#{conf[:extra_usage]}"
|
161
|
+
else
|
162
|
+
conf[:_USAGE_LABEL_GENERAL] = ''
|
163
|
+
end
|
164
|
+
|
165
|
+
usage.gsub!(/\$(\w+)/) do conf[$1.to_sym] end
|
166
|
+
|
167
|
+
print usage
|
168
|
+
end
|
169
|
+
|
170
|
+
def OGLBench.show_basic_config(conf,gl_info,version)
|
171
|
+
print <<CONFIG
|
172
|
+
#{conf[:title]}, version #{version}, with Ruby #{RUBY_VERSION}
|
173
|
+
|
174
|
+
window size: #{conf[:width]} x #{conf[:height]}
|
175
|
+
full screen: #{conf[:fs]}
|
176
|
+
rgba bits: #{gl_info[:r]} #{gl_info[:g]} #{gl_info[:b]} #{gl_info[:a]}
|
177
|
+
depth bits: #{gl_info[:d]}
|
178
|
+
min frames/test: #{conf[:frames]}
|
179
|
+
min seconds/test: #{conf[:seconds]}
|
180
|
+
CONFIG
|
181
|
+
end
|
182
|
+
|
183
|
+
def OGLBench.friendly_booleans(conf)
|
184
|
+
booleans = conf[:booleans].update(conf[:extra_booleans])
|
185
|
+
|
186
|
+
booleans.each_pair do |logical,readable|
|
187
|
+
conf[readable] = (conf[logical] ? 'yes' : 'no')
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def OGLBench.basic_init(extra_conf = nil,extra_options = nil)
|
192
|
+
usage = <<'USAGE';
|
193
|
+
$title
|
194
|
+
|
195
|
+
usage: $0 [options...]
|
196
|
+
$_USAGE_LABEL_GENERAL
|
197
|
+
-f |--frames=[NNN] Set minimum frame count [$frames]
|
198
|
+
-s |--seconds=[NNN] Set minimum time [$seconds seconds]
|
199
|
+
--fs|--fullscreen Try to use full screen [$fs]
|
200
|
+
-g |--geometry=[WWW]x[HHH] Set viewport size [$width x $height]
|
201
|
+
-g |--geometry=<name> Set viewport size via well-known name
|
202
|
+
-k |--known-geometries Show list of known geometry names
|
203
|
+
-h |-?|--help Show this help message
|
204
|
+
USAGE
|
205
|
+
|
206
|
+
# conf = {:usage => usage, :frames => "150"}
|
207
|
+
# show_usage(conf)
|
208
|
+
# FIXME: $0 ?
|
209
|
+
|
210
|
+
conf = {
|
211
|
+
:title => 'Ruby-OpenGL Benchmark',
|
212
|
+
:usage => usage,
|
213
|
+
:extra_usage => '',
|
214
|
+
"0".to_sym => $0,
|
215
|
+
|
216
|
+
:frames => 100,
|
217
|
+
:seconds => 10,
|
218
|
+
:geometry => '300x300',
|
219
|
+
|
220
|
+
:fullscreen => false,
|
221
|
+
:known => false,
|
222
|
+
:help => false,
|
223
|
+
|
224
|
+
:booleans => {
|
225
|
+
:fullscreen => :fs,
|
226
|
+
:known => :show_known,
|
227
|
+
:help => :show_help,
|
228
|
+
},
|
229
|
+
:extra_booleans => {},
|
230
|
+
}
|
231
|
+
|
232
|
+
conf.update(extra_conf) if extra_conf
|
233
|
+
|
234
|
+
opts = GetoptLong.new(
|
235
|
+
[ "--frames", "-f", GetoptLong::REQUIRED_ARGUMENT ],
|
236
|
+
[ "--seconds", "-s", GetoptLong::REQUIRED_ARGUMENT ],
|
237
|
+
[ "--geometry", "-g", GetoptLong::REQUIRED_ARGUMENT ],
|
238
|
+
[ "--fullscreen", "--fs", GetoptLong::NO_ARGUMENT ],
|
239
|
+
[ "--known", "-k","--known-geometries", GetoptLong::NO_ARGUMENT ],
|
240
|
+
[ "--help", "-h", "-?", GetoptLong::NO_ARGUMENT ]
|
241
|
+
)
|
242
|
+
|
243
|
+
opts.each do |opt, arg|
|
244
|
+
name = opt.tr('-','')
|
245
|
+
if arg.empty?
|
246
|
+
conf[name.to_sym] = true
|
247
|
+
else
|
248
|
+
conf[name.to_sym] = arg
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
friendly_booleans(conf)
|
253
|
+
|
254
|
+
|
255
|
+
geometry = conf[:geometry]
|
256
|
+
w,h = w_h_from_geometry(geometry)
|
257
|
+
conf[:width] = w.to_i
|
258
|
+
conf[:height] = h.to_i
|
259
|
+
|
260
|
+
$stdout.sync = true
|
261
|
+
|
262
|
+
if (conf[:help])
|
263
|
+
show_usage(conf)
|
264
|
+
exit(0)
|
265
|
+
end
|
266
|
+
|
267
|
+
if (conf[:known])
|
268
|
+
show_known_geometries()
|
269
|
+
exit(0)
|
270
|
+
end
|
271
|
+
|
272
|
+
|
273
|
+
app = init_opengl(conf)
|
274
|
+
gl_info = get_gl_info(app)
|
275
|
+
|
276
|
+
[conf, app, gl_info]
|
277
|
+
end
|
278
|
+
|
279
|
+
|
280
|
+
def OGLBench.init_opengl(conf)
|
281
|
+
w,h = conf[:width], conf[:height]
|
282
|
+
|
283
|
+
raise "Could not determine sane width and height from '#{conf[:geometry]}'.\n" unless w > 0 && h > 0;
|
284
|
+
|
285
|
+
glutInit()
|
286
|
+
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH)
|
287
|
+
glutInitWindowSize(w,h)
|
288
|
+
app = glutCreateWindow(conf[:title])
|
289
|
+
glViewport(0, 0, w, h)
|
290
|
+
|
291
|
+
glMatrixMode(GL_PROJECTION)
|
292
|
+
glLoadIdentity
|
293
|
+
|
294
|
+
glMatrixMode(GL_MODELVIEW)
|
295
|
+
glLoadIdentity
|
296
|
+
|
297
|
+
$CACHED[:conf] = conf
|
298
|
+
$CACHED[:app] = app
|
299
|
+
|
300
|
+
app
|
301
|
+
end
|
302
|
+
|
303
|
+
def OGLBench.get_gl_info(app = $CACHED[:app])
|
304
|
+
gl_info = {}
|
305
|
+
|
306
|
+
# These values are faked
|
307
|
+
conf = $CACHED[:conf]
|
308
|
+
gl_info[:r] = 8
|
309
|
+
gl_info[:g] = 8
|
310
|
+
gl_info[:b] = 8
|
311
|
+
gl_info[:a] = 0
|
312
|
+
gl_info[:d] = 24
|
313
|
+
|
314
|
+
$CACHED[:gl_info] = gl_info
|
315
|
+
|
316
|
+
gl_info
|
317
|
+
end
|
318
|
+
|
319
|
+
def OGLBench.fade_to_white(frac)
|
320
|
+
glColor4f(frac, frac, frac, 1)
|
321
|
+
glClearColor(frac, frac, frac, 1)
|
322
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
323
|
+
glFinish
|
324
|
+
end
|
325
|
+
|
326
|
+
def OGLBench.draw_string(font_style,str,x,y)
|
327
|
+
glRasterPos2i(x,y)
|
328
|
+
str.each_byte do |char|
|
329
|
+
glutBitmapCharacter(font_style, char)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
# def init_bitmap_font
|
334
|
+
# def texture_from_texels
|
335
|
+
|
336
|
+
end # end module
|
337
|
+
|