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.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +2 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +19 -0
  6. data/History.rdoc +26 -0
  7. data/Manifest.txt +3 -23
  8. data/README.rdoc +43 -37
  9. data/Rakefile +6 -62
  10. data/examples/NeHe/nehe_lesson02.rb +3 -2
  11. data/examples/NeHe/nehe_lesson03.rb +3 -2
  12. data/examples/NeHe/nehe_lesson04.rb +3 -1
  13. data/examples/NeHe/nehe_lesson05.rb +4 -1
  14. data/examples/NeHe/nehe_lesson06.rb +9 -6
  15. data/examples/NeHe/nehe_lesson07.rb +9 -6
  16. data/examples/NeHe/nehe_lesson08.rb +9 -6
  17. data/examples/NeHe/nehe_lesson09.rb +10 -6
  18. data/examples/NeHe/nehe_lesson11.rb +9 -6
  19. data/examples/NeHe/nehe_lesson12.rb +9 -6
  20. data/examples/NeHe/nehe_lesson16.rb +50 -47
  21. data/examples/NeHe/nehe_lesson19.rb +10 -7
  22. data/examples/NeHe/nehe_lesson36.rb +234 -229
  23. data/examples/OrangeBook/brick.rb +227 -225
  24. data/examples/OrangeBook/particle.rb +233 -231
  25. data/examples/RedBook/aapoly.rb +71 -70
  26. data/examples/RedBook/aargb.rb +54 -52
  27. data/examples/RedBook/accanti.rb +96 -94
  28. data/examples/RedBook/accpersp.rb +106 -104
  29. data/examples/RedBook/alpha.rb +54 -52
  30. data/examples/RedBook/alpha3D.rb +90 -88
  31. data/examples/RedBook/bezcurve.rb +48 -46
  32. data/examples/RedBook/bezmesh.rb +71 -69
  33. data/examples/RedBook/checker.rb +57 -55
  34. data/examples/RedBook/clip.rb +41 -39
  35. data/examples/RedBook/colormat.rb +72 -70
  36. data/examples/RedBook/cube.rb +39 -37
  37. data/examples/RedBook/depthcue.rb +37 -35
  38. data/examples/RedBook/dof.rb +110 -109
  39. data/examples/RedBook/double.rb +40 -38
  40. data/examples/RedBook/drawf.rb +30 -28
  41. data/examples/RedBook/feedback.rb +79 -77
  42. data/examples/RedBook/fog.rb +90 -89
  43. data/examples/RedBook/font.rb +78 -76
  44. data/examples/RedBook/hello.rb +29 -27
  45. data/examples/RedBook/image.rb +57 -55
  46. data/examples/RedBook/jitter.rb +131 -131
  47. data/examples/RedBook/light.rb +2 -1
  48. data/examples/RedBook/lines.rb +70 -68
  49. data/examples/RedBook/list.rb +48 -46
  50. data/examples/RedBook/material.rb +200 -199
  51. data/examples/RedBook/mipmap.rb +84 -82
  52. data/examples/RedBook/model.rb +55 -53
  53. data/examples/RedBook/movelight.rb +52 -50
  54. data/examples/RedBook/pickdepth.rb +103 -101
  55. data/examples/RedBook/planet.rb +46 -44
  56. data/examples/RedBook/quadric.rb +97 -95
  57. data/examples/RedBook/robot.rb +55 -53
  58. data/examples/RedBook/select.rb +118 -116
  59. data/examples/RedBook/smooth.rb +35 -33
  60. data/examples/RedBook/stencil.rb +96 -94
  61. data/examples/RedBook/stroke.rb +75 -73
  62. data/examples/RedBook/surface.rb +93 -91
  63. data/examples/RedBook/teaambient.rb +71 -69
  64. data/examples/RedBook/teapots.rb +105 -103
  65. data/examples/RedBook/tess.rb +96 -94
  66. data/examples/RedBook/texbind.rb +79 -77
  67. data/examples/RedBook/texgen.rb +88 -86
  68. data/examples/RedBook/texturesurf.rb +57 -55
  69. data/examples/RedBook/varray.rb +85 -83
  70. data/examples/RedBook/wrap.rb +76 -74
  71. data/examples/misc/OGLBench.rb +114 -113
  72. data/examples/misc/anisotropic.rb +154 -152
  73. data/examples/misc/fbo_test.rb +37 -36
  74. data/examples/misc/font-glut.rb +47 -46
  75. data/examples/misc/glfwtest.rb +16 -16
  76. data/examples/misc/plane.rb +13 -13
  77. data/examples/misc/readpixel.rb +66 -65
  78. data/examples/misc/sdltest.rb +21 -19
  79. data/examples/misc/trislam.rb +548 -547
  80. data/ext/opengl/common.h +16 -38
  81. data/ext/opengl/conv.h +39 -41
  82. data/ext/opengl/extconf.rb +4 -31
  83. data/ext/opengl/funcdef.h +126 -124
  84. data/ext/opengl/gl-1.0-1.1.c +1917 -1917
  85. data/ext/opengl/gl-1.2.c +4 -667
  86. data/ext/opengl/gl-1.3.c +9 -9
  87. data/ext/opengl/gl-1.4.c +8 -8
  88. data/ext/opengl/gl-1.5.c +1 -1
  89. data/ext/opengl/gl-2.0.c +392 -388
  90. data/ext/opengl/gl-3.0.c +493 -0
  91. data/ext/opengl/gl-enums.c +1523 -5
  92. data/ext/opengl/gl-enums.h +4679 -122
  93. data/ext/opengl/gl-error.c +7 -7
  94. data/ext/opengl/gl-error.h +4 -4
  95. data/ext/opengl/gl-ext-arb.c +468 -464
  96. data/ext/opengl/gl-ext-ext.c +18 -18
  97. data/ext/opengl/gl-ext-nv.c +15 -15
  98. data/ext/opengl/gl.c +2 -0
  99. data/ext/opengl/gl_buffer.c +92 -92
  100. data/ext/opengl/opengl.c +1 -7
  101. data/lib/opengl.rb +23 -59
  102. data/lib/opengl/1.9/opengl.so +0 -0
  103. data/lib/opengl/2.0/opengl.so +0 -0
  104. data/lib/opengl/2.1/opengl.so +0 -0
  105. data/lib/opengl/test_case.rb +1 -2
  106. data/test/dummy.xorg.conf +140 -0
  107. data/test/test_gl.rb +18 -22
  108. data/test/test_gl_10_11.rb +220 -220
  109. data/test/test_gl_12.rb +11 -122
  110. data/test/test_gl_13.rb +202 -210
  111. data/test/test_gl_14.rb +16 -19
  112. data/test/test_gl_15.rb +2 -4
  113. data/test/test_gl_20.rb +45 -58
  114. data/test/test_gl_21.rb +46 -163
  115. data/test/test_gl_ext_arb.rb +54 -72
  116. data/test/test_gl_ext_ati.rb +0 -2
  117. data/test/test_gl_ext_ext.rb +66 -66
  118. data/test/test_gl_ext_gremedy.rb +8 -15
  119. data/test/test_gl_ext_nv.rb +109 -112
  120. data/test/test_opengl_buffer.rb +8 -25
  121. data/utils/README +0 -5
  122. data/utils/enumgen.rb +72 -76
  123. data/utils/extlistgen.rb +55 -55
  124. metadata +90 -67
  125. metadata.gz.sig +0 -0
  126. data/Rakefile.cross +0 -107
  127. data/docs/build_install.txt +0 -119
  128. data/docs/extensions.txt.in +0 -348
  129. data/docs/history.txt +0 -66
  130. data/docs/requirements_and_design.txt +0 -117
  131. data/docs/roadmap.txt +0 -28
  132. data/docs/scientific_use.txt +0 -35
  133. data/docs/supplies/page_template.html +0 -71
  134. data/docs/thanks.txt +0 -29
  135. data/docs/tutorial.txt +0 -469
  136. data/ext/opengl/glu-enums.c +0 -164
  137. data/ext/opengl/glu-enums.h +0 -463
  138. data/ext/opengl/glu.c +0 -1534
  139. data/ext/opengl/glut.c +0 -1145
  140. data/ext/opengl/glut_callbacks.c +0 -845
  141. data/lib/glu.rb +0 -1
  142. data/lib/glut.rb +0 -1
  143. data/lib/opengl/opengl.so +0 -0
  144. data/test/test_glu.rb +0 -309
  145. data/utils/mkdn2html.rb +0 -59
  146. data/utils/post-mkdn2html.rb +0 -91
  147. data/website/images/ogl.jpg +0 -0
  148. data/website/images/tab_bottom.gif +0 -0
  149. data/website/style.css +0 -198
@@ -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
- while event = SDL::Event2.poll
12
- case event
13
- when SDL::Event2::KeyDown, SDL::Event2::Quit
14
- exit
15
- end
16
- end
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
- Gl.glClear( Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT )
20
+ Gl.glClear( Gl::GL_COLOR_BUFFER_BIT | Gl::GL_DEPTH_BUFFER_BIT )
19
21
 
20
- Gl.glBegin( Gl::GL_POLYGON )
21
- Gl.glColor3f( 1.0, 0.0, 0.0 )
22
- Gl.glVertex2f( -0.5, -0.5 )
23
- Gl.glColor3f( 0.0, 1.0, 0.0 )
24
- Gl.glVertex2f( -0.5, 0.5 )
25
- Gl.glColor3f( 0.0, 0.0, 1.0 )
26
- Gl.glVertex2f( 0.5, 0.5 )
27
- Gl.glColor3f( 1.0, 0.0, 1.0 )
28
- Gl.glVertex2f( 0.5, -0.5 )
29
- Gl.glEnd
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
- SDL.GLSwapBuffers()
33
+ SDL.GLSwapBuffers()
32
34
 
33
- sleep 0.01 # to avoid consuming all CPU power
35
+ sleep 0.01 # to avoid consuming all CPU power
34
36
  end
@@ -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
- require 'OGLBench'
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
- init()
69
- print "Benchmarks:"
70
+ init()
71
+ print "Benchmarks:"
70
72
 
71
- glutDisplayFunc(method(:cbDraw).to_proc)
72
- glutIdleFunc(method(:cbDraw).to_proc)
73
- glutKeyboardFunc(method(:cbKeyPressed).to_proc)
74
- glutMainLoop()
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
- $stdout.sync = true
80
+ $stdout.sync = true
79
81
 
80
- $combos = recurse_combos($max_powers)
81
- $combos.sort!
82
- $slow = $combos.select { |a| a <= $max_count_slow }
83
- $fast = $combos.select { |a| a > $max_count_slow &&
84
- a <= $max_count_slow }
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
- # Choose drawing area size to match counts
87
- $h = $w = $combos.last
88
+ # Choose drawing area size to match counts
89
+ $h = $w = $combos.last
88
90
 
89
91
  default_conf = {
90
- :title => 'Triangle Slammer OpenGL Benchmark',
91
- :geometry => "#{$w}x#{$h}",
92
- :frames => 10,
93
- :seconds => 1,
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
- # Reduce indirections in inner loops
99
- $MIN_FRAMES, $MIN_SECONDS = $conf[:frames], $conf[:seconds]
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
- # Change projection to integer-pixel ortho
105
- glMatrixMode(GL_PROJECTION)
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
- # Make sure GL state is consistent for VA and DL creation
110
- start_frame()
111
-
112
- # Create vertex arrays and display lists outside timing loop
113
- init_vertex_arrays()
114
- init_display_lists()
115
-
116
- # Clean up GL state
117
- end_frame()
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
- base, max_power, *rest = powers
123
+ base, max_power, *rest = powers
122
124
 
123
- return [1] if powers.size<1
125
+ return [1] if powers.size<1
124
126
 
125
- combos = []
126
- (0..max_power).each do |power|
127
- multiplier = base ** power
128
- recurse_combos(rest).each do |item|
129
- combos << (item*multiplier)
130
- end
131
- end
132
- combos
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
- print <<"EOM";
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
- OGLBench.show_basic_config($conf, $gl_info, VER)
148
-
149
- puts "standard runs: #{$slow.join(' ')}"
150
- puts "extra fast runs: #{$fast.join(' ')}"
151
- puts '-' * 79
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
- print "Init vertex arrays:"
157
-
158
- $va_types.keys.sort.each do |type|
159
- print " #{type}"
160
- ($slow + $fast).each do |count|
161
- data = $va_types[type].call(count, $w / count.to_f)
162
- va = data.pack("f*")
163
- $vas["#{type}_#{count}"] = va
164
- end
165
- end
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
- print ".\n";
169
+ print ".\n";
168
170
  end
169
171
 
170
172
  def init_display_lists
171
- print "Init display lists:"
172
-
173
- num_lists = $dl_types.size * ($slow + $fast).size
174
- current = glGenLists(num_lists)
175
-
176
- $dl_types.keys.sort.each do |type|
177
- print " #{type}"
178
- ($slow + $fast).each do |count|
179
- $dls["#{type}_#{count}"] = current
180
- glNewList(current, GL_COMPILE)
181
- $dl_types[type].call(count, $w / count.to_f)
182
- glEndList()
183
- current += 1
184
- end
185
- end
186
- puts "."
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
- if ($test >= $tests.size)
191
- print ".\n" if (!$done)
192
- $done = true
193
- return
194
- end
195
- name,draw,stats,class_ = $tests[$test]
196
-
197
- counts = class_ == 'single' ? [1] : (class_ == 'slow' ? $slow : $slow + $fast)
198
-
199
- if ($run == 0)
200
- print " #{name}";
201
-
202
- # After printing current test name, busy wait for a second
203
- # so that the terminal can catch up and not do work while
204
- # the GL timing is in progress
205
- a = Time.now
206
- while 1 > (Time.now - a) do end
207
- end
208
-
209
- count = counts[$run]
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
- OGLBench.fade_to_white(($test + ($run.to_f / counts.size)) / $tests.size)
214
+ OGLBench.fade_to_white(($test + ($run.to_f / counts.size)) / $tests.size)
213
215
 
214
- run_done = 0
216
+ run_done = 0
215
217
  frames = 0
216
218
  start = Time.now
217
219
 
218
220
  while (run_done==0)
219
- start_frame()
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
- end
227
- glFinish()
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
- $run += 1
234
- if ($run >= counts.size)
235
- $test += 1
236
- $run = 0
237
- end
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
- fixup_stats()
242
- show_stats()
243
- draw_stats()
243
+ fixup_stats()
244
+ show_stats()
245
+ draw_stats()
244
246
  end
245
247
 
246
248
  def start_frame
247
- glClear(GL_COLOR_BUFFER_BIT |
248
- GL_DEPTH_BUFFER_BIT)
249
+ glClear(GL_COLOR_BUFFER_BIT |
250
+ GL_DEPTH_BUFFER_BIT)
249
251
  end
250
252
 
251
253
  def end_frame
252
- glFinish()
254
+ glFinish()
253
255
  end
254
256
 
255
257
  def fixup_stats
256
- empty = $stats.shift
257
-
258
- $empty_time = empty[2]
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
- $total = ['totl,','avg'] + [0] * 12
263
- $max = ['max','max'] + [0] * 12
264
-
265
- $stats.each do |stat|
266
- name, count, time, frames, pixpf, prmpf, tpf, vpf = stat
267
-
268
- # Subtract out empty loop time, and loop if negative result
269
- # $time -= $empty_tpf * $frames;
270
- if (time <= 0)
271
- stat += [0] * 5
272
- next
273
- end
274
-
275
- # Calc "work", the geometric mean of pixels and vertices
276
- workpf = Math::sqrt(pixpf * vpf)
277
-
278
- # Calc fps
279
- fps = frames / time
280
-
281
- # Calc other perf stats
282
- pixps = pixpf * fps
283
- prmps = prmpf * fps
284
- tps = tpf * fps
285
- vps = vpf * fps
286
- wps = workpf * fps
287
-
288
- # Add them to stat row
289
- stat += [fps, pixps, prmps, tps, vps, wps]
290
-
291
- # Convert per frame counts to totals
292
- (4..7).each { |i| stat[i] *= frames }
293
-
294
- # Update running totals
295
- (2..7).each { |i| $total[i] += stat[i] }
296
-
297
- # Update running maximums
298
- (2..13).each do |i|
299
- $max[i] = stat[i] if $max[i] < stat[i]
300
- end
301
-
302
- $stats_fixed << stat
303
- end
304
-
305
- # Calc averages for totals line
306
- (8..13).each { |i| $total[i] = $total[i-5] / $total[2].to_f }
307
-
308
- $ready = true
309
- $stats = $stats_fixed
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
- basic = ["Name","Cnt","Time"]
315
- raw = ["Frms","Mpix","Kprim","Ktri","Kvert"]
316
- calc = raw
317
- scale = [ 0, 6, 3, 3, 3, ] * 2
318
- header = basic + raw + calc
319
- scale.map! {|n| 10 ** n }
320
-
321
- g_form = "%9s%-*s %s\n"
322
- h_form = '%-5s%3s %6s' + ' %5s' * raw.size + ' ' + ' %5s' * calc.size + "\n"
323
- format = '%-5s%3s %6.3f' + ' %5d' * raw.size + ' ' + ' %5d' * calc.size + "\n"
324
-
325
- printf(g_form, '', 6 * 5 + 8, 'MEASURED', 'PER SECOND')
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
- ($stats + [$total]).each do |stat|
331
- st = stat.clone()
332
- (0..scale.size-1).each do |i|
333
- st[i + 3] /= scale[i]
334
- end
335
- printf(format,*st)
336
- end
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
- data = []
342
- (0 .. count-1).each do |y|
343
- (0 .. count-1).each do |x|
344
- data << x * size << y * size + size
345
- data << x * size << y * size
346
- data << x * size + size << y * size
347
- data << x * size + size << y * size + size
348
- end
349
- end
350
- data
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
- data = []
355
- (0 .. count-1).each do |y|
356
- (0 .. count-1).each do |x|
357
- data << x * size << y * size + size
358
- data << x * size << y * size
359
- data << x * size + size << y * size + size
360
-
361
- data << x * size + size << y * size + size
362
- data << x * size << y * size
363
- data << x * size + size << y * size
364
- end
365
- end
366
- data
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
- data = []
371
- (0 .. count-1).each do |y|
372
- (0 .. count).each do |x|
373
- data << x * size << y * size + size
374
- data << x * size << y * size
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
- end
377
- data
378
+ end
379
+ data
378
380
  end
379
381
 
380
382
  def make_ts_va(count,size)
381
- data = []
382
- (0 .. count-1).each do |y|
383
- (0 .. count).each do |x|
384
- data << x * size << y * size + size
385
- data << x * size << y * size
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
- end
388
- data
389
+ end
390
+ data
389
391
  end
390
392
 
391
393
  def draw_qs(count,size)
392
- (0 .. count-1).each do |y|
393
- glBegin(GL_QUAD_STRIP)
394
- (0 .. count).each do |x|
395
- glVertex2f(x * size, y * size + size)
396
- glVertex2f(x * size, y * size )
397
- end
398
- glEnd()
399
- end
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
- (0 .. count-1).each do |y|
404
- glBegin(GL_TRIANGLE_STRIP)
405
- (0 .. count).each do |x|
406
- glVertex2f(x * size, y * size + size)
407
- glVertex2f(x * size, y * size )
408
- end
409
- glEnd()
410
- end
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
- va = $vas["qs_#{count}"]
415
- row = 2 * (count + 1)
416
+ va = $vas["qs_#{count}"]
417
+ row = 2 * (count + 1)
416
418
 
417
- glEnableClientState(GL_VERTEX_ARRAY)
418
- glVertexPointer(2, GL_FLOAT, 0, va)
419
- (0 .. count-1).each do |y|
420
- glDrawArrays(GL_QUAD_STRIP, y * row, row)
421
- end
422
- glDisableClientState(GL_VERTEX_ARRAY)
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
- va = $vas["ts_#{count}"]
427
- row = 2 * (count + 1)
428
+ va = $vas["ts_#{count}"]
429
+ row = 2 * (count + 1)
428
430
 
429
- glEnableClientState(GL_VERTEX_ARRAY)
430
- glVertexPointer(2, GL_FLOAT, 0, va)
431
- (0 .. count-1).each do |y|
432
- glDrawArrays(GL_TRIANGLE_STRIP, y * row, row)
433
- end
434
- glDisableClientState(GL_VERTEX_ARRAY)
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
- glBegin(GL_TRIANGLES)
439
- (0 .. count-1).each do |y|
440
- (0 .. count-1).each do |x|
441
- glVertex2f(x * size , y * size + size)
442
- glVertex2f(x * size , y * size )
443
- glVertex2f(x * size + size, y * size + size)
444
-
445
- glVertex2f(x * size + size, y * size + size)
446
- glVertex2f(x * size , y * size )
447
- glVertex2f(x * size + size, y * size )
448
- end
449
- end
450
- glEnd
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
- length = size * count
455
- area = length * length
456
- prims = 2 * count * count
457
- tris = prims
458
- verts = 3 * prims
459
-
460
- [area, prims, tris, verts]
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
- glBegin(GL_QUADS)
472
- (0 .. count-1).each do |y|
473
- (0 .. count-1).each do |x|
474
- glVertex2f(x * size , y * size + size)
475
- glVertex2f(x * size , y * size )
476
- glVertex2f(x * size + size, y * size )
477
- glVertex2f(x * size + size, y * size + size)
478
- end
479
- end
480
- glEnd
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
- length = size * count
485
- area = length * length
486
- prims = count * count
487
- tris = 2 * prims
488
- verts = 4 * prims
486
+ length = size * count
487
+ area = length * length
488
+ prims = count * count
489
+ tris = 2 * prims
490
+ verts = 4 * prims
489
491
 
490
- [area, prims, tris, verts]
492
+ [area, prims, tris, verts]
491
493
  end
492
494
 
493
495
  def stats_ts(count,size)
494
- length = size * count
495
- area = length * length
496
- prims = count
497
- tris = 2 * count * prims
498
- verts = 2 * (count + 1) * prims
499
-
500
- [area, prims, tris, verts]
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
- length = size * count
505
- area = length * length
506
- prims = count
507
- tris = 2 * count * prims
508
- verts = 2 * (count + 1) * prims
509
-
510
- [area, prims, tris, verts]
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
- glCallList($dls["ts_#{count}"]);
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
- va = $vas["t_#{count}"]
523
-
524
- glVertexPointer(2, GL_FLOAT, 0, va)
525
-
526
- glEnableClientState(GL_VERTEX_ARRAY)
527
- glDrawArrays(GL_TRIANGLES, 0, 6 * count * count)
528
- glDisableClientState(GL_VERTEX_ARRAY)
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
- va = $vas["q_#{count}"]
533
-
534
- glVertexPointer(2, GL_FLOAT, 0, va)
535
-
536
- glEnableClientState(GL_VERTEX_ARRAY)
537
- glDrawArrays(GL_QUADS, 0, 4 * count * count)
538
- glDisableClientState(GL_VERTEX_ARRAY)
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
- va = $vas["ts_#{count}"]
544
-
545
- glVertexPointer(2, GL_FLOAT, 0, va)
546
-
547
- glEnableClientState(GL_VERTEX_ARRAY)
548
- glCallList($dls["tsv_#{count}"])
549
- glDisableClientState(GL_VERTEX_ARRAY)
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
- va = $vas["qs_#{count}"]
554
-
555
- glVertexPointer(2, GL_FLOAT, 0, va)
556
-
557
- glEnableClientState(GL_VERTEX_ARRAY)
558
- glCallList($dls["qsv_#{count}"])
559
- glDisableClientState(GL_VERTEX_ARRAY)
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
- return if (!$ready)
565
-
566
- # Graph config
567
- x_off = 10
568
- y_off = 10
569
- tick_size = 3
570
- val_space = 50
571
- key_size = 20
572
- x_scale = ($w - 4 * x_off) / (2 * ($fast.last || $slow.last))
573
- key_scale = ($h - 4 * y_off) / (2 * $tests.size)
574
-
575
- # Get a fresh black frame for graphing
576
- glClearColor(0, 0, 0, 1)
577
- start_frame()
578
-
579
- # Use antialiased lines
580
- glEnable(GL_BLEND)
581
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
582
- glEnable(GL_LINE_SMOOTH)
583
- glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
584
-
585
- # Draw axis ticks
586
- glColor3f(1, 1, 1);
587
- glBegin(GL_LINES);
588
-
589
- ([0] + $slow + $fast).each do |count|
590
- x_tick = count * x_scale + x_off
591
- glVertex2f(x_tick, y_off)
592
- glVertex2f(x_tick, y_off - tick_size)
593
- glVertex2f(x_tick, y_off + $h / 2)
594
- glVertex2f(x_tick, y_off + $h / 2 - tick_size)
595
- glVertex2f(x_tick + $w / 2, y_off + $h / 2)
596
- glVertex2f(x_tick + $w / 2, y_off + $h / 2 - tick_size)
597
- end
598
- glEnd
599
-
600
- x_tick = x_off + 3
601
- val_max = (($h / 2 - 2 * y_off) / val_space).to_i
602
-
603
- # Work
604
- (0..val_max).each do |value|
605
- y_tick = value * val_space + y_off
606
-
607
- glBegin(GL_LINES)
608
- glVertex2f(x_off, y_tick)
609
- glVertex2f(x_off - tick_size, y_tick)
610
- glEnd
611
- end
612
-
613
- # Pixels
614
- value = 0
615
- val_max = $max[9] / mag_scale($max[9])
616
- y_scale = ($h - 4 * y_off) / (2 * val_max)
617
- val_inc = tick_inc(val_max,5)
618
-
619
- while (value < val_max)
620
- y_tick = (value * y_scale) + y_off
621
-
622
- glBegin(GL_LINES)
623
- glVertex2f(x_off, y_tick + $h / 2)
624
- glVertex2f(x_off - tick_size, y_tick + $h / 2)
625
- glEnd
626
- OGLBench.draw_string($font_style, value.to_s, x_tick, y_tick + $h / 2) if (value!=0)
627
- value += val_inc
628
- end
629
-
630
- # Vertices
631
- value = 0
632
- val_max = $max[12] / mag_scale($max[12])
633
- y_scale = ($h - 4 * y_off) / (2 * val_max)
634
- val_inc = tick_inc(val_max,5)
635
- while (value < val_max)
636
- y_tick = (value * y_scale) + y_off
637
-
638
- glBegin(GL_LINES)
639
- glVertex2f(x_off + $w / 2, y_tick + $h / 2)
640
- glVertex2f(x_off + $w / 2 - tick_size, y_tick + $h / 2)
641
- glEnd
642
-
643
- OGLBench.draw_string($font_style, value.to_s, x_tick + $w / 2, y_tick + $h / 2) if (value!=0)
644
- value += val_inc
645
- end
646
-
647
- # Draw axes
648
- glBegin(GL_LINE_STRIP)
649
- glVertex2f(x_off, $h / 2 - y_off)
650
- glVertex2f(x_off, y_off)
651
- glVertex2f($w / 2 - x_off, y_off)
652
- glEnd
653
- glBegin(GL_LINE_STRIP)
654
- glVertex2f(x_off, $h - y_off)
655
- glVertex2f(x_off, $h / 2 + y_off)
656
- glVertex2f($w / 2 - x_off, $h / 2 + y_off)
657
- glEnd
658
- glBegin(GL_LINE_STRIP)
659
- glVertex2f($w / 2 + x_off, $h - y_off)
660
- glVertex2f($w / 2 + x_off, $h / 2 + y_off)
661
- glVertex2f($w - x_off, $h / 2 + y_off)
662
- glEnd
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
- (0..$tests.size - 1).each do |num|
666
- test = $tests[num]
667
- name,color,stipple = [test[0]] + test[-2,2]
668
- glEnable(GL_LINE_STIPPLE)
669
- glLineStipple(3, stipple)
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
- glBegin(GL_LINES)
672
- glColor3fv(color)
673
- glVertex2f(x_off + $w / 2, y_off + num * key_scale)
674
- glVertex2f(x_off + $w / 2 + key_size, y_off + num * key_scale)
675
- glEnd()
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
- glDisable(GL_LINE_STIPPLE)
679
+ glDisable(GL_LINE_STIPPLE)
678
680
 
679
- OGLBench.draw_string($font_style, name, x_off + $w / 2 + key_size * 2, y_off + num * key_scale)
680
- end
681
+ OGLBench.draw_string($font_style, name, x_off + $w / 2 + key_size * 2, y_off + num * key_scale)
682
+ end
681
683
 
682
- # Draw performance graph lines
684
+ # Draw performance graph lines
683
685
 
684
- # Pixels per second
685
- draw_one_stat(x_off, y_off + $h / 2, y_off, x_scale, 9)
686
- glColor3f(1, 1, 1)
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
- OGLBench.draw_string($font_style, mag_char($max[9]) + " Pixels/Sec", $w / 4, $h - 2 * y_off)
690
+ OGLBench.draw_string($font_style, mag_char($max[9]) + " Pixels/Sec", $w / 4, $h - 2 * y_off)
689
691
 
690
- # Vertices per second
691
- draw_one_stat(x_off + $w / 2, y_off + $h / 2, y_off, x_scale, 12)
692
- glColor3f(1, 1, 1)
693
- OGLBench.draw_string($font_style, mag_char($max[12]) + " Vertices/Sec", 3 * $w / 4, $h - 2 * y_off)
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
- # "Work" per second, the geometric mean of pixels and vertices
696
- draw_one_stat(x_off, y_off, y_off, x_scale, 13)
697
- glColor3f(1, 1, 1)
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
- OGLBench.draw_string($font_style, "Work/Sec", $w / 4, $h / 2 - 2 * y_off)
701
+ OGLBench.draw_string($font_style, "Work/Sec", $w / 4, $h / 2 - 2 * y_off)
700
702
 
701
- # Show our graph
702
- end_frame();
703
- $showing_graph = true
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
- max = $max[num]
708
- y_scale = ($h - 4 * y_off) / (2 * max)
709
- colors = {}
710
- $tests.each do |test| colors[test[0]] = test[-2] end
711
-
712
- stipple = {}
713
- $tests.each do |test| stipple[test[0]] = test[-1] end
714
-
715
- last = ''
716
-
717
- glEnable(GL_LINE_STIPPLE)
718
- glBegin(GL_LINE_STRIP)
719
- $stats.each_with_index do |stat,run|
720
- name,count, st = stat[0,2] + [stat[num]]
721
-
722
- if name != last
723
- glEnd
724
- glLineStipple(3, stipple[name])
725
- glBegin(GL_LINE_STRIP)
726
- last = name
727
- end
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
- glColor3fv(colors[name])
730
- glVertex2f(count * x_scale + x_loc, st * y_scale + y_loc)
731
- end
732
- glEnd
733
- glDisable(GL_LINE_STIPPLE)
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
- mag = (Math::log(num) / Math::log(10)).to_i
739
- (mag / 3)
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
- ['','K','M','G','T','P','E','Z','Y'][kilo_mag(num)]
745
+ ['','K','M','G','T','P','E','Z','Y'][kilo_mag(num)]
744
746
  end
745
747
 
746
748
  def mag_scale(num)
747
- 10 ** (3*kilo_mag(num))
749
+ 10 ** (3*kilo_mag(num))
748
750
  end
749
751
 
750
752
  def tick_inc(max,parts = 5)
751
- return (max / parts.to_f) if (max < 1)
752
-
753
- mag = (Math::log(max) / Math::log(10)).to_i
754
- scl = (10 ** (mag - 1))
755
- inc = max / (scl * parts)
756
-
757
- if (inc > 7.5)
758
- inc = 10
759
- elsif (inc > 3.5)
760
- inc = 5
761
- elsif (inc > 1.5)
762
- inc = 2
763
- else
764
- inc = 1
765
- end
766
- (inc * scl.to_f)
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
- if (!$done)
772
- benchmark()
773
- elsif (!$ready)
774
- cleanup()
775
- else
776
- sleep(1)
777
- draw_stats()
778
- end
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
- glutDestroyWindow($app)
785
- exit(0)
786
- end
787
- if ($done && key == ?r)
788
- draw_stats()
789
- end
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
- "q" => method(:make_quads_va),
797
- "t" => method(:make_tris_va),
798
- "qs" => method(:make_qs_va),
799
- "ts" => method(:make_ts_va),
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
- "qs" => method(:draw_qs),
805
+ "qs" => method(:draw_qs),
804
806
  "ts" => method(:draw_ts),
805
807
  "qsv" => method(:draw_qs_va),
806
- "tsv" => method(:draw_ts_va),
808
+ "tsv" => method(:draw_ts_va),
807
809
  }
808
810
 
809
811
  $tests = [
810
- # Nick Draw Routine Stats Calc Type Graph Color
811
- # ["empty",method(:draw_empty), method(:stats_empty),'single',[1 , 1, 1], 0xFFFF],
812
- ["t" ,method(:draw_tris), method(:stats_tris) ,'slow', [1 , 0, 0], 0xAAAA],
813
- ["q" ,method(:draw_quads), method(:stats_quads),'slow', [1 ,0.5, 0], 0xAAAA],
814
- ["ts" ,method(:draw_ts), method(:stats_ts), 'slow', [1 , 1, 0], 0xAAAA],
815
- ["qs" ,method(:draw_qs), method(:stats_qs), 'slow', [0 , 1, 0], 0xAAAA],
816
- ["tsd" ,method(:draw_ts_dl), method(:stats_ts), 'fast', [0 , 1, 1], 0xAAAA],
817
- ["qsd" ,method(:draw_qs_dl), method(:stats_qs), 'fast', [0 , 0, 1], 0xAAAA],
818
- ["tv" ,method(:draw_tris_va), method(:stats_tris), 'fast', [0.8, 0, 0], 0xFFFF],
819
- ["qv" ,method(:draw_quads_va),method(:stats_quads),'fast', [0.8,0.4, 0], 0xFFFF],
820
- ["tsv" ,method(:draw_ts_va), method(:stats_ts), 'fast', [0.8,0.8, 0], 0xFFFF],
821
- ["qsv" ,method(:draw_qs_va), method(:stats_qs), 'fast', [0 ,0.8, 0], 0xFFFF],
822
- ["tsvd" ,method(:draw_ts_va_dl),method(:stats_ts), 'fast', [0 ,0.8,0.8], 0xFFFF],
823
- ["qsvd" ,method(:draw_qs_va_dl),method(:stats_qs), 'fast', [0 , 0,0.8], 0xFFFF],
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
-