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.
Files changed (118) hide show
  1. data/Rakefile +15 -11
  2. data/doc/build_install.txt +10 -6
  3. data/doc/extensions.txt.in +348 -0
  4. data/doc/history.txt +4 -0
  5. data/doc/roadmap.txt +4 -6
  6. data/doc/scientific_use.txt +7 -0
  7. data/doc/supplies/page_template.html +2 -1
  8. data/doc/thanks.txt +5 -0
  9. data/doc/tutorial.txt +431 -121
  10. data/examples/NeHe/nehe_lesson02.rb +1 -1
  11. data/examples/NeHe/nehe_lesson03.rb +1 -1
  12. data/examples/NeHe/nehe_lesson04.rb +1 -1
  13. data/examples/NeHe/nehe_lesson05.rb +1 -1
  14. data/examples/NeHe/nehe_lesson36.rb +1 -1
  15. data/examples/OrangeBook/brick.rb +3 -15
  16. data/examples/OrangeBook/particle.rb +2 -20
  17. data/examples/RedBook/aapoly.rb +1 -1
  18. data/examples/RedBook/aargb.rb +2 -2
  19. data/examples/RedBook/accanti.rb +1 -1
  20. data/examples/RedBook/accpersp.rb +1 -1
  21. data/examples/RedBook/alpha.rb +2 -2
  22. data/examples/RedBook/alpha3D.rb +1 -1
  23. data/examples/RedBook/bezcurve.rb +1 -1
  24. data/examples/RedBook/bezmesh.rb +1 -1
  25. data/examples/RedBook/checker.rb +1 -1
  26. data/examples/RedBook/clip.rb +1 -1
  27. data/examples/RedBook/colormat.rb +1 -1
  28. data/examples/RedBook/cube.rb +1 -1
  29. data/examples/RedBook/depthcue.rb +1 -1
  30. data/examples/RedBook/dof.rb +1 -1
  31. data/examples/RedBook/double.rb +1 -1
  32. data/examples/RedBook/drawf.rb +1 -1
  33. data/examples/RedBook/feedback.rb +1 -1
  34. data/examples/RedBook/fog.rb +1 -1
  35. data/examples/RedBook/font.rb +2 -2
  36. data/examples/RedBook/hello.rb +1 -1
  37. data/examples/RedBook/image.rb +4 -4
  38. data/examples/RedBook/lines.rb +1 -1
  39. data/examples/RedBook/list.rb +1 -1
  40. data/examples/RedBook/material.rb +1 -1
  41. data/examples/RedBook/mipmap.rb +1 -1
  42. data/examples/RedBook/model.rb +1 -1
  43. data/examples/RedBook/movelight.rb +1 -1
  44. data/examples/RedBook/pickdepth.rb +1 -1
  45. data/examples/RedBook/planet.rb +5 -5
  46. data/examples/RedBook/quadric.rb +1 -1
  47. data/examples/RedBook/robot.rb +5 -5
  48. data/examples/RedBook/select.rb +1 -1
  49. data/examples/RedBook/smooth.rb +1 -1
  50. data/examples/RedBook/stencil.rb +1 -1
  51. data/examples/RedBook/stroke.rb +2 -2
  52. data/examples/RedBook/surface.rb +1 -1
  53. data/examples/RedBook/teaambient.rb +1 -1
  54. data/examples/RedBook/teapots.rb +1 -1
  55. data/examples/RedBook/tess.rb +1 -1
  56. data/examples/RedBook/texbind.rb +1 -1
  57. data/examples/RedBook/texgen.rb +5 -5
  58. data/examples/RedBook/texturesurf.rb +1 -1
  59. data/examples/RedBook/varray.rb +1 -1
  60. data/examples/RedBook/wrap.rb +5 -5
  61. data/examples/misc/OGLBench.rb +337 -0
  62. data/examples/misc/anisotropic.rb +1 -1
  63. data/examples/misc/fbo_test.rb +356 -0
  64. data/examples/misc/font-glut.rb +1 -1
  65. data/examples/misc/glfwtest.rb +30 -0
  66. data/examples/misc/md2model.rb +15 -0
  67. data/examples/misc/plane.rb +1 -1
  68. data/examples/misc/readpixel.rb +1 -1
  69. data/examples/misc/sdltest.rb +34 -0
  70. data/examples/misc/trislam.rb +828 -0
  71. data/ext/common/common.h +126 -218
  72. data/ext/common/conv.h +244 -0
  73. data/ext/common/funcdef.h +280 -0
  74. data/ext/common/gl-error.h +23 -0
  75. data/ext/common/gl-types.h +14 -0
  76. data/ext/gl/gl-1.0-1.1.c +497 -1255
  77. data/ext/gl/gl-1.2.c +121 -304
  78. data/ext/gl/gl-1.3.c +78 -339
  79. data/ext/gl/gl-1.4.c +102 -164
  80. data/ext/gl/gl-1.5.c +42 -173
  81. data/ext/gl/gl-2.0.c +273 -1039
  82. data/ext/gl/gl-2.1.c +15 -19
  83. data/ext/gl/gl-enums.c +3 -2
  84. data/ext/gl/gl-error.c +104 -0
  85. data/ext/gl/gl-ext-3dfx.c +27 -0
  86. data/ext/gl/gl-ext-arb.c +812 -12
  87. data/ext/gl/gl-ext-ati.c +41 -0
  88. data/ext/gl/gl-ext-ext.c +791 -119
  89. data/ext/gl/gl-ext-gremedy.c +41 -0
  90. data/ext/gl/gl-ext-nv.c +679 -0
  91. data/ext/gl/gl.c +48 -28
  92. data/ext/gl/mkrf_conf.rb +13 -10
  93. data/ext/glu/glu-enums.c +3 -2
  94. data/ext/glu/glu.c +136 -41
  95. data/ext/glu/mkrf_conf.rb +15 -12
  96. data/ext/glut/glut.c +37 -80
  97. data/ext/glut/mkrf_conf.rb +17 -13
  98. data/lib/opengl.rb +29 -53
  99. data/test/tc_common.rb +9 -3
  100. data/test/tc_ext_arb.rb +397 -3
  101. data/test/tc_ext_ati.rb +33 -0
  102. data/test/tc_ext_ext.rb +479 -2
  103. data/test/tc_ext_gremedy.rb +36 -0
  104. data/test/tc_ext_nv.rb +357 -0
  105. data/test/tc_func_10_11.rb +93 -67
  106. data/test/tc_func_12.rb +11 -11
  107. data/test/tc_func_13.rb +38 -18
  108. data/test/tc_func_14.rb +2 -2
  109. data/test/tc_func_15.rb +10 -10
  110. data/test/tc_func_20.rb +20 -20
  111. data/test/tc_func_21.rb +53 -22
  112. data/test/tc_glu.rb +9 -4
  113. data/test/tc_misc.rb +15 -2
  114. metadata +22 -8
  115. data/doc/extensions.txt +0 -361
  116. data/examples/RedBook/aaindex.rb +0 -97
  117. data/examples/misc/smooth.rb +0 -42
  118. data/examples/misc/test.rb +0 -65
@@ -91,7 +91,7 @@ end
91
91
 
92
92
  keyboard = Proc.new do |key, x, y|
93
93
  case (key)
94
- when 27
94
+ when ?\e
95
95
  exit(0)
96
96
  end
97
97
  end
@@ -254,7 +254,7 @@ end
254
254
 
255
255
  keyboard = Proc.new do |key, x, y|
256
256
  case (key)
257
- when 27
257
+ when ?\e
258
258
  exit(0);
259
259
  end
260
260
  end
@@ -139,7 +139,7 @@ end
139
139
 
140
140
  keyboard = Proc.new do |key, x, y|
141
141
  case (key)
142
- when 27
142
+ when ?\e
143
143
  exit(0);
144
144
  end
145
145
  end
@@ -95,7 +95,7 @@ end
95
95
 
96
96
  keyboard = Proc.new do |key, x, y|
97
97
  case key
98
- when 27
98
+ when ?\e
99
99
  exit(0)
100
100
  end
101
101
  end
@@ -113,7 +113,7 @@ end
113
113
 
114
114
  keyboard = Proc.new do |key, x, y|
115
115
  case key
116
- when 27
116
+ when ?\e
117
117
  exit(0)
118
118
  end
119
119
  end
@@ -158,7 +158,7 @@ end
158
158
 
159
159
  keyboard = Proc.new do |key, x, y|
160
160
  case (key)
161
- when 27
161
+ when ?\e
162
162
  exit(0)
163
163
  end
164
164
  end
@@ -79,19 +79,19 @@ end
79
79
 
80
80
  keyboard = Proc.new do |key, x, y|
81
81
  case (key)
82
- when 'd'[0]
82
+ when ?d
83
83
  $day = ($day + 10) % 360
84
84
  glutPostRedisplay()
85
- when 'D'[0]
85
+ when ?D
86
86
  $day = ($day - 10) % 360
87
87
  glutPostRedisplay()
88
- when 'y'[0]
88
+ when ?y
89
89
  $year = ($year + 5) % 360
90
90
  glutPostRedisplay()
91
- when 'Y'[0]
91
+ when ?Y
92
92
  $year = ($year - 5) % 360
93
93
  glutPostRedisplay()
94
- when 27
94
+ when ?\e
95
95
  exit(0)
96
96
  end
97
97
  end
@@ -140,7 +140,7 @@ end
140
140
 
141
141
  keyboard = Proc.new do |key, x, y|
142
142
  case (key)
143
- when 27
143
+ when ?\e
144
144
  exit(0)
145
145
  end
146
146
  end
@@ -86,19 +86,19 @@ end
86
86
 
87
87
  keyboard = Proc.new do|key, x, y|
88
88
  case (key)
89
- when 's'[0]
89
+ when ?s
90
90
  $shoulder = ($shoulder + 5) % 360
91
91
  glutPostRedisplay()
92
- when 'S'[0]
92
+ when ?S
93
93
  $shoulder = ($shoulder - 5) % 360
94
94
  glutPostRedisplay()
95
- when 'e'[0]
95
+ when ?e
96
96
  $elbow = ($elbow + 5) % 360
97
97
  glutPostRedisplay()
98
- when 'E'[0]
98
+ when ?E
99
99
  $elbow = ($elbow - 5) % 360
100
100
  glutPostRedisplay()
101
- when 27
101
+ when ?\e
102
102
  exit(0)
103
103
  end
104
104
  end
@@ -178,7 +178,7 @@ end
178
178
 
179
179
  keyboard = proc do |key, x, y|
180
180
  case (key)
181
- when 27
181
+ when ?\e
182
182
  exit(0)
183
183
  end
184
184
  end
@@ -78,7 +78,7 @@ end
78
78
 
79
79
  keyboard = lambda do |key, x, y|
80
80
  case(key)
81
- when 27
81
+ when ?\e
82
82
  exit(0)
83
83
  end
84
84
  end
@@ -143,7 +143,7 @@ end
143
143
 
144
144
  keyboard = Proc.new do |key, x, y|
145
145
  case (key)
146
- when 27
146
+ when ?\e
147
147
  exit(0);
148
148
  end
149
149
  end
@@ -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( s)
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 27
150
+ when ?\e
151
151
  exit(0);
152
152
  end
153
153
  end
@@ -145,7 +145,7 @@ end
145
145
 
146
146
  keyboard = Proc.new do |key, x, y|
147
147
  case (key)
148
- when 27
148
+ when ?\e
149
149
  exit(0);
150
150
  end
151
151
  end
@@ -112,7 +112,7 @@ end
112
112
 
113
113
  keyboard = Proc.new do |key, x, y|
114
114
  case (key)
115
- when 27
115
+ when ?\e
116
116
  exit(0);
117
117
  end
118
118
  end
@@ -163,7 +163,7 @@ end
163
163
 
164
164
  keyboard = Proc.new do |key, x, y|
165
165
  case (key)
166
- when 27
166
+ when ?\e
167
167
  exit(0);
168
168
  end
169
169
  end
@@ -166,7 +166,7 @@ end
166
166
 
167
167
  keyboard = proc do |key, x, y|
168
168
  case (key)
169
- when 27
169
+ when ?\e
170
170
  exit(0)
171
171
  end
172
172
  end
@@ -129,7 +129,7 @@ end
129
129
 
130
130
  keyboard = Proc.new do |key, x, y|
131
131
  case (key)
132
- when 27
132
+ when ?\e
133
133
  exit(0)
134
134
  end
135
135
  end
@@ -131,27 +131,27 @@ end
131
131
 
132
132
  keyboard = Proc.new do |key, x, y|
133
133
  case (key)
134
- when 'e'[0],'E'[0]
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 'o'[0], 'O'[0]
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 's'[0],'S'[0]
146
+ when ?s,?S
147
147
  $currentCoeff = $slanted
148
148
  glTexGen(GL_S, $currentPlane, $currentCoeff)
149
149
  glutPostRedisplay()
150
- when 'x'[0],'X'[0]
150
+ when ?x,?X
151
151
  $currentCoeff = $xequalzero
152
152
  glTexGen(GL_S, $currentPlane, $currentCoeff)
153
153
  glutPostRedisplay()
154
- when 27
154
+ when ?\e
155
155
  exit(0)
156
156
  end
157
157
  end
@@ -111,7 +111,7 @@ end
111
111
 
112
112
  keyboard = Proc.new do |key, x, y|
113
113
  case (key)
114
- when 27
114
+ when ?\e
115
115
  exit(0);
116
116
  end
117
117
  end
@@ -141,7 +141,7 @@ end
141
141
 
142
142
  keyboard = proc do |key, x, y|
143
143
  case (key)
144
- when 27
144
+ when ?\e
145
145
  exit(0)
146
146
  end
147
147
  end
@@ -119,19 +119,19 @@ end
119
119
 
120
120
  keyboard = Proc.new do |key, x, y|
121
121
  case (key)
122
- when 's'[0]
122
+ when ?s
123
123
  glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
124
124
  glutPostRedisplay()
125
- when 'S'[0]
125
+ when ?S
126
126
  glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
127
127
  glutPostRedisplay()
128
- when 't'[0]
128
+ when ?t
129
129
  glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
130
130
  glutPostRedisplay()
131
- when 'T'[0]
131
+ when ?T
132
132
  glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
133
133
  glutPostRedisplay()
134
- when 27
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
+