opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32
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 +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/sdltest.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'opengl'
|
2
|
+
require 'glu'
|
3
|
+
require 'glut'
|
2
4
|
require 'sdl'
|
3
5
|
|
4
6
|
#init
|
@@ -8,27 +10,27 @@ SDL.setVideoMode(512,512,32,SDL::OPENGL)
|
|
8
10
|
|
9
11
|
# main loop
|
10
12
|
while true
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
while event = SDL::Event2.poll
|
14
|
+
case event
|
15
|
+
when SDL::Event2::KeyDown, SDL::Event2::Quit
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
end
|
17
19
|
|
18
|
-
|
20
|
+
Gl.glClear( Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT )
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
Gl.glBegin( Gl::GL_POLYGON )
|
23
|
+
Gl.glColor3f( 1.0, 0.0, 0.0 )
|
24
|
+
Gl.glVertex2f( -0.5, -0.5 )
|
25
|
+
Gl.glColor3f( 0.0, 1.0, 0.0 )
|
26
|
+
Gl.glVertex2f( -0.5, 0.5 )
|
27
|
+
Gl.glColor3f( 0.0, 0.0, 1.0 )
|
28
|
+
Gl.glVertex2f( 0.5, 0.5 )
|
29
|
+
Gl.glColor3f( 1.0, 0.0, 1.0 )
|
30
|
+
Gl.glVertex2f( 0.5, -0.5 )
|
31
|
+
Gl.glEnd
|
30
32
|
|
31
|
-
|
33
|
+
SDL.GLSwapBuffers()
|
32
34
|
|
33
|
-
|
35
|
+
sleep 0.01 # to avoid consuming all CPU power
|
34
36
|
end
|
data/examples/misc/trislam.rb
CHANGED
@@ -13,11 +13,13 @@
|
|
13
13
|
# Conversion to ruby by Jan Dvorak <jan.dvorak@kraxnet.cz>
|
14
14
|
|
15
15
|
require 'opengl'
|
16
|
+
require 'glu'
|
17
|
+
require 'glut'
|
16
18
|
include Gl,Glu,Glut
|
17
19
|
|
18
20
|
require 'mathn'
|
19
21
|
|
20
|
-
|
22
|
+
require_relative 'OGLBench'
|
21
23
|
|
22
24
|
VER = '0.1.24-ruby-p1'
|
23
25
|
|
@@ -65,75 +67,75 @@ $stats_fixed = []
|
|
65
67
|
### CODE
|
66
68
|
|
67
69
|
def main
|
68
|
-
|
69
|
-
|
70
|
+
init()
|
71
|
+
print "Benchmarks:"
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
glutDisplayFunc(method(:cbDraw).to_proc)
|
74
|
+
glutIdleFunc(method(:cbDraw).to_proc)
|
75
|
+
glutKeyboardFunc(method(:cbKeyPressed).to_proc)
|
76
|
+
glutMainLoop()
|
75
77
|
end
|
76
78
|
|
77
79
|
def init
|
78
|
-
|
80
|
+
$stdout.sync = true
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
$combos = recurse_combos($max_powers)
|
83
|
+
$combos.sort!
|
84
|
+
$slow = $combos.select { |a| a <= $max_count_slow }
|
85
|
+
$fast = $combos.select { |a| a > $max_count_slow &&
|
86
|
+
a <= $max_count_slow }
|
85
87
|
|
86
|
-
|
87
|
-
|
88
|
+
# Choose drawing area size to match counts
|
89
|
+
$h = $w = $combos.last
|
88
90
|
|
89
91
|
default_conf = {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
:title => 'Triangle Slammer OpenGL Benchmark',
|
93
|
+
:geometry => "#{$w}x#{$h}",
|
94
|
+
:frames => 10,
|
95
|
+
:seconds => 1,
|
96
|
+
}
|
95
97
|
$conf, $app, $gl_info = OGLBench.basic_init(default_conf)
|
96
98
|
|
97
99
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
# Let user know what's going on
|
102
|
-
show_user_message()
|
100
|
+
# Reduce indirections in inner loops
|
101
|
+
$MIN_FRAMES, $MIN_SECONDS = $conf[:frames], $conf[:seconds]
|
103
102
|
|
104
|
-
|
105
|
-
|
106
|
-
glOrtho(0, $w, 0, $h, -1, 1)
|
107
|
-
glMatrixMode(GL_MODELVIEW)
|
103
|
+
# Let user know what's going on
|
104
|
+
show_user_message()
|
108
105
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
106
|
+
# Change projection to integer-pixel ortho
|
107
|
+
glMatrixMode(GL_PROJECTION)
|
108
|
+
glOrtho(0, $w, 0, $h, -1, 1)
|
109
|
+
glMatrixMode(GL_MODELVIEW)
|
110
|
+
|
111
|
+
# Make sure GL state is consistent for VA and DL creation
|
112
|
+
start_frame()
|
113
|
+
|
114
|
+
# Create vertex arrays and display lists outside timing loop
|
115
|
+
init_vertex_arrays()
|
116
|
+
init_display_lists()
|
117
|
+
|
118
|
+
# Clean up GL state
|
119
|
+
end_frame()
|
118
120
|
end
|
119
121
|
|
120
122
|
def recurse_combos(powers)
|
121
|
-
|
123
|
+
base, max_power, *rest = powers
|
122
124
|
|
123
|
-
|
125
|
+
return [1] if powers.size<1
|
124
126
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
127
|
+
combos = []
|
128
|
+
(0..max_power).each do |power|
|
129
|
+
multiplier = base ** power
|
130
|
+
recurse_combos(rest).each do |item|
|
131
|
+
combos << (item*multiplier)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
combos
|
133
135
|
end
|
134
136
|
|
135
137
|
def show_user_message
|
136
|
-
|
138
|
+
print <<"EOM";
|
137
139
|
TRISLAM benchmarks several methods of pushing OpenGL primitives,
|
138
140
|
testing each method with various primitive counts and sizes.
|
139
141
|
During the benchmark, the test window will start out black, slowly
|
@@ -144,320 +146,320 @@ The configuration for this series of tests will be as follows:
|
|
144
146
|
|
145
147
|
EOM
|
146
148
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
149
|
+
OGLBench.show_basic_config($conf, $gl_info, VER)
|
150
|
+
|
151
|
+
puts "standard runs: #{$slow.join(' ')}"
|
152
|
+
puts "extra fast runs: #{$fast.join(' ')}"
|
153
|
+
puts '-' * 79
|
152
154
|
end
|
153
155
|
|
154
156
|
|
155
157
|
def init_vertex_arrays
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
158
|
+
print "Init vertex arrays:"
|
159
|
+
|
160
|
+
$va_types.keys.sort.each do |type|
|
161
|
+
print " #{type}"
|
162
|
+
($slow + $fast).each do |count|
|
163
|
+
data = $va_types[type].call(count, $w / count.to_f)
|
164
|
+
va = data.pack("f*")
|
165
|
+
$vas["#{type}_#{count}"] = va
|
166
|
+
end
|
167
|
+
end
|
166
168
|
|
167
|
-
|
169
|
+
print ".\n";
|
168
170
|
end
|
169
171
|
|
170
172
|
def init_display_lists
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
173
|
+
print "Init display lists:"
|
174
|
+
|
175
|
+
num_lists = $dl_types.size * ($slow + $fast).size
|
176
|
+
current = glGenLists(num_lists)
|
177
|
+
|
178
|
+
$dl_types.keys.sort.each do |type|
|
179
|
+
print " #{type}"
|
180
|
+
($slow + $fast).each do |count|
|
181
|
+
$dls["#{type}_#{count}"] = current
|
182
|
+
glNewList(current, GL_COMPILE)
|
183
|
+
$dl_types[type].call(count, $w / count.to_f)
|
184
|
+
glEndList()
|
185
|
+
current += 1
|
186
|
+
end
|
187
|
+
end
|
188
|
+
puts "."
|
187
189
|
end
|
188
190
|
|
189
191
|
def benchmark
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
192
|
+
if ($test >= $tests.size)
|
193
|
+
print ".\n" if (!$done)
|
194
|
+
$done = true
|
195
|
+
return
|
196
|
+
end
|
197
|
+
name,draw,stats,class_ = $tests[$test]
|
198
|
+
|
199
|
+
counts = class_ == 'single' ? [1] : (class_ == 'slow' ? $slow : $slow + $fast)
|
200
|
+
|
201
|
+
if ($run == 0)
|
202
|
+
print " #{name}";
|
203
|
+
|
204
|
+
# After printing current test name, busy wait for a second
|
205
|
+
# so that the terminal can catch up and not do work while
|
206
|
+
# the GL timing is in progress
|
207
|
+
a = Time.now
|
208
|
+
while 1 > (Time.now - a) do end
|
209
|
+
end
|
210
|
+
|
211
|
+
count = counts[$run]
|
210
212
|
size = $w / count
|
211
213
|
|
212
|
-
|
214
|
+
OGLBench.fade_to_white(($test + ($run.to_f / counts.size)) / $tests.size)
|
213
215
|
|
214
|
-
|
216
|
+
run_done = 0
|
215
217
|
frames = 0
|
216
218
|
start = Time.now
|
217
219
|
|
218
220
|
while (run_done==0)
|
219
|
-
|
221
|
+
start_frame()
|
220
222
|
draw.call(count, size.to_f)
|
221
223
|
end_frame()
|
222
|
-
|
224
|
+
|
223
225
|
frames += 1
|
224
226
|
run_done = 1 if ($MIN_FRAMES <= frames &&
|
225
227
|
$MIN_SECONDS <= Time.now - start)
|
226
|
-
|
227
|
-
|
228
|
+
end
|
229
|
+
glFinish()
|
228
230
|
end_ = Time.now
|
229
231
|
time = end_ - start
|
230
|
-
|
231
|
-
$stats << [name,count,time,frames] + stats.call(count,size.to_f)
|
232
232
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
233
|
+
$stats << [name,count,time,frames] + stats.call(count,size.to_f)
|
234
|
+
|
235
|
+
$run += 1
|
236
|
+
if ($run >= counts.size)
|
237
|
+
$test += 1
|
238
|
+
$run = 0
|
239
|
+
end
|
238
240
|
end
|
239
241
|
|
240
242
|
def cleanup
|
241
|
-
|
242
|
-
|
243
|
-
|
243
|
+
fixup_stats()
|
244
|
+
show_stats()
|
245
|
+
draw_stats()
|
244
246
|
end
|
245
247
|
|
246
248
|
def start_frame
|
247
|
-
|
248
|
-
|
249
|
+
glClear(GL_COLOR_BUFFER_BIT |
|
250
|
+
GL_DEPTH_BUFFER_BIT)
|
249
251
|
end
|
250
252
|
|
251
253
|
def end_frame
|
252
|
-
|
254
|
+
glFinish()
|
253
255
|
end
|
254
256
|
|
255
257
|
def fixup_stats
|
256
|
-
|
257
|
-
|
258
|
-
|
258
|
+
empty = $stats.shift
|
259
|
+
|
260
|
+
$empty_time = empty[2]
|
259
261
|
$empty_frames = empty[3]
|
260
262
|
empty_tpf = $empty_time.to_f / $empty_frames
|
261
263
|
|
262
|
-
|
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
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
264
|
+
$total = ['totl,','avg'] + [0] * 12
|
265
|
+
$max = ['max','max'] + [0] * 12
|
266
|
+
|
267
|
+
$stats.each do |stat|
|
268
|
+
name, count, time, frames, pixpf, prmpf, tpf, vpf = stat
|
269
|
+
|
270
|
+
# Subtract out empty loop time, and loop if negative result
|
271
|
+
# $time -= $empty_tpf * $frames;
|
272
|
+
if (time <= 0)
|
273
|
+
stat += [0] * 5
|
274
|
+
next
|
275
|
+
end
|
276
|
+
|
277
|
+
# Calc "work", the geometric mean of pixels and vertices
|
278
|
+
workpf = Math::sqrt(pixpf * vpf)
|
279
|
+
|
280
|
+
# Calc fps
|
281
|
+
fps = frames / time
|
282
|
+
|
283
|
+
# Calc other perf stats
|
284
|
+
pixps = pixpf * fps
|
285
|
+
prmps = prmpf * fps
|
286
|
+
tps = tpf * fps
|
287
|
+
vps = vpf * fps
|
288
|
+
wps = workpf * fps
|
289
|
+
|
290
|
+
# Add them to stat row
|
291
|
+
stat += [fps, pixps, prmps, tps, vps, wps]
|
292
|
+
|
293
|
+
# Convert per frame counts to totals
|
294
|
+
(4..7).each { |i| stat[i] *= frames }
|
295
|
+
|
296
|
+
# Update running totals
|
297
|
+
(2..7).each { |i| $total[i] += stat[i] }
|
298
|
+
|
299
|
+
# Update running maximums
|
300
|
+
(2..13).each do |i|
|
301
|
+
$max[i] = stat[i] if $max[i] < stat[i]
|
302
|
+
end
|
303
|
+
|
304
|
+
$stats_fixed << stat
|
305
|
+
end
|
306
|
+
|
307
|
+
# Calc averages for totals line
|
308
|
+
(8..13).each { |i| $total[i] = $total[i-5] / $total[2].to_f }
|
309
|
+
|
310
|
+
$ready = true
|
311
|
+
$stats = $stats_fixed
|
310
312
|
end
|
311
313
|
|
312
314
|
|
313
315
|
def show_stats
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
316
|
+
basic = ["Name","Cnt","Time"]
|
317
|
+
raw = ["Frms","Mpix","Kprim","Ktri","Kvert"]
|
318
|
+
calc = raw
|
319
|
+
scale = [ 0, 6, 3, 3, 3, ] * 2
|
320
|
+
header = basic + raw + calc
|
321
|
+
scale.map! {|n| 10 ** n }
|
322
|
+
|
323
|
+
g_form = "%9s%-*s %s\n"
|
324
|
+
h_form = '%-5s%3s %6s' + ' %5s' * raw.size + ' ' + ' %5s' * calc.size + "\n"
|
325
|
+
format = '%-5s%3s %6.3f' + ' %5d' * raw.size + ' ' + ' %5d' * calc.size + "\n"
|
326
|
+
|
327
|
+
printf(g_form, '', 6 * 5 + 8, 'MEASURED', 'PER SECOND')
|
326
328
|
printf(h_form, *header)
|
327
329
|
printf(format, "empty", 1, $empty_time, $empty_frames, *([0] * 9))
|
328
330
|
#
|
329
331
|
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
332
|
+
($stats + [$total]).each do |stat|
|
333
|
+
st = stat.clone()
|
334
|
+
(0..scale.size-1).each do |i|
|
335
|
+
st[i + 3] /= scale[i]
|
336
|
+
end
|
337
|
+
printf(format,*st)
|
338
|
+
end
|
337
339
|
end
|
338
340
|
|
339
341
|
|
340
342
|
def make_quads_va(count,size)
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
343
|
+
data = []
|
344
|
+
(0 .. count-1).each do |y|
|
345
|
+
(0 .. count-1).each do |x|
|
346
|
+
data << x * size << y * size + size
|
347
|
+
data << x * size << y * size
|
348
|
+
data << x * size + size << y * size
|
349
|
+
data << x * size + size << y * size + size
|
350
|
+
end
|
351
|
+
end
|
352
|
+
data
|
351
353
|
end
|
352
354
|
|
353
355
|
def make_tris_va(count,size)
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
356
|
+
data = []
|
357
|
+
(0 .. count-1).each do |y|
|
358
|
+
(0 .. count-1).each do |x|
|
359
|
+
data << x * size << y * size + size
|
360
|
+
data << x * size << y * size
|
361
|
+
data << x * size + size << y * size + size
|
362
|
+
|
363
|
+
data << x * size + size << y * size + size
|
364
|
+
data << x * size << y * size
|
365
|
+
data << x * size + size << y * size
|
366
|
+
end
|
367
|
+
end
|
368
|
+
data
|
367
369
|
end
|
368
370
|
|
369
371
|
def make_qs_va(count,size)
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
372
|
+
data = []
|
373
|
+
(0 .. count-1).each do |y|
|
374
|
+
(0 .. count).each do |x|
|
375
|
+
data << x * size << y * size + size
|
376
|
+
data << x * size << y * size
|
375
377
|
end
|
376
|
-
|
377
|
-
|
378
|
+
end
|
379
|
+
data
|
378
380
|
end
|
379
381
|
|
380
382
|
def make_ts_va(count,size)
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
383
|
+
data = []
|
384
|
+
(0 .. count-1).each do |y|
|
385
|
+
(0 .. count).each do |x|
|
386
|
+
data << x * size << y * size + size
|
387
|
+
data << x * size << y * size
|
386
388
|
end
|
387
|
-
|
388
|
-
|
389
|
+
end
|
390
|
+
data
|
389
391
|
end
|
390
392
|
|
391
393
|
def draw_qs(count,size)
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
394
|
+
(0 .. count-1).each do |y|
|
395
|
+
glBegin(GL_QUAD_STRIP)
|
396
|
+
(0 .. count).each do |x|
|
397
|
+
glVertex2f(x * size, y * size + size)
|
398
|
+
glVertex2f(x * size, y * size )
|
399
|
+
end
|
400
|
+
glEnd()
|
401
|
+
end
|
400
402
|
end
|
401
403
|
|
402
404
|
def draw_ts(count,size)
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
405
|
+
(0 .. count-1).each do |y|
|
406
|
+
glBegin(GL_TRIANGLE_STRIP)
|
407
|
+
(0 .. count).each do |x|
|
408
|
+
glVertex2f(x * size, y * size + size)
|
409
|
+
glVertex2f(x * size, y * size )
|
410
|
+
end
|
411
|
+
glEnd()
|
412
|
+
end
|
411
413
|
end
|
412
414
|
|
413
415
|
def draw_qs_va(count,size)
|
414
|
-
|
415
|
-
|
416
|
+
va = $vas["qs_#{count}"]
|
417
|
+
row = 2 * (count + 1)
|
416
418
|
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
419
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
420
|
+
glVertexPointer(2, GL_FLOAT, 0, va)
|
421
|
+
(0 .. count-1).each do |y|
|
422
|
+
glDrawArrays(GL_QUAD_STRIP, y * row, row)
|
423
|
+
end
|
424
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
423
425
|
end
|
424
426
|
|
425
427
|
def draw_ts_va(count,size)
|
426
|
-
|
427
|
-
|
428
|
+
va = $vas["ts_#{count}"]
|
429
|
+
row = 2 * (count + 1)
|
428
430
|
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
431
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
432
|
+
glVertexPointer(2, GL_FLOAT, 0, va)
|
433
|
+
(0 .. count-1).each do |y|
|
434
|
+
glDrawArrays(GL_TRIANGLE_STRIP, y * row, row)
|
435
|
+
end
|
436
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
435
437
|
end
|
436
438
|
|
437
439
|
def draw_tris(count,size)
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
440
|
+
glBegin(GL_TRIANGLES)
|
441
|
+
(0 .. count-1).each do |y|
|
442
|
+
(0 .. count-1).each do |x|
|
443
|
+
glVertex2f(x * size , y * size + size)
|
444
|
+
glVertex2f(x * size , y * size )
|
445
|
+
glVertex2f(x * size + size, y * size + size)
|
446
|
+
|
447
|
+
glVertex2f(x * size + size, y * size + size)
|
448
|
+
glVertex2f(x * size , y * size )
|
449
|
+
glVertex2f(x * size + size, y * size )
|
450
|
+
end
|
451
|
+
end
|
452
|
+
glEnd
|
451
453
|
end
|
452
454
|
|
453
455
|
def stats_tris(count,size)
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
456
|
+
length = size * count
|
457
|
+
area = length * length
|
458
|
+
prims = 2 * count * count
|
459
|
+
tris = prims
|
460
|
+
verts = 3 * prims
|
461
|
+
|
462
|
+
[area, prims, tris, verts]
|
461
463
|
end
|
462
464
|
|
463
465
|
def draw_empty(count,size)
|
@@ -468,50 +470,50 @@ def stats_empty(count,size)
|
|
468
470
|
end
|
469
471
|
|
470
472
|
def draw_quads(count,size)
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
473
|
+
glBegin(GL_QUADS)
|
474
|
+
(0 .. count-1).each do |y|
|
475
|
+
(0 .. count-1).each do |x|
|
476
|
+
glVertex2f(x * size , y * size + size)
|
477
|
+
glVertex2f(x * size , y * size )
|
478
|
+
glVertex2f(x * size + size, y * size )
|
479
|
+
glVertex2f(x * size + size, y * size + size)
|
480
|
+
end
|
481
|
+
end
|
482
|
+
glEnd
|
481
483
|
end
|
482
484
|
|
483
485
|
def stats_quads(count,size)
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
486
|
+
length = size * count
|
487
|
+
area = length * length
|
488
|
+
prims = count * count
|
489
|
+
tris = 2 * prims
|
490
|
+
verts = 4 * prims
|
489
491
|
|
490
|
-
|
492
|
+
[area, prims, tris, verts]
|
491
493
|
end
|
492
494
|
|
493
495
|
def stats_ts(count,size)
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
496
|
+
length = size * count
|
497
|
+
area = length * length
|
498
|
+
prims = count
|
499
|
+
tris = 2 * count * prims
|
500
|
+
verts = 2 * (count + 1) * prims
|
501
|
+
|
502
|
+
[area, prims, tris, verts]
|
501
503
|
end
|
502
504
|
|
503
505
|
def stats_qs(count,size)
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
506
|
+
length = size * count
|
507
|
+
area = length * length
|
508
|
+
prims = count
|
509
|
+
tris = 2 * count * prims
|
510
|
+
verts = 2 * (count + 1) * prims
|
511
|
+
|
512
|
+
[area, prims, tris, verts]
|
511
513
|
end
|
512
514
|
|
513
515
|
def draw_ts_dl(count,size)
|
514
|
-
|
516
|
+
glCallList($dls["ts_#{count}"]);
|
515
517
|
end
|
516
518
|
|
517
519
|
def draw_qs_dl(count,size)
|
@@ -519,310 +521,309 @@ def draw_qs_dl(count,size)
|
|
519
521
|
end
|
520
522
|
|
521
523
|
def draw_tris_va(count,size)
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
524
|
+
va = $vas["t_#{count}"]
|
525
|
+
|
526
|
+
glVertexPointer(2, GL_FLOAT, 0, va)
|
527
|
+
|
528
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
529
|
+
glDrawArrays(GL_TRIANGLES, 0, 6 * count * count)
|
530
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
529
531
|
end
|
530
532
|
|
531
533
|
def draw_quads_va(count,size)
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
534
|
+
va = $vas["q_#{count}"]
|
535
|
+
|
536
|
+
glVertexPointer(2, GL_FLOAT, 0, va)
|
537
|
+
|
538
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
539
|
+
glDrawArrays(GL_QUADS, 0, 4 * count * count)
|
540
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
539
541
|
end
|
540
542
|
|
541
543
|
|
542
544
|
def draw_ts_va_dl(count,size)
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
545
|
+
va = $vas["ts_#{count}"]
|
546
|
+
|
547
|
+
glVertexPointer(2, GL_FLOAT, 0, va)
|
548
|
+
|
549
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
550
|
+
glCallList($dls["tsv_#{count}"])
|
551
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
550
552
|
end
|
551
553
|
|
552
554
|
def draw_qs_va_dl(count,size)
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
555
|
+
va = $vas["qs_#{count}"]
|
556
|
+
|
557
|
+
glVertexPointer(2, GL_FLOAT, 0, va)
|
558
|
+
|
559
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
560
|
+
glCallList($dls["qsv_#{count}"])
|
561
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
560
562
|
end
|
561
563
|
|
562
564
|
|
563
565
|
def draw_stats
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
566
|
+
return if (!$ready)
|
567
|
+
|
568
|
+
# Graph config
|
569
|
+
x_off = 10
|
570
|
+
y_off = 10
|
571
|
+
tick_size = 3
|
572
|
+
val_space = 50
|
573
|
+
key_size = 20
|
574
|
+
x_scale = ($w - 4 * x_off) / (2 * ($fast.last || $slow.last))
|
575
|
+
key_scale = ($h - 4 * y_off) / (2 * $tests.size)
|
576
|
+
|
577
|
+
# Get a fresh black frame for graphing
|
578
|
+
glClearColor(0, 0, 0, 1)
|
579
|
+
start_frame()
|
580
|
+
|
581
|
+
# Use antialiased lines
|
582
|
+
glEnable(GL_BLEND)
|
583
|
+
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
584
|
+
glEnable(GL_LINE_SMOOTH)
|
585
|
+
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
|
586
|
+
|
587
|
+
# Draw axis ticks
|
588
|
+
glColor3f(1, 1, 1);
|
589
|
+
glBegin(GL_LINES);
|
590
|
+
|
591
|
+
([0] + $slow + $fast).each do |count|
|
592
|
+
x_tick = count * x_scale + x_off
|
593
|
+
glVertex2f(x_tick, y_off)
|
594
|
+
glVertex2f(x_tick, y_off - tick_size)
|
595
|
+
glVertex2f(x_tick, y_off + $h / 2)
|
596
|
+
glVertex2f(x_tick, y_off + $h / 2 - tick_size)
|
597
|
+
glVertex2f(x_tick + $w / 2, y_off + $h / 2)
|
598
|
+
glVertex2f(x_tick + $w / 2, y_off + $h / 2 - tick_size)
|
599
|
+
end
|
600
|
+
glEnd
|
601
|
+
|
602
|
+
x_tick = x_off + 3
|
603
|
+
val_max = (($h / 2 - 2 * y_off) / val_space).to_i
|
604
|
+
|
605
|
+
# Work
|
606
|
+
(0..val_max).each do |value|
|
607
|
+
y_tick = value * val_space + y_off
|
608
|
+
|
609
|
+
glBegin(GL_LINES)
|
610
|
+
glVertex2f(x_off, y_tick)
|
611
|
+
glVertex2f(x_off - tick_size, y_tick)
|
612
|
+
glEnd
|
613
|
+
end
|
614
|
+
|
615
|
+
# Pixels
|
616
|
+
value = 0
|
617
|
+
val_max = $max[9] / mag_scale($max[9])
|
618
|
+
y_scale = ($h - 4 * y_off) / (2 * val_max)
|
619
|
+
val_inc = tick_inc(val_max,5)
|
620
|
+
|
621
|
+
while (value < val_max)
|
622
|
+
y_tick = (value * y_scale) + y_off
|
623
|
+
|
624
|
+
glBegin(GL_LINES)
|
625
|
+
glVertex2f(x_off, y_tick + $h / 2)
|
626
|
+
glVertex2f(x_off - tick_size, y_tick + $h / 2)
|
627
|
+
glEnd
|
628
|
+
OGLBench.draw_string($font_style, value.to_s, x_tick, y_tick + $h / 2) if (value!=0)
|
629
|
+
value += val_inc
|
630
|
+
end
|
631
|
+
|
632
|
+
# Vertices
|
633
|
+
value = 0
|
634
|
+
val_max = $max[12] / mag_scale($max[12])
|
635
|
+
y_scale = ($h - 4 * y_off) / (2 * val_max)
|
636
|
+
val_inc = tick_inc(val_max,5)
|
637
|
+
while (value < val_max)
|
638
|
+
y_tick = (value * y_scale) + y_off
|
639
|
+
|
640
|
+
glBegin(GL_LINES)
|
641
|
+
glVertex2f(x_off + $w / 2, y_tick + $h / 2)
|
642
|
+
glVertex2f(x_off + $w / 2 - tick_size, y_tick + $h / 2)
|
643
|
+
glEnd
|
644
|
+
|
645
|
+
OGLBench.draw_string($font_style, value.to_s, x_tick + $w / 2, y_tick + $h / 2) if (value!=0)
|
646
|
+
value += val_inc
|
647
|
+
end
|
648
|
+
|
649
|
+
# Draw axes
|
650
|
+
glBegin(GL_LINE_STRIP)
|
651
|
+
glVertex2f(x_off, $h / 2 - y_off)
|
652
|
+
glVertex2f(x_off, y_off)
|
653
|
+
glVertex2f($w / 2 - x_off, y_off)
|
654
|
+
glEnd
|
655
|
+
glBegin(GL_LINE_STRIP)
|
656
|
+
glVertex2f(x_off, $h - y_off)
|
657
|
+
glVertex2f(x_off, $h / 2 + y_off)
|
658
|
+
glVertex2f($w / 2 - x_off, $h / 2 + y_off)
|
659
|
+
glEnd
|
660
|
+
glBegin(GL_LINE_STRIP)
|
661
|
+
glVertex2f($w / 2 + x_off, $h - y_off)
|
662
|
+
glVertex2f($w / 2 + x_off, $h / 2 + y_off)
|
663
|
+
glVertex2f($w - x_off, $h / 2 + y_off)
|
664
|
+
glEnd
|
663
665
|
|
664
666
|
# Draw color key
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
667
|
+
(0..$tests.size - 1).each do |num|
|
668
|
+
test = $tests[num]
|
669
|
+
name,color,stipple = [test[0]] + test[-2,2]
|
670
|
+
glEnable(GL_LINE_STIPPLE)
|
671
|
+
glLineStipple(3, stipple)
|
670
672
|
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
673
|
+
glBegin(GL_LINES)
|
674
|
+
glColor3fv(color)
|
675
|
+
glVertex2f(x_off + $w / 2, y_off + num * key_scale)
|
676
|
+
glVertex2f(x_off + $w / 2 + key_size, y_off + num * key_scale)
|
677
|
+
glEnd()
|
676
678
|
|
677
|
-
|
679
|
+
glDisable(GL_LINE_STIPPLE)
|
678
680
|
|
679
|
-
|
680
|
-
|
681
|
+
OGLBench.draw_string($font_style, name, x_off + $w / 2 + key_size * 2, y_off + num * key_scale)
|
682
|
+
end
|
681
683
|
|
682
|
-
|
684
|
+
# Draw performance graph lines
|
683
685
|
|
684
|
-
|
685
|
-
|
686
|
-
|
686
|
+
# Pixels per second
|
687
|
+
draw_one_stat(x_off, y_off + $h / 2, y_off, x_scale, 9)
|
688
|
+
glColor3f(1, 1, 1)
|
687
689
|
|
688
|
-
|
690
|
+
OGLBench.draw_string($font_style, mag_char($max[9]) + " Pixels/Sec", $w / 4, $h - 2 * y_off)
|
689
691
|
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
692
|
+
# Vertices per second
|
693
|
+
draw_one_stat(x_off + $w / 2, y_off + $h / 2, y_off, x_scale, 12)
|
694
|
+
glColor3f(1, 1, 1)
|
695
|
+
OGLBench.draw_string($font_style, mag_char($max[12]) + " Vertices/Sec", 3 * $w / 4, $h - 2 * y_off)
|
694
696
|
|
695
|
-
|
696
|
-
|
697
|
-
|
697
|
+
# "Work" per second, the geometric mean of pixels and vertices
|
698
|
+
draw_one_stat(x_off, y_off, y_off, x_scale, 13)
|
699
|
+
glColor3f(1, 1, 1)
|
698
700
|
|
699
|
-
|
701
|
+
OGLBench.draw_string($font_style, "Work/Sec", $w / 4, $h / 2 - 2 * y_off)
|
700
702
|
|
701
|
-
|
702
|
-
|
703
|
-
|
703
|
+
# Show our graph
|
704
|
+
end_frame();
|
705
|
+
$showing_graph = true
|
704
706
|
end
|
705
707
|
|
706
708
|
def draw_one_stat(x_loc,y_loc,y_off,x_scale,num)
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
709
|
+
max = $max[num]
|
710
|
+
y_scale = ($h - 4 * y_off) / (2 * max)
|
711
|
+
colors = {}
|
712
|
+
$tests.each do |test| colors[test[0]] = test[-2] end
|
713
|
+
|
714
|
+
stipple = {}
|
715
|
+
$tests.each do |test| stipple[test[0]] = test[-1] end
|
716
|
+
|
717
|
+
last = ''
|
718
|
+
|
719
|
+
glEnable(GL_LINE_STIPPLE)
|
720
|
+
glBegin(GL_LINE_STRIP)
|
721
|
+
$stats.each_with_index do |stat,run|
|
722
|
+
name,count, st = stat[0,2] + [stat[num]]
|
723
|
+
|
724
|
+
if name != last
|
725
|
+
glEnd
|
726
|
+
glLineStipple(3, stipple[name])
|
727
|
+
glBegin(GL_LINE_STRIP)
|
728
|
+
last = name
|
729
|
+
end
|
728
730
|
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
731
|
+
glColor3fv(colors[name])
|
732
|
+
glVertex2f(count * x_scale + x_loc, st * y_scale + y_loc)
|
733
|
+
end
|
734
|
+
glEnd
|
735
|
+
glDisable(GL_LINE_STIPPLE)
|
734
736
|
end
|
735
737
|
|
736
738
|
|
737
739
|
def kilo_mag(num)
|
738
|
-
|
739
|
-
|
740
|
+
mag = (Math::log(num) / Math::log(10)).to_i
|
741
|
+
(mag / 3)
|
740
742
|
end
|
741
743
|
|
742
744
|
def mag_char(num)
|
743
|
-
|
745
|
+
['','K','M','G','T','P','E','Z','Y'][kilo_mag(num)]
|
744
746
|
end
|
745
747
|
|
746
748
|
def mag_scale(num)
|
747
|
-
|
749
|
+
10 ** (3*kilo_mag(num))
|
748
750
|
end
|
749
751
|
|
750
752
|
def tick_inc(max,parts = 5)
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
753
|
+
return (max / parts.to_f) if (max < 1)
|
754
|
+
|
755
|
+
mag = (Math::log(max) / Math::log(10)).to_i
|
756
|
+
scl = (10 ** (mag - 1))
|
757
|
+
inc = max / (scl * parts)
|
758
|
+
|
759
|
+
if (inc > 7.5)
|
760
|
+
inc = 10
|
761
|
+
elsif (inc > 3.5)
|
762
|
+
inc = 5
|
763
|
+
elsif (inc > 1.5)
|
764
|
+
inc = 2
|
765
|
+
else
|
766
|
+
inc = 1
|
767
|
+
end
|
768
|
+
(inc * scl.to_f)
|
767
769
|
end
|
768
770
|
|
769
771
|
# State engine
|
770
772
|
def cbDraw
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
773
|
+
if (!$done)
|
774
|
+
benchmark()
|
775
|
+
elsif (!$ready)
|
776
|
+
cleanup()
|
777
|
+
else
|
778
|
+
sleep(1)
|
779
|
+
draw_stats()
|
780
|
+
end
|
779
781
|
end
|
780
782
|
|
781
783
|
# Keyboard handler
|
782
784
|
def cbKeyPressed(key,x,y)
|
783
785
|
if (key == ?\e or key == ?q)
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
786
|
+
glutDestroyWindow($app)
|
787
|
+
exit(0)
|
788
|
+
end
|
789
|
+
if ($done && key == ?r)
|
790
|
+
draw_stats()
|
791
|
+
end
|
790
792
|
end
|
791
793
|
|
792
794
|
|
793
795
|
### METHODS TO BENCHMARK
|
794
796
|
|
795
797
|
$va_types = {
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
798
|
+
"q" => method(:make_quads_va),
|
799
|
+
"t" => method(:make_tris_va),
|
800
|
+
"qs" => method(:make_qs_va),
|
801
|
+
"ts" => method(:make_ts_va),
|
800
802
|
}
|
801
803
|
|
802
804
|
$dl_types = {
|
803
|
-
|
805
|
+
"qs" => method(:draw_qs),
|
804
806
|
"ts" => method(:draw_ts),
|
805
807
|
"qsv" => method(:draw_qs_va),
|
806
|
-
|
808
|
+
"tsv" => method(:draw_ts_va),
|
807
809
|
}
|
808
810
|
|
809
811
|
$tests = [
|
810
|
-
|
811
|
-
#
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
812
|
+
# Nick Draw Routine Stats Calc Type Graph Color
|
813
|
+
# ["empty",method(:draw_empty), method(:stats_empty),'single',[1 , 1, 1], 0xFFFF],
|
814
|
+
["t" ,method(:draw_tris), method(:stats_tris) ,'slow', [1 , 0, 0], 0xAAAA],
|
815
|
+
["q" ,method(:draw_quads), method(:stats_quads),'slow', [1 ,0.5, 0], 0xAAAA],
|
816
|
+
["ts" ,method(:draw_ts), method(:stats_ts), 'slow', [1 , 1, 0], 0xAAAA],
|
817
|
+
["qs" ,method(:draw_qs), method(:stats_qs), 'slow', [0 , 1, 0], 0xAAAA],
|
818
|
+
["tsd" ,method(:draw_ts_dl), method(:stats_ts), 'fast', [0 , 1, 1], 0xAAAA],
|
819
|
+
["qsd" ,method(:draw_qs_dl), method(:stats_qs), 'fast', [0 , 0, 1], 0xAAAA],
|
820
|
+
["tv" ,method(:draw_tris_va), method(:stats_tris), 'fast', [0.8, 0, 0], 0xFFFF],
|
821
|
+
["qv" ,method(:draw_quads_va),method(:stats_quads),'fast', [0.8,0.4, 0], 0xFFFF],
|
822
|
+
["tsv" ,method(:draw_ts_va), method(:stats_ts), 'fast', [0.8,0.8, 0], 0xFFFF],
|
823
|
+
["qsv" ,method(:draw_qs_va), method(:stats_qs), 'fast', [0 ,0.8, 0], 0xFFFF],
|
824
|
+
["tsvd" ,method(:draw_ts_va_dl),method(:stats_ts), 'fast', [0 ,0.8,0.8], 0xFFFF],
|
825
|
+
["qsvd" ,method(:draw_qs_va_dl),method(:stats_qs), 'fast', [0 , 0,0.8], 0xFFFF],
|
824
826
|
]
|
825
827
|
|
826
828
|
# Start from main function ()
|
827
829
|
main()
|
828
|
-
|