opengl 0.7.0.pre1-x86-mingw32 → 0.7.0.pre2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/.autotest +29 -0
  2. data/.gitignore +5 -8
  3. data/History.rdoc +33 -0
  4. data/Manifest.txt +72 -57
  5. data/README.rdoc +72 -25
  6. data/Rakefile +60 -72
  7. data/Rakefile.cross +5 -2
  8. data/{doc → docs}/build_install.txt +0 -0
  9. data/{doc → docs}/extensions.txt.in +0 -0
  10. data/{doc → docs}/history.txt +0 -0
  11. data/{doc → docs}/requirements_and_design.txt +0 -0
  12. data/{doc → docs}/roadmap.txt +0 -0
  13. data/{doc → docs}/scientific_use.txt +0 -0
  14. data/{doc → docs}/supplies/page_template.html +0 -0
  15. data/{doc → docs}/thanks.txt +0 -0
  16. data/{doc → docs}/tutorial.txt +0 -0
  17. data/examples/NeHe/NeHe.png +0 -0
  18. data/examples/NeHe/crate.png +0 -0
  19. data/examples/NeHe/glass.png +0 -0
  20. data/examples/NeHe/nehe_lesson02.rb +82 -83
  21. data/examples/NeHe/nehe_lesson03.rb +88 -88
  22. data/examples/NeHe/nehe_lesson04.rb +93 -96
  23. data/examples/NeHe/nehe_lesson05.rb +137 -144
  24. data/examples/NeHe/nehe_lesson06.rb +183 -0
  25. data/examples/NeHe/nehe_lesson07.rb +237 -0
  26. data/examples/NeHe/nehe_lesson08.rb +252 -0
  27. data/examples/NeHe/nehe_lesson09.rb +199 -0
  28. data/examples/NeHe/nehe_lesson11.rb +173 -0
  29. data/examples/NeHe/nehe_lesson12.rb +200 -0
  30. data/examples/NeHe/nehe_lesson16.rb +208 -0
  31. data/examples/NeHe/nehe_lesson19.rb +206 -0
  32. data/examples/NeHe/particle.png +0 -0
  33. data/examples/NeHe/star.png +0 -0
  34. data/examples/NeHe/tim.png +0 -0
  35. data/examples/RedBook/light.rb +154 -0
  36. data/examples/misc/OGLBench.rb +2 -2
  37. data/examples/misc/trislam.rb +2 -2
  38. data/ext/{common → opengl}/common.h +2 -11
  39. data/ext/{common → opengl}/conv.h +43 -31
  40. data/ext/{glut → opengl}/extconf.rb +14 -7
  41. data/ext/{common → opengl}/funcdef.h +155 -125
  42. data/ext/{gl → opengl}/gl-1.0-1.1.c +426 -162
  43. data/ext/{gl → opengl}/gl-1.2.c +70 -66
  44. data/ext/{gl → opengl}/gl-1.3.c +19 -19
  45. data/ext/{gl → opengl}/gl-1.4.c +23 -23
  46. data/ext/{gl → opengl}/gl-1.5.c +46 -47
  47. data/ext/{gl → opengl}/gl-2.0.c +66 -60
  48. data/ext/{gl → opengl}/gl-2.1.c +4 -4
  49. data/ext/{gl → opengl}/gl-enums.c +2 -1
  50. data/ext/{common → opengl}/gl-enums.h +0 -0
  51. data/ext/{gl → opengl}/gl-error.c +12 -4
  52. data/ext/{common → opengl}/gl-error.h +7 -2
  53. data/ext/{gl → opengl}/gl-ext-3dfx.c +1 -1
  54. data/ext/{gl → opengl}/gl-ext-arb.c +75 -70
  55. data/ext/{gl → opengl}/gl-ext-ati.c +3 -3
  56. data/ext/{gl → opengl}/gl-ext-ext.c +54 -54
  57. data/ext/{gl → opengl}/gl-ext-gremedy.c +3 -3
  58. data/ext/{gl → opengl}/gl-ext-nv.c +49 -48
  59. data/ext/{common → opengl}/gl-types.h +0 -0
  60. data/ext/{gl → opengl}/gl.c +8 -10
  61. data/ext/{glu → opengl}/glu-enums.c +1 -1
  62. data/ext/{common → opengl}/glu-enums.h +0 -0
  63. data/ext/{glu → opengl}/glu.c +7 -3
  64. data/ext/{glut → opengl}/glut.c +98 -48
  65. data/ext/opengl/opengl.c +11 -0
  66. data/lib/gl.rb +1 -0
  67. data/lib/glu.rb +1 -0
  68. data/lib/glut.rb +1 -0
  69. data/lib/opengl.rb +13 -14
  70. data/lib/opengl/opengl.so +0 -0
  71. data/lib/opengl/test_case.rb +87 -0
  72. data/test/{tc_misc.rb → test_gl.rb} +2 -14
  73. data/test/test_gl_10_11.rb +1363 -0
  74. data/test/test_gl_12.rb +182 -0
  75. data/test/{tc_func_13.rb → test_gl_13.rb} +14 -14
  76. data/test/test_gl_14.rb +221 -0
  77. data/test/test_gl_15.rb +260 -0
  78. data/test/test_gl_20.rb +430 -0
  79. data/test/test_gl_21.rb +553 -0
  80. data/test/test_gl_ext_arb.rb +526 -0
  81. data/test/{tc_ext_ati.rb → test_gl_ext_ati.rb} +11 -14
  82. data/test/test_gl_ext_ext.rb +608 -0
  83. data/test/{tc_ext_gremedy.rb → test_gl_ext_gremedy.rb} +6 -6
  84. data/test/test_gl_ext_nv.rb +352 -0
  85. data/test/test_glu.rb +309 -0
  86. metadata +159 -102
  87. data/History.txt +0 -36
  88. data/ext/gl/extconf.rb +0 -43
  89. data/ext/glu/extconf.rb +0 -51
  90. data/test/README +0 -10
  91. data/test/tc_common.rb +0 -98
  92. data/test/tc_ext_arb.rb +0 -467
  93. data/test/tc_ext_ext.rb +0 -551
  94. data/test/tc_ext_nv.rb +0 -357
  95. data/test/tc_func_10_11.rb +0 -1281
  96. data/test/tc_func_12.rb +0 -186
  97. data/test/tc_func_14.rb +0 -197
  98. data/test/tc_func_15.rb +0 -270
  99. data/test/tc_func_20.rb +0 -346
  100. data/test/tc_func_21.rb +0 -541
  101. data/test/tc_glu.rb +0 -310
  102. data/test/tc_include_gl.rb +0 -35
  103. data/test/tc_require_gl.rb +0 -34
Binary file
@@ -0,0 +1,87 @@
1
+ #
2
+ # Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
3
+ #
4
+ # This program is distributed under the terms of the MIT license.
5
+ # See the included MIT-LICENSE file for the terms of this license.
6
+ #
7
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
11
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ #
15
+
16
+ require 'rubygems'
17
+ begin
18
+ gem 'minitest'
19
+ rescue Gem::LoadError
20
+ end
21
+
22
+ require 'minitest/autorun'
23
+ require 'gl'
24
+ require 'glu'
25
+ require 'glut'
26
+ require 'matrix'
27
+
28
+ include Gl
29
+ include Glu
30
+ include Glut
31
+
32
+ Gl.enable_error_checking
33
+
34
+ module OpenGL; end
35
+
36
+ class OpenGL::TestCase < MiniTest::Unit::TestCase
37
+
38
+ WINDOW_SIZE = 512
39
+
40
+ glutInit
41
+ glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA | GLUT_STENCIL |
42
+ GLUT_ACCUM | GLUT_ALPHA)
43
+
44
+ def setup
45
+ glutInitWindowPosition 1, 1
46
+ glutInitWindowSize WINDOW_SIZE, WINDOW_SIZE
47
+ @window = glutCreateWindow "test"
48
+
49
+ glPushAttrib GL_ALL_ATTRIB_BITS
50
+ glPushClientAttrib GL_CLIENT_ALL_ATTRIB_BITS
51
+ glMatrixMode GL_MODELVIEW
52
+ glLoadIdentity
53
+ glMatrixMode GL_PROJECTION
54
+ glLoadIdentity
55
+
56
+ glClearColor 0, 0, 0, 0
57
+ glClear GL_COLOR_BUFFER_BIT
58
+ end
59
+
60
+ def teardown
61
+ glPopAttrib
62
+ glPopClientAttrib
63
+ glRenderMode GL_RENDER
64
+
65
+ # in case there is an GL error that escaped error checking routines ...
66
+ error = glGetError
67
+ assert_equal error, 0, gluErrorString(error)
68
+
69
+ glutDestroyWindow @window
70
+ end
71
+
72
+ def assert_each_in_delta expected, actual, epsilon = 0.01
73
+ assert_equal expected.length, actual.length, 'array lengths do not match'
74
+
75
+ expected.flatten.zip(actual.flatten).each_with_index do |(e, a), i|
76
+ assert_in_delta e, a, epsilon, "element #{i}"
77
+ end
78
+ end
79
+
80
+ def supported? funcs
81
+ Array(funcs).each do |name| # convert to array if it isn't already
82
+ skip "#{name} is not supported" unless Gl.is_available? name
83
+ end
84
+ end
85
+
86
+ end
87
+
@@ -13,25 +13,13 @@
13
13
  # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
14
  #
15
15
 
16
- if __FILE__ == $0
17
- # If we are being called from the command line, e.g., ruby foo.rb, then
18
- # fixup the load path so we can find the OpenGL extension libs
19
- $: << File.join(File.dirname(__FILE__), '..', 'lib')
20
- end
21
-
22
- require 'test/unit'
16
+ require 'opengl/test_case'
23
17
  require 'gl'
24
18
  require 'glut'
25
19
  include Gl
26
20
  include Glut
27
21
 
28
- class Test_misc < Test::Unit::TestCase
29
- def setup
30
- return if $glut_initialized
31
- glut_init()
32
- $glut_initialized = true
33
- end
34
-
22
+ class TestGl < OpenGL::TestCase
35
23
  def test_isavailable
36
24
  assert_equal(is_available?(1.1),true)
37
25
  assert_equal(is_available?("GL_ARB_multitexture"),true)
@@ -0,0 +1,1363 @@
1
+ #
2
+ # Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
3
+ #
4
+ # This program is distributed under the terms of the MIT license.
5
+ # See the included MIT-LICENSE file for the terms of this license.
6
+ #
7
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
11
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ #
15
+
16
+ require 'opengl/test_case'
17
+
18
+ class TestGl10_11 < OpenGL::TestCase
19
+ def test_glhint
20
+ glHint(GL_FOG_HINT,GL_NICEST)
21
+ assert_equal(glGetIntegerv(GL_FOG_HINT), GL_NICEST)
22
+ glHint(GL_FOG_HINT,GL_FASTEST)
23
+ assert_equal(glGetIntegerv(GL_FOG_HINT), GL_FASTEST)
24
+ end
25
+
26
+ def test_glindex
27
+ glIndexd(2.0)
28
+ assert_in_delta(glGetDoublev(GL_CURRENT_INDEX),2.0,0.001)
29
+ glIndexdv([3.0])
30
+ assert_in_delta(glGetDoublev(GL_CURRENT_INDEX),3.0,0.001)
31
+
32
+ glIndexf(4.0)
33
+ assert_in_delta(glGetFloatv(GL_CURRENT_INDEX),4.0,0.001)
34
+ glIndexfv([5.0])
35
+ assert_in_delta(glGetFloatv(GL_CURRENT_INDEX),5.0,0.001)
36
+
37
+ glIndexi(6)
38
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),6,0.001)
39
+ glIndexiv([7])
40
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),7,0.001)
41
+
42
+ glIndexs(8)
43
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),8,0.001)
44
+ glIndexsv([9])
45
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),9,0.001)
46
+
47
+ glIndexub(10)
48
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),10,0.001)
49
+ glIndexubv([11])
50
+ assert_in_delta(glGetIntegerv(GL_CURRENT_INDEX),11,0.001)
51
+
52
+ # index pointer
53
+ glIndexPointer(GL_INT,2,"")
54
+ assert_equal(glGetIntegerv(GL_INDEX_ARRAY_STRIDE),2)
55
+ assert_equal(glGetIntegerv(GL_INDEX_ARRAY_TYPE),GL_INT)
56
+ end
57
+
58
+ def test_glclear
59
+ glClearColor(1,0,1,0)
60
+ assert_equal(glGetDoublev(GL_COLOR_CLEAR_VALUE),[1,0,1,0])
61
+
62
+ glClearIndex(2)
63
+ assert_equal(glGetDoublev(GL_INDEX_CLEAR_VALUE),2)
64
+
65
+ glClearAccum(0.5,0.5,0.5,0.5)
66
+ assert_equal(glGetDoublev(GL_ACCUM_CLEAR_VALUE),[0.5,0.5,0.5,0.5])
67
+
68
+ glClearStencil(1)
69
+ assert_equal(glGetIntegerv(GL_STENCIL_CLEAR_VALUE),1)
70
+
71
+ glClearDepth(0.5)
72
+ assert_equal(glGetDoublev(GL_DEPTH_CLEAR_VALUE),0.5)
73
+ end
74
+
75
+ def test_glclientattrib
76
+ glPixelStorei(GL_PACK_ALIGNMENT,2)
77
+ glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT)
78
+ glPixelStorei(GL_PACK_ALIGNMENT,4)
79
+ assert_equal(glGetIntegerv(GL_PACK_ALIGNMENT),4)
80
+ glPopClientAttrib()
81
+ assert_equal(glGetIntegerv(GL_PACK_ALIGNMENT),2)
82
+ end
83
+
84
+ def test_matrix
85
+ m_a = [[2.0,0.0,0.0,0.0],
86
+ [0.0,2.0,0.0,0.0],
87
+ [0.0,0.0,2.0,0.0],
88
+ [0.0,0.0,0.0,2.0]]
89
+
90
+ m_b = [[3.0,0.0,0.0,0.0],
91
+ [0.0,3.0,0.0,0.0],
92
+ [0.0,0.0,3.0,0.0],
93
+ [0.0,0.0,0.0,3.0]]
94
+
95
+ m_ident = [[1.0,0.0,0.0,0.0],
96
+ [0.0,1.0,0.0,0.0],
97
+ [0.0,0.0,1.0,0.0],
98
+ [0.0,0.0,0.0,1.0]]
99
+
100
+ # 1
101
+ glMatrixMode(GL_MODELVIEW)
102
+ glLoadMatrixf(m_a)
103
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_a)
104
+ glLoadMatrixd(m_b)
105
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_b)
106
+
107
+ glLoadIdentity()
108
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_ident)
109
+
110
+ glMultMatrixf(m_a)
111
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_a)
112
+ glLoadIdentity()
113
+ glMultMatrixd(m_b)
114
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_b)
115
+
116
+ # 2
117
+ glMatrixMode(GL_MODELVIEW)
118
+ glLoadMatrixf(m_a)
119
+ glMatrixMode(GL_PROJECTION)
120
+ glLoadMatrixf(m_b)
121
+
122
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_a)
123
+ assert_equal(glGetDoublev(GL_PROJECTION_MATRIX), m_b)
124
+
125
+ glMatrixMode(GL_MODELVIEW)
126
+ glLoadMatrixf(m_a)
127
+ glPushMatrix()
128
+ glLoadMatrixf(m_b)
129
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_b)
130
+ glPopMatrix()
131
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m_a)
132
+
133
+ # 3
134
+ m = Matrix.rows([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]])
135
+ glMatrixMode(GL_MODELVIEW)
136
+ glLoadMatrixf(m)
137
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m.to_a)
138
+ glLoadIdentity()
139
+ glLoadMatrixd(m)
140
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m.to_a)
141
+ glLoadIdentity()
142
+ glMultMatrixf(m)
143
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m.to_a)
144
+ glLoadIdentity()
145
+ glMultMatrixd(m)
146
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX), m.to_a)
147
+
148
+ assert_raises ArgumentError do glLoadMatrixf([1,2,3,4]) end
149
+ assert_raises ArgumentError do glLoadMatrixd([1,2,3,4]) end
150
+ assert_raises ArgumentError do glMultMatrixf([1,2,3,4]) end
151
+ assert_raises ArgumentError do glMultMatrixd([1,2,3,4]) end
152
+ end
153
+
154
+ def test_gledge
155
+ glEdgeFlag(GL_FALSE)
156
+ assert_equal(glGetBooleanv(GL_EDGE_FLAG),false)
157
+
158
+ glEdgeFlag(GL_TRUE)
159
+ assert_equal(glGetBooleanv(GL_EDGE_FLAG),true)
160
+
161
+ glEdgeFlagv([GL_FALSE])
162
+ assert_equal(glGetBooleanv(GL_EDGE_FLAG),false)
163
+ end
164
+
165
+ def test_clientstate
166
+ glEnableClientState(GL_COLOR_ARRAY)
167
+ assert_equal(glIsEnabled(GL_COLOR_ARRAY),true)
168
+ glDisableClientState(GL_COLOR_ARRAY)
169
+ assert_equal(glIsEnabled(GL_COLOR_ARRAY),false)
170
+ end
171
+
172
+ def test_glshademodel
173
+ glShadeModel(GL_FLAT)
174
+ assert_equal(glGetIntegerv(GL_SHADE_MODEL),GL_FLAT)
175
+ glShadeModel(GL_SMOOTH)
176
+ assert_equal(glGetIntegerv(GL_SHADE_MODEL),GL_SMOOTH)
177
+ end
178
+
179
+ def test_glclipplane
180
+ glClipPlane(GL_CLIP_PLANE0,[1,2,3,4])
181
+ assert_equal(glGetClipPlane(GL_CLIP_PLANE0),[1,2,3,4])
182
+ end
183
+
184
+ def test_polygonoffset
185
+ glPolygonOffset(2.0,3.0)
186
+ assert_equal(glGetDoublev(GL_POLYGON_OFFSET_FACTOR),2.0)
187
+ assert_equal(glGetDoublev(GL_POLYGON_OFFSET_UNITS),3.0)
188
+ end
189
+
190
+ def test_glviewport
191
+ glViewport(1,2,3,4)
192
+ assert_equal(glGetIntegerv(GL_VIEWPORT), [1,2,3,4])
193
+ end
194
+
195
+ def test_mask
196
+ glStencilMask(2)
197
+ assert_equal(glGetIntegerv(GL_STENCIL_WRITEMASK), 2)
198
+ glStencilMask(1)
199
+ assert_equal(glGetIntegerv(GL_STENCIL_BACK_WRITEMASK), 1)
200
+
201
+ glColorMask(GL_TRUE,GL_FALSE,GL_TRUE,GL_FALSE)
202
+ assert_equal(glGetBooleanv(GL_COLOR_WRITEMASK),[true,false,true,false])
203
+
204
+ glDepthMask(GL_TRUE)
205
+ assert_equal(glGetBooleanv(GL_DEPTH_WRITEMASK),true)
206
+ glDepthMask(GL_FALSE)
207
+ assert_equal(glGetBooleanv(GL_DEPTH_WRITEMASK),false)
208
+
209
+ glIndexMask(2)
210
+ assert_equal(glGetIntegerv(GL_INDEX_WRITEMASK), 2)
211
+ glIndexMask(1)
212
+ assert_equal(glGetIntegerv(GL_INDEX_WRITEMASK), 1)
213
+ end
214
+
215
+ def test_glflush
216
+ begin
217
+ glBegin(GL_POINTS)
218
+ glFlush()
219
+ glEnd
220
+ rescue Gl::Error => err
221
+ assert(err.id == GL_INVALID_OPERATION)
222
+ end
223
+ end
224
+
225
+ def test_glfinish
226
+ begin
227
+ glBegin(GL_POINTS)
228
+ glFinish()
229
+ glEnd
230
+ rescue Gl::Error => err
231
+ assert(err.id == GL_INVALID_OPERATION)
232
+ end
233
+ end
234
+
235
+ def test_glgetstring
236
+ assert(glGetString(GL_VERSION).size > 0)
237
+ end
238
+
239
+ def test_glscissor
240
+ glScissor(1,2,3,4)
241
+ assert_equal(glGetIntegerv(GL_SCISSOR_BOX),[1,2,3,4])
242
+ end
243
+
244
+ def test_glstencilfunc
245
+ glStencilFunc(GL_LEQUAL,2,3)
246
+ assert_equal(glGetIntegerv(GL_STENCIL_FUNC),GL_LEQUAL)
247
+ assert_equal(glGetIntegerv(GL_STENCIL_REF),2)
248
+ assert_equal(glGetIntegerv(GL_STENCIL_VALUE_MASK),3)
249
+ end
250
+
251
+ def test_glstencilop
252
+ glStencilOp(GL_ZERO,GL_REPLACE,GL_INCR)
253
+ assert_equal(glGetIntegerv(GL_STENCIL_FAIL),GL_ZERO)
254
+ assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL),GL_REPLACE)
255
+ assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS),GL_INCR)
256
+ end
257
+
258
+ def test_gllogicop
259
+ glLogicOp(GL_NAND)
260
+ assert_equal(glGetIntegerv(GL_LOGIC_OP_MODE),GL_NAND)
261
+ end
262
+
263
+ def test_glfrustum
264
+ glMatrixMode(GL_PROJECTION)
265
+ glLoadIdentity()
266
+
267
+ glFrustum(1,2,3,4,5,6)
268
+ assert_equal(glGetDoublev(GL_PROJECTION_MATRIX),[[10.0, 0.0, 0.0, 0.0], [0.0, 10.0, 0.0, 0.0], [3.0, 7.0, -11.0, -1.0], [0.0, 0.0, -60.0, 0.0]])
269
+ end
270
+
271
+ def test_gldepthrange
272
+ glDepthRange(0.5,0.5)
273
+ assert_equal(glGetDoublev(GL_DEPTH_RANGE),[0.5,0.5])
274
+ end
275
+
276
+ def test_func
277
+ glAlphaFunc(GL_GREATER,0.5)
278
+ assert_equal(glGetIntegerv(GL_ALPHA_TEST_FUNC),GL_GREATER)
279
+ assert_equal(glGetDoublev(GL_ALPHA_TEST_REF),0.5)
280
+
281
+ glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_DST_COLOR)
282
+ assert_equal(glGetIntegerv(GL_BLEND_SRC),GL_CONSTANT_ALPHA)
283
+ assert_equal(glGetIntegerv(GL_BLEND_DST),GL_ONE_MINUS_DST_COLOR)
284
+
285
+ glDepthFunc(GL_LEQUAL)
286
+ assert_equal(glGetIntegerv(GL_DEPTH_FUNC),GL_LEQUAL)
287
+ end
288
+
289
+ def test_glpixelzoom
290
+ glPixelZoom(0.5,0.5)
291
+ assert_equal(glGetDoublev(GL_ZOOM_X),0.5)
292
+ assert_equal(glGetDoublev(GL_ZOOM_Y),0.5)
293
+ end
294
+
295
+ def test_glpixelstore
296
+ glPixelStoref(GL_PACK_IMAGE_HEIGHT,5)
297
+ assert_equal(glGetIntegerv(GL_PACK_IMAGE_HEIGHT),5)
298
+ glPixelStorei(GL_PACK_IMAGE_HEIGHT,6)
299
+ assert_equal(glGetIntegerv(GL_PACK_IMAGE_HEIGHT),6)
300
+ end
301
+
302
+ def test_glpixeltransfer
303
+ glPixelTransferf(GL_RED_SCALE,2)
304
+ assert_equal(glGetIntegerv(GL_RED_SCALE),2)
305
+ glPixelTransferi(GL_RED_SCALE,3)
306
+ assert_equal(glGetIntegerv(GL_RED_SCALE),3)
307
+ end
308
+
309
+ def test_pixelmap
310
+ glPixelMapfv(GL_PIXEL_MAP_I_TO_I,[1,2,3,4])
311
+ assert_equal(glGetPixelMapfv(GL_PIXEL_MAP_I_TO_I), [1,2,3,4])
312
+
313
+ glPixelMapuiv(GL_PIXEL_MAP_I_TO_I,[5,6,7,8])
314
+ assert_equal(glGetPixelMapuiv(GL_PIXEL_MAP_I_TO_I),[5,6,7,8])
315
+
316
+ glPixelMapusv(GL_PIXEL_MAP_I_TO_I,[9,10,11,12])
317
+ assert_equal(glGetPixelMapusv(GL_PIXEL_MAP_I_TO_I),[9,10,11,12])
318
+ end
319
+
320
+ def test_buffers
321
+ glDrawBuffer(GL_FRONT)
322
+ assert_equal(glGetIntegerv(GL_DRAW_BUFFER),GL_FRONT)
323
+ glDrawBuffer(GL_BACK)
324
+ assert_equal(glGetIntegerv(GL_DRAW_BUFFER),GL_BACK)
325
+
326
+ glReadBuffer(GL_FRONT)
327
+ assert_equal(glGetIntegerv(GL_READ_BUFFER),GL_FRONT)
328
+ glReadBuffer(GL_BACK)
329
+ assert_equal(glGetIntegerv(GL_READ_BUFFER),GL_BACK)
330
+ end
331
+
332
+ def test__selection_buffer
333
+ buf = glSelectBuffer(32)
334
+
335
+ glRenderMode(GL_SELECT)
336
+ glInitNames()
337
+ glPushName(6)
338
+ glPushName(3)
339
+ glLoadName(5)
340
+ glPopName()
341
+
342
+ glBegin(GL_QUADS)
343
+ glVertex2i(-1,-1)
344
+ glVertex2i( 1,-1)
345
+ glVertex2i( 1, 1)
346
+ glVertex2i(-1, 1)
347
+ glEnd()
348
+
349
+ count = glRenderMode(GL_RENDER)
350
+ data = buf.unpack("i*")
351
+ assert(count==1) # number of records
352
+ assert(data[0]==1) # number of hits in this record
353
+ # assert(data[1]>0) # zbuffer near
354
+ # assert(data[2]>0) # zbuffer far
355
+ assert(data[3]==6) # name of hit
356
+ end
357
+
358
+ def test__feedback_buffer
359
+ buf = glFeedbackBuffer(32,GL_2D)
360
+
361
+ glRenderMode(GL_FEEDBACK)
362
+
363
+ glBegin(GL_TRIANGLES)
364
+ glVertex2i(-1,-1)
365
+ glVertex2i( 1,-1)
366
+ glVertex2i( 1, 1)
367
+ glEnd()
368
+
369
+ glPassThrough(2.0)
370
+
371
+ count = glRenderMode(GL_RENDER)
372
+ data = buf.unpack("f*")
373
+ assert_equal(count,10) # (1 + 1 + 3x2) + (1 + 1)
374
+ assert_equal(data[0],GL_POLYGON_TOKEN)
375
+ assert_equal(data[1],3) # 3 vertices
376
+ # skip rasterized vertex data
377
+ assert_equal(data[8],GL_PASS_THROUGH_TOKEN)
378
+ assert_equal(data[9],2.0)
379
+ end
380
+
381
+ def test_glrasterposv
382
+ glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
383
+
384
+ glRasterPos3dv Vector[1, 1, 1]
385
+
386
+ assert_each_in_delta [1, 1, 1, 1], glGetDoublev(GL_CURRENT_RASTER_POSITION)
387
+ end
388
+
389
+ def test_glrasterpos_2
390
+ glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
391
+
392
+ glRasterPos2d(1.0,2.0)
393
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,0.0,1.0])
394
+ glRasterPos2dv([3.0,4.0])
395
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
396
+
397
+ glRasterPos2f(1.0,2.0)
398
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,0.0,1.0])
399
+ glRasterPos2fv([3.0,4.0])
400
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
401
+
402
+ glRasterPos2i(1,2)
403
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,0.0,1.0])
404
+ glRasterPos2iv([3,4])
405
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
406
+
407
+ glRasterPos2s(1,2)
408
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,0.0,1.0])
409
+ glRasterPos2sv([3,4])
410
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
411
+ end
412
+
413
+ def test_glrasterpos_3
414
+ glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
415
+
416
+ glRasterPos3d(1.0,2.0,1.0)
417
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
418
+ glRasterPos3dv([3.0,4.0,0.0])
419
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
420
+
421
+ glRasterPos3f(1.0,2.0,1.0)
422
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
423
+ glRasterPos3fv([3.0,4.0,0.0])
424
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
425
+
426
+ glRasterPos3i(1,2,1)
427
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
428
+ glRasterPos3iv([3,4,0])
429
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
430
+
431
+ glRasterPos3s(1,2,1)
432
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
433
+ glRasterPos3sv([3,4,0])
434
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
435
+
436
+ # 4
437
+ glRasterPos4d(1.0,2.0,1.0,1.0)
438
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
439
+ glRasterPos4dv([3.0,4.0,0.0,1.0])
440
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
441
+
442
+ glRasterPos4f(1.0,2.0,1.0,1.0)
443
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
444
+ glRasterPos4fv([3.0,4.0,0.0,1.0])
445
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
446
+
447
+ glRasterPos4i(1,2,1,1)
448
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
449
+ glRasterPos4iv([3,4,0,1])
450
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
451
+
452
+ glRasterPos4s(1,2,1,1)
453
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1.0,2.0,1.0,1.0])
454
+ glRasterPos4sv([3,4,0,1])
455
+ assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[3.0,4.0,0.0,1.0])
456
+ end
457
+
458
+ def test_glbitmap
459
+ glOrtho(0,WINDOW_SIZE,0,WINDOW_SIZE,0,-1)
460
+
461
+ bitmap = [ 0x55 ] * 8 # 64 bits (8x8 bitmap), stipple pattern
462
+
463
+ glPixelStorei(GL_PACK_ALIGNMENT,1)
464
+ glPixelStorei(GL_UNPACK_ALIGNMENT,1)
465
+
466
+ glBitmap(8,8,0,0,0,0,bitmap.pack("c*"))
467
+ data = glReadPixels(0,0,8,8,GL_RED,GL_UNSIGNED_BYTE)
468
+ assert_equal(data.unpack("C*"),[0,255] * 32)
469
+ end
470
+
471
+ def test_glfog
472
+ glFogfv(GL_FOG_COLOR,[0.0,1.0,0.0,1.0])
473
+ assert_equal(glGetDoublev(GL_FOG_COLOR),[0.0,1.0,0.0,1.0])
474
+ glFogf(GL_FOG_DENSITY,0.5)
475
+ assert_equal(glGetDoublev(GL_FOG_DENSITY),0.5)
476
+ glFogi(GL_FOG_MODE,GL_LINEAR)
477
+ assert_equal(glGetIntegerv(GL_FOG_MODE),GL_LINEAR)
478
+ glFogi(GL_FOG_MODE,GL_EXP)
479
+ assert_equal(glGetIntegerv(GL_FOG_MODE),GL_EXP)
480
+ glFogiv(GL_FOG_MODE,[GL_EXP2])
481
+ assert_equal(glGetIntegerv(GL_FOG_MODE),GL_EXP2)
482
+ end
483
+
484
+ def test_glcolorv
485
+ glColor3fv Vector[1, 1, 1]
486
+
487
+ assert_each_in_delta [1, 1, 1, 1], glGetDoublev(GL_CURRENT_COLOR)
488
+ end
489
+
490
+ def test_glcolor_3
491
+ glColor3b(2**7-1, 0, 2**7-1)
492
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
493
+
494
+ glColor3bv([0, 2**7-1, 0])
495
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
496
+
497
+ glColor3d(1.0, 0.0, 1.0)
498
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
499
+
500
+ glColor3dv([0.0, 1.0, 0.0])
501
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
502
+
503
+ glColor3f(1.0, 0.0, 1.0)
504
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
505
+
506
+ glColor3fv([0.0, 1.0, 0.0])
507
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
508
+
509
+ glColor3i(2**31-1, 0, 2**31-1)
510
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
511
+
512
+ glColor3iv([0, 2**31-1, 0])
513
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
514
+
515
+ glColor3s(2**15-1, 0, 2**15-1)
516
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
517
+
518
+ glColor3sv([0, 2**15-1, 0])
519
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
520
+
521
+ glColor3ub(2**8-1, 0, 2**8-1)
522
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
523
+
524
+ glColor3ubv([0, 2**8-1, 0])
525
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
526
+
527
+ glColor3ui(2**32-1, 0, 2**32-1)
528
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
529
+
530
+ glColor3uiv([0, 2**32-1, 0])
531
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
532
+
533
+ glColor3us(2**16-1, 0, 2**16-1)
534
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
535
+
536
+ glColor3usv([0, 2**16-1, 0])
537
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
538
+ end
539
+
540
+ def test_glcolor_4
541
+ glColor4b(2**7-1, 0, 2**7-1, 0)
542
+ assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
543
+
544
+ glColor4bv([0, 2**7-1, 0, 2**7-1])
545
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
546
+
547
+ glColor4d(1.0, 0.0, 1.0, 0.0)
548
+ assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
549
+
550
+ glColor4dv([0.0, 1.0, 0.0, 1.0])
551
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
552
+
553
+ glColor4fv([0.0, 1.0, 0.0, 1.0])
554
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
555
+
556
+ glColor4i(2**31-1, 0, 2**31-1, 0)
557
+ assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
558
+
559
+ glColor4iv([0, 2**31-1, 0, 2**31-1])
560
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
561
+
562
+ glColor4s(2**15-1, 0, 2**15-1, 0)
563
+ assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
564
+
565
+ glColor4sv([0, 2**15-1, 0, 2**15-1])
566
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
567
+
568
+ glColor4ub(2**8-1, 0, 2**8-1, 0)
569
+ assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
570
+
571
+ glColor4ubv([0, 2**8-1, 0, 2**8-1])
572
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
573
+
574
+ glColor4ui(2**32-1, 0, 2**32-1, 0)
575
+ assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
576
+
577
+ glColor4uiv([0, 2**32-1, 0, 2**32-1])
578
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
579
+
580
+ glColor4us(2**16-1, 0, 2**16-1, 0)
581
+ assert_each_in_delta [1.0, 0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
582
+
583
+ glColor4usv([0, 2**16-1, 0, 2**16-1])
584
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_COLOR), 0.01
585
+ end
586
+
587
+ def test_glortho
588
+ res = [ [2.0/WINDOW_SIZE, 0, 0, 0],
589
+ [0, 2.0/WINDOW_SIZE, 0, 0],
590
+ [0, 0, 2, 0],
591
+ [-1,-1,-1,1] ]
592
+
593
+ glMatrixMode(GL_PROJECTION)
594
+ glLoadIdentity()
595
+ glOrtho(0,WINDOW_SIZE,0,WINDOW_SIZE,0,-1)
596
+ assert_equal(glGetDoublev(GL_PROJECTION_MATRIX),res)
597
+ end
598
+
599
+ def test_glnormal
600
+ glNormal3d(1.0, 2.0, 3.0)
601
+ assert_equal([1.0, 2.0, 3.0], glGetDoublev(GL_CURRENT_NORMAL))
602
+
603
+ glNormal3dv([4.0, 5.0, 6.0])
604
+ assert_equal([4.0, 5.0, 6.0], glGetDoublev(GL_CURRENT_NORMAL))
605
+
606
+ glNormal3f(1.0, 2.0, 3.0)
607
+ assert_equal([1.0, 2.0, 3.0], glGetDoublev(GL_CURRENT_NORMAL))
608
+
609
+ glNormal3fv([4.0, 5.0, 6.0])
610
+ assert_equal([4.0, 5.0, 6.0], glGetDoublev(GL_CURRENT_NORMAL))
611
+
612
+ glNormal3i(1, 2, 3)
613
+ assert_equal([0, 1, 2], glGetIntegerv(GL_CURRENT_NORMAL))
614
+
615
+ glNormal3iv([4, 5, 6])
616
+ assert_equal([3, 4, 5], glGetIntegerv(GL_CURRENT_NORMAL))
617
+
618
+ glNormal3b(2**7-1, 0, 2**7-1)
619
+ assert_each_in_delta([1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_NORMAL))
620
+
621
+ glNormal3bv(0, 2**7-1, 0)
622
+ assert_each_in_delta([0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_NORMAL))
623
+
624
+ glNormal3s(2**15-1, 0, 2**15-1)
625
+ assert_each_in_delta([1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_NORMAL))
626
+
627
+ glNormal3sv(0, 2**15-1, 0)
628
+ assert_each_in_delta([0.0, 1.0, 0.0], glGetDoublev(GL_CURRENT_NORMAL))
629
+ end
630
+
631
+ def test_gllight
632
+ glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,80.0)
633
+ assert_equal(glGetLightfv(GL_LIGHT0,GL_SPOT_CUTOFF),80.0)
634
+ glLighti(GL_LIGHT0,GL_SPOT_CUTOFF,75)
635
+ assert_equal(glGetLightiv(GL_LIGHT0,GL_SPOT_CUTOFF),75)
636
+ glLightfv(GL_LIGHT0,GL_AMBIENT,[0.5,0.5,0.5,1.0])
637
+ assert_equal(glGetLightfv(GL_LIGHT0,GL_AMBIENT), [0.5,0.5,0.5,1.0])
638
+ glLightiv(GL_LIGHT0,GL_CONSTANT_ATTENUATION,[32])
639
+ assert_equal(glGetLightiv(GL_LIGHT0,GL_CONSTANT_ATTENUATION),32)
640
+ end
641
+
642
+ def test_glmaterial
643
+ glMaterialfv(GL_FRONT,GL_AMBIENT,[0.0,1.0,0.0,1.0])
644
+ assert_equal([0.0,1.0,0.0,1.0], glGetMaterialfv(GL_FRONT,GL_AMBIENT))
645
+
646
+ glMaterialiv(GL_FRONT,GL_SHININESS,[50])
647
+ assert_equal(glGetMaterialiv(GL_FRONT,GL_SHININESS),50)
648
+
649
+ glMaterialf(GL_FRONT,GL_SHININESS,49.0)
650
+ assert_equal(glGetMaterialfv(GL_FRONT,GL_SHININESS),49.0)
651
+
652
+ glMateriali(GL_FRONT,GL_SHININESS,48)
653
+ assert_equal(glGetMaterialiv(GL_FRONT,GL_SHININESS),48)
654
+
655
+ end
656
+
657
+ def test_glcolormaterial
658
+ glColorMaterial(GL_FRONT,GL_EMISSION)
659
+ assert_equal(glGetIntegerv(GL_COLOR_MATERIAL_FACE),GL_FRONT)
660
+ assert_equal(glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER),GL_EMISSION)
661
+
662
+ glColorMaterial(GL_BACK,GL_SPECULAR)
663
+ assert_equal(glGetIntegerv(GL_COLOR_MATERIAL_FACE),GL_BACK)
664
+ assert_equal(glGetIntegerv(GL_COLOR_MATERIAL_PARAMETER),GL_SPECULAR)
665
+ end
666
+
667
+ def test_gllightmodel
668
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1)
669
+ assert_equal(GL_TRUE, glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE))
670
+
671
+ glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, 0)
672
+ assert_equal(GL_FALSE, glGetBooleanv(GL_LIGHT_MODEL_TWO_SIDE))
673
+
674
+ glLightModelfv(GL_LIGHT_MODEL_AMBIENT, [0.5, 0.5, 0.5, 1.0])
675
+ assert_equal([0.5, 0.5, 0.5, 1.0], glGetDoublev(GL_LIGHT_MODEL_AMBIENT))
676
+
677
+ glLightModeliv(GL_LIGHT_MODEL_AMBIENT, [2, 0, 2, 0])
678
+ assert_equal([1, 0, 1, 0], glGetIntegerv(GL_LIGHT_MODEL_AMBIENT))
679
+ end
680
+
681
+ def test_gltexcoordv
682
+ glTexCoord2dv [1, 1]
683
+
684
+ assert_each_in_delta [1, 1, 0, 1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS)
685
+ end
686
+
687
+ def test_gltexcoord_1
688
+ glTexCoord1d(1.5)
689
+ assert_equal([1.5,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
690
+ glTexCoord1dv([0.5])
691
+ assert_equal([0.5,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
692
+ glTexCoord1f(1.5)
693
+ assert_equal([1.5,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
694
+ glTexCoord1fv([0.5])
695
+ assert_equal([0.5,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
696
+ glTexCoord1i(1)
697
+ assert_equal([1,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
698
+ glTexCoord1iv([0])
699
+ assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
700
+ glTexCoord1s(1)
701
+ assert_equal([1,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
702
+ glTexCoord1sv([0])
703
+ assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
704
+ end
705
+
706
+ def test_gltexcoord_2
707
+ glTexCoord2d(1.5,1.5)
708
+ assert_equal([1.5,1.5,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
709
+ glTexCoord2dv([0.5,0.5])
710
+ assert_equal([0.5,0.5,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
711
+ glTexCoord2f(1.5,1.5)
712
+ assert_equal([1.5,1.5,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
713
+ glTexCoord2fv([0.5,0.5])
714
+ assert_equal([0.5,0.5,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
715
+ glTexCoord2i(1,1)
716
+ assert_equal([1,1,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
717
+ glTexCoord2iv([0,0])
718
+ assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
719
+ glTexCoord2s(1,1)
720
+ assert_equal([1,1,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
721
+ glTexCoord2sv([0,0])
722
+ assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
723
+ end
724
+
725
+ def test_gltexcoord_3
726
+ glTexCoord3d(1.5,1.5,1.5)
727
+ assert_equal([1.5,1.5,1.5,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
728
+ glTexCoord3dv([0.5,0.5,0.5])
729
+ assert_equal([0.5,0.5,0.5,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
730
+ glTexCoord3f(1.5,1.5,1.5)
731
+ assert_equal([1.5,1.5,1.5,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
732
+ glTexCoord3fv([0.5,0.5,0.5])
733
+ assert_equal([0.5,0.5,0.5,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
734
+ glTexCoord3i(1,1,1)
735
+ assert_equal([1,1,1,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
736
+ glTexCoord3iv([0,0,0])
737
+ assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
738
+ glTexCoord3s(1,1,1)
739
+ assert_equal([1,1,1,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
740
+ glTexCoord3sv([0,0,0])
741
+ assert_equal([0,0,0,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
742
+ end
743
+
744
+ def test_gltexcoord_4
745
+ glTexCoord4d(1.5,1.5,1.5,1.5)
746
+ assert_equal([1.5,1.5,1.5,1.5], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
747
+ glTexCoord4dv([0.5,0.5,0.5,0.5])
748
+ assert_equal([0.5,0.5,0.5,0.5], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
749
+ glTexCoord4f(1.5,1.5,1.5,1.5)
750
+ assert_equal([1.5,1.5,1.5,1.5], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
751
+ glTexCoord4fv([0.5,0.5,0.5,0.5])
752
+ assert_equal([0.5,0.5,0.5,0.5], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
753
+ glTexCoord4i(1,1,1,1)
754
+ assert_equal([1,1,1,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
755
+ glTexCoord4iv([0,0,0,0])
756
+ assert_equal([0,0,0,0], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
757
+ glTexCoord4s(1,1,1,1)
758
+ assert_equal([1,1,1,1], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
759
+ glTexCoord4sv([0,0,0,0])
760
+ assert_equal([0,0,0,0], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
761
+ end
762
+
763
+ def test_glenable_disable
764
+ glEnable(GL_FOG)
765
+ assert_equal(glIsEnabled(GL_FOG),true)
766
+ glDisable(GL_FOG)
767
+ assert_equal(glIsEnabled(GL_FOG),false)
768
+ end
769
+
770
+ def test_gltexparameter
771
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP)
772
+ assert_equal(glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S),GL_CLAMP)
773
+
774
+ glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_MIRRORED_REPEAT)
775
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S),GL_MIRRORED_REPEAT)
776
+
777
+ glTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,[GL_CLAMP])
778
+ assert_equal(glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S),GL_CLAMP)
779
+
780
+ glTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,[GL_MIRRORED_REPEAT])
781
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S),GL_MIRRORED_REPEAT)
782
+
783
+ assert_equal(glGetTexLevelParameterfv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH),0.0)
784
+ assert_equal(glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH),0)
785
+ end
786
+
787
+ def test_glcullface
788
+ glCullFace(GL_FRONT)
789
+ assert_equal(glGetIntegerv(GL_CULL_FACE_MODE),GL_FRONT)
790
+ glCullFace(GL_BACK)
791
+ assert_equal(glGetIntegerv(GL_CULL_FACE_MODE),GL_BACK)
792
+ end
793
+
794
+ def test_glfrontface
795
+ glFrontFace(GL_CW)
796
+ assert_equal(glGetIntegerv(GL_FRONT_FACE),GL_CW)
797
+ glFrontFace(GL_CCW)
798
+ assert_equal(glGetIntegerv(GL_FRONT_FACE),GL_CCW)
799
+ end
800
+
801
+ def test_glpointsize
802
+ glPointSize(2.0)
803
+ assert_equal(glGetDoublev(GL_POINT_SIZE),2.0)
804
+ glPointSize(3.0)
805
+ assert_equal(glGetDoublev(GL_POINT_SIZE),3.0)
806
+ end
807
+
808
+ def test_glpolygonmode
809
+ glPolygonMode(GL_FRONT_AND_BACK,GL_LINE)
810
+ assert_equal(glGetIntegerv(GL_POLYGON_MODE),[GL_LINE,GL_LINE])
811
+ glPolygonMode(GL_FRONT_AND_BACK,GL_FILL)
812
+ assert_equal(glGetIntegerv(GL_POLYGON_MODE),[GL_FILL,GL_FILL])
813
+ end
814
+
815
+ def test_gllinewidth
816
+ glLineWidth(2.0)
817
+ assert_equal(glGetDoublev(GL_LINE_WIDTH),2.0)
818
+ glLineWidth(3.0)
819
+ assert_equal(glGetDoublev(GL_LINE_WIDTH),3.0)
820
+ end
821
+
822
+ def test_gllinestipple
823
+ glLineStipple(3,0x1234)
824
+ assert_equal(glGetIntegerv(GL_LINE_STIPPLE_REPEAT),3)
825
+ assert_equal(glGetIntegerv(GL_LINE_STIPPLE_PATTERN),0x1234)
826
+ end
827
+
828
+ def test_glpolygonstipple
829
+ stipple = [0x12] * 128
830
+ glPolygonStipple(stipple.pack("c*"))
831
+ assert_equal(glGetPolygonStipple(),stipple.pack("c*"))
832
+ end
833
+
834
+ def parse_feedback_data(data,count)
835
+ c = count / 11
836
+ ret = []
837
+ (0...c).each do |x|
838
+ i = x *11
839
+ type = data[0+i]
840
+
841
+ v1 = [data[2+i], data[3+i], data[4+i]]
842
+ v2 = [data[5+i], data[6+i], data[7+i]]
843
+ v3 = [data[8+i], data[9+i], data[10+i]]
844
+ vertex = [v1,v2,v3].sort
845
+ ret << [type,vertex]
846
+ end
847
+ ret
848
+ end
849
+
850
+ def test_glvertex
851
+ glMatrixMode(GL_PROJECTION)
852
+ glOrtho(0,WINDOW_SIZE,0,WINDOW_SIZE,0,-1)
853
+
854
+ buf = glFeedbackBuffer(256,GL_3D)
855
+
856
+ glRenderMode(GL_FEEDBACK)
857
+
858
+ glBegin(GL_TRIANGLES)
859
+ glVertex2d( 1, 0)
860
+ glVertex2dv([0,0])
861
+ glVertex2f( 1,1)
862
+
863
+ glVertex2fv([ 1, 0])
864
+ glVertex2i( 0,0)
865
+ glVertex2iv([1,1])
866
+
867
+ glVertex2s( 1, 0)
868
+ glVertex2sv([0,0])
869
+ glVertex3d( 1,1,0)
870
+
871
+ glVertex3dv([ 1, 0,0])
872
+ glVertex3f( 0,0,0)
873
+ glVertex3fv([1,1,0])
874
+
875
+ glVertex3i( 1, 0,0)
876
+ glVertex3iv([0,0,0])
877
+ glVertex3s( 1,1,0)
878
+
879
+ glVertex3sv([ 1, 0,0])
880
+ glVertex4d( 0,0,0,1)
881
+ glVertex4dv([1,1,0,1])
882
+
883
+ glVertex4f( 1, 0,0,1)
884
+ glVertex4fv([0,0,0,1])
885
+ glVertex4i( 1,1,0,1)
886
+
887
+ glVertex4iv([ 1, 0,0,1])
888
+ glVertex4s( 0,0,0,1)
889
+ glVertex4sv([1,1,0,1])
890
+
891
+ glEnd()
892
+
893
+ count = glRenderMode(GL_RENDER)
894
+ data = buf.unpack("f*")
895
+
896
+ ref = [[GL_POLYGON_TOKEN,[[0,0,0],[1,0,0],[1,1,0]]]] * 8
897
+
898
+ assert_equal(parse_feedback_data(data,count),ref)
899
+ end
900
+
901
+ def test_glrect
902
+ glMatrixMode GL_PROJECTION
903
+ glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
904
+
905
+ buf = glFeedbackBuffer 256, GL_3D
906
+
907
+ glRenderMode GL_FEEDBACK
908
+
909
+ glRectd(0, 0, 1, 1)
910
+ glRectdv([0, 0], [1, 1])
911
+
912
+ glRectf(0, 0, 1, 1)
913
+ glRectfv([0, 0], [1, 1])
914
+
915
+ glRecti(0, 0, 1, 1)
916
+ glRectiv([0, 0], [1, 1])
917
+
918
+ glRects(0, 0, 1, 1)
919
+ glRectsv([0, 0], [1, 1])
920
+
921
+ count = glRenderMode GL_RENDER
922
+ data = buf.unpack("f*")
923
+
924
+ # eight 3d polygons with four points
925
+ assert_equal 8 * (4 * 3 + 2), count
926
+ end
927
+
928
+ def test_glrectv
929
+ glMatrixMode GL_PROJECTION
930
+ glOrtho 0, WINDOW_SIZE, 0, WINDOW_SIZE, 0, -1
931
+
932
+ buf = glFeedbackBuffer 256, GL_3D
933
+
934
+ glRenderMode GL_FEEDBACK
935
+
936
+ glRectdv Vector[0, 0], Vector[1, 1]
937
+
938
+ refute_equal 0, glRenderMode(GL_RENDER)
939
+ end
940
+
941
+ def test_glclear
942
+ glClearColor(1.0,1.0,1.0,1.0)
943
+ glClear(GL_COLOR_BUFFER_BIT)
944
+
945
+ data = glReadPixels(0,0,1,1,GL_RGB,GL_FLOAT)
946
+ assert_equal(data.unpack("f*"),[1.0,1.0,1.0])
947
+
948
+ glClearColor(0.0,0.0,0.0,0.0)
949
+ glClear(GL_COLOR_BUFFER_BIT)
950
+
951
+ data = glReadPixels(0,0,1,1,GL_RGB,GL_FLOAT)
952
+ assert_equal(data.unpack("f*"),[0.0,0.0,0.0])
953
+ end
954
+
955
+ def test_gltexenv
956
+ glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_ADD)
957
+ assert_equal(glGetTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE),GL_ADD)
958
+ glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE)
959
+ assert_equal(glGetTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE),GL_MODULATE)
960
+
961
+ glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,[GL_ADD])
962
+ assert_equal(glGetTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE),GL_ADD)
963
+ glTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,[GL_MODULATE])
964
+ assert_equal(glGetTexEnviv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE),GL_MODULATE)
965
+ end
966
+
967
+ def test_gltexgen
968
+ glTexGend(GL_S,GL_TEXTURE_GEN_MODE,GL_REFLECTION_MAP)
969
+ assert_equal(glGetTexGendv(GL_S,GL_TEXTURE_GEN_MODE),GL_REFLECTION_MAP)
970
+ glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_EYE_LINEAR)
971
+ assert_equal(glGetTexGenfv(GL_S,GL_TEXTURE_GEN_MODE),GL_EYE_LINEAR)
972
+ glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP)
973
+ assert_equal(glGetTexGeniv(GL_S,GL_TEXTURE_GEN_MODE),GL_SPHERE_MAP)
974
+
975
+ glTexGendv(GL_S,GL_TEXTURE_GEN_MODE,[GL_REFLECTION_MAP])
976
+ assert_equal(glGetTexGendv(GL_S,GL_TEXTURE_GEN_MODE),GL_REFLECTION_MAP)
977
+ glTexGenfv(GL_S,GL_TEXTURE_GEN_MODE,[GL_EYE_LINEAR])
978
+ assert_equal(glGetTexGenfv(GL_S,GL_TEXTURE_GEN_MODE),GL_EYE_LINEAR)
979
+ glTexGeniv(GL_S,GL_TEXTURE_GEN_MODE,[GL_SPHERE_MAP])
980
+ assert_equal(glGetTexGeniv(GL_S,GL_TEXTURE_GEN_MODE),GL_SPHERE_MAP)
981
+ end
982
+
983
+ def test_textures
984
+ textures = glGenTextures(2)
985
+ assert_equal(textures.size, 2)
986
+ assert_equal(glIsTexture(textures[0]),false)
987
+ glBindTexture(GL_TEXTURE_2D,textures[0])
988
+ assert_equal(glIsTexture(textures[0]),true)
989
+
990
+ image = ([0,0,0,1,1,1] * 8).pack("f*") # 16 RGB pixels
991
+
992
+ glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8, 4, 4, 0, GL_RGB, GL_FLOAT, image)
993
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT), image)
994
+
995
+ glBindTexture(GL_TEXTURE_1D,textures[1])
996
+
997
+ glTexImage1D(GL_TEXTURE_1D,0,GL_RGB8, 16, 0, GL_RGB, GL_FLOAT, image)
998
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT), image)
999
+
1000
+ glDeleteTextures(textures)
1001
+ assert_equal(glIsTexture(textures[0]),false)
1002
+ end
1003
+
1004
+ def test_pixels
1005
+ glClearColor(0,0,0,0)
1006
+ glClear(GL_COLOR_BUFFER_BIT)
1007
+
1008
+ data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
1009
+ assert_equal(data.unpack("f*"), [0] * 3 * 16)
1010
+
1011
+ image = ([1.0] * 3 * 16).pack("f*")
1012
+ glDrawPixels(4,4,GL_RGB,GL_FLOAT,image)
1013
+
1014
+ data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
1015
+ assert_equal(data,image)
1016
+
1017
+ #
1018
+ glClearColor(0,0,0,0)
1019
+ glClear(GL_COLOR_BUFFER_BIT)
1020
+
1021
+ image = (([0.0] * 3 * 8) + ([1.0] * 3 * 8)).pack("f*")
1022
+ glDrawPixels(4,4,GL_RGB,GL_FLOAT,image)
1023
+
1024
+ data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
1025
+ assert_equal(data,image)
1026
+
1027
+ glCopyPixels(0,2,4,2,GL_COLOR)
1028
+
1029
+ data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
1030
+ assert_equal(data,([1.0] * 3 * 16).pack("f*"))
1031
+ end
1032
+
1033
+ def test_gltranslate
1034
+ m = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[1,2,3,1]]
1035
+ glMatrixMode(GL_MODELVIEW)
1036
+ glLoadIdentity()
1037
+ glTranslated(1.0,2.0,3.0)
1038
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX),m)
1039
+ glLoadIdentity()
1040
+ glTranslatef(1.0,2.0,3.0)
1041
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX),m)
1042
+ end
1043
+
1044
+ def test_glscale
1045
+ m = [[1,0,0,0],[0,2,0,0],[0,0,3,0],[0,0,0,1]]
1046
+ glMatrixMode(GL_MODELVIEW)
1047
+ glLoadIdentity()
1048
+ glScaled(1.0,2.0,3.0)
1049
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX),m)
1050
+ glLoadIdentity()
1051
+ glScalef(1.0,2.0,3.0)
1052
+ assert_equal(glGetDoublev(GL_MODELVIEW_MATRIX),m)
1053
+ end
1054
+
1055
+ def test_glrotate
1056
+ m1 = [[0, 0, -1, 0], [0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1]]
1057
+ m2 = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
1058
+ glMatrixMode(GL_MODELVIEW)
1059
+ glLoadIdentity()
1060
+ glRotated(90, 0, 1, 0)
1061
+
1062
+ assert_each_in_delta m1, glGetDoublev(GL_MODELVIEW_MATRIX)
1063
+
1064
+ glRotated(-90, 0, 1, 0)
1065
+
1066
+ assert_each_in_delta m2, glGetDoublev(GL_MODELVIEW_MATRIX)
1067
+ end
1068
+
1069
+ def test_textures_2
1070
+ textures = glGenTextures(2)
1071
+ glBindTexture(GL_TEXTURE_1D,textures[0])
1072
+ glBindTexture(GL_TEXTURE_2D,textures[1])
1073
+ assert_equal(glAreTexturesResident(textures).size,2)
1074
+ glPrioritizeTextures(textures,[0.5,1.0])
1075
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_1D,GL_TEXTURE_PRIORITY),0.5)
1076
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_2D,GL_TEXTURE_PRIORITY),1.0)
1077
+
1078
+ tex = ([0,0,0,1,1,1] * 2).pack("f*")
1079
+ tex2 = ([1] * 3 * 4).pack("f*")
1080
+
1081
+ # 1d
1082
+ glDrawPixels(4,1,GL_RGB,GL_FLOAT,tex)
1083
+ glCopyTexImage1D(GL_TEXTURE_1D,0,GL_RGB8,0,0,4,0)
1084
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT),tex)
1085
+
1086
+ glDrawPixels(4,1,GL_RGB,GL_FLOAT,tex2)
1087
+ glCopyTexSubImage1D(GL_TEXTURE_1D,0,0,0,0,4)
1088
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT),tex2)
1089
+
1090
+ glTexSubImage1D(GL_TEXTURE_1D,0,0,4,GL_RGB,GL_FLOAT,tex)
1091
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT),tex)
1092
+
1093
+ # 2d
1094
+ glDrawPixels(2,2,GL_RGB,GL_FLOAT,tex)
1095
+ glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,0,0,2,2,0)
1096
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT),tex)
1097
+
1098
+ glDrawPixels(2,2,GL_RGB,GL_FLOAT,tex2)
1099
+ glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,2,2)
1100
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT),tex2)
1101
+
1102
+ glTexSubImage2D(GL_TEXTURE_2D,0,0,0,2,2,GL_RGB,GL_FLOAT,tex)
1103
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT),tex)
1104
+
1105
+ glDeleteTextures(textures)
1106
+ end
1107
+
1108
+ def test_glmap
1109
+ control_points = [
1110
+ 0.25, 0.5, 0.0,
1111
+ 1.0, 1.0, 0.0
1112
+ ]
1113
+
1114
+ control_points_2 = [
1115
+ 1.25, 1.5, 1.0,
1116
+ 0.0, 0.0, 1.0
1117
+ ]
1118
+
1119
+ glMap1f(GL_MAP1_VERTEX_3,0,100,3,2,control_points)
1120
+ assert_equal(glGetMapfv(GL_MAP1_VERTEX_3,GL_COEFF),control_points)
1121
+
1122
+ glMap1d(GL_MAP1_VERTEX_3,0,100,3,2,control_points_2)
1123
+ assert_equal(glGetMapdv(GL_MAP1_VERTEX_3,GL_COEFF),control_points_2)
1124
+
1125
+ assert_equal(glGetMapiv(GL_MAP1_VERTEX_3,GL_ORDER),2)
1126
+
1127
+ glMap2f(GL_MAP2_VERTEX_3,0,100,3,1,0,100,3,2,control_points)
1128
+ assert_equal(glGetMapfv(GL_MAP2_VERTEX_3,GL_COEFF),control_points)
1129
+
1130
+ glMap2d(GL_MAP2_VERTEX_3,0,100,3,1,0,100,3,2,control_points_2)
1131
+ assert_equal(glGetMapdv(GL_MAP2_VERTEX_3,GL_COEFF),control_points_2)
1132
+ end
1133
+
1134
+ def test_glmapgrid
1135
+ glMapGrid1d(2,1,100)
1136
+ assert_equal(glGetIntegerv(GL_MAP1_GRID_SEGMENTS),2)
1137
+ assert_equal(glGetIntegerv(GL_MAP1_GRID_DOMAIN),[1,100])
1138
+ glMapGrid1f(3,2,99)
1139
+ assert_equal(glGetIntegerv(GL_MAP1_GRID_SEGMENTS),3)
1140
+ assert_equal(glGetIntegerv(GL_MAP1_GRID_DOMAIN),[2,99])
1141
+ #
1142
+ glMapGrid2d(2,1,100,3,2,99)
1143
+ assert_equal(glGetIntegerv(GL_MAP2_GRID_SEGMENTS),[2,3])
1144
+ assert_equal(glGetIntegerv(GL_MAP2_GRID_DOMAIN),[1,100,2,99])
1145
+
1146
+ glMapGrid2f(3,2,99,4,3,98)
1147
+ assert_equal(glGetIntegerv(GL_MAP2_GRID_SEGMENTS),[3,4])
1148
+ assert_equal(glGetIntegerv(GL_MAP2_GRID_DOMAIN),[2,99,3,98])
1149
+ end
1150
+
1151
+ def test_gleval
1152
+ control_points = [0,0,0,1,1,1]
1153
+ glMap1f(GL_MAP1_VERTEX_3,0,1,3,2,control_points)
1154
+ glMap2f(GL_MAP2_VERTEX_3,0,1,3,1,0,1,3,2,control_points)
1155
+ glEnable(GL_MAP1_VERTEX_3)
1156
+ glEnable(GL_MAP2_VERTEX_3)
1157
+
1158
+ buf = glFeedbackBuffer(256,GL_3D)
1159
+ glRenderMode(GL_FEEDBACK)
1160
+
1161
+ glBegin(GL_TRIANGLES)
1162
+ glEvalCoord1d(1.0)
1163
+ glEvalCoord1dv([1.0])
1164
+ glEvalCoord1f(1.0)
1165
+
1166
+ glEvalCoord1fv([1.0])
1167
+ glEvalCoord1fv([1.0])
1168
+ glEvalCoord1fv([1.0])
1169
+
1170
+ glEvalCoord2d(1.0,1.0)
1171
+ glEvalCoord2dv([1.0,1.0])
1172
+ glEvalCoord2f(1.0,1.0)
1173
+
1174
+ glEvalCoord2fv([1.0,1.0])
1175
+ glEvalCoord2fv([1.0,1.0])
1176
+ glEvalCoord2fv([1.0,1.0])
1177
+
1178
+ glEvalPoint1(0.0)
1179
+ glEvalPoint1(0.0)
1180
+ glEvalPoint1(0.0)
1181
+
1182
+ glEvalPoint2(0.0,1.0)
1183
+ glEvalPoint2(0.0,1.0)
1184
+ glEvalPoint2(0.0,1.0)
1185
+
1186
+ glEnd
1187
+
1188
+ count = glRenderMode(GL_RENDER)
1189
+ assert_equal(count,(3*3+2)*6)
1190
+
1191
+ glDisable(GL_MAP2_VERTEX_3)
1192
+ glDisable(GL_MAP1_VERTEX_3)
1193
+ end
1194
+
1195
+ def test_glevalmesh
1196
+ control_points = [0,0,0,1,1,1]
1197
+ glMap1f(GL_MAP1_VERTEX_3,0,1,3,2,control_points)
1198
+ glMap2f(GL_MAP2_VERTEX_3,0,1,3,1,0,1,3,2,control_points)
1199
+ glEnable(GL_MAP1_VERTEX_3)
1200
+ glEnable(GL_MAP2_VERTEX_3)
1201
+
1202
+ buf = glFeedbackBuffer(256,GL_3D)
1203
+ glRenderMode(GL_FEEDBACK)
1204
+
1205
+ glEvalMesh1(GL_POINT,0,1)
1206
+ glEvalMesh2(GL_POINT,0,1,0,1)
1207
+
1208
+ count = glRenderMode(GL_RENDER)
1209
+ assert_equal(count,((3+1)*(2+2*2)))
1210
+
1211
+ glDisable(GL_MAP2_VERTEX_3)
1212
+ glDisable(GL_MAP1_VERTEX_3)
1213
+ end
1214
+
1215
+ def test_glaccum
1216
+ return if glGetIntegerv(GL_ACCUM_RED_BITS) <= 0 # no accumulation buffer ?
1217
+
1218
+ i1 = ([0.0] * 3 + [1.0] * 3 ).pack("f*")
1219
+ i2 = ([1.0] * 3 + [0.0] * 3 ).pack("f*")
1220
+
1221
+ # init
1222
+ glClearColor(0,0,0,0)
1223
+ glClear(GL_ACCUM_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
1224
+ # left
1225
+ glDrawPixels(2,1,GL_RGB,GL_FLOAT,i1)
1226
+ glAccum(GL_ACCUM,1.0)
1227
+ # right
1228
+ glClear(GL_COLOR_BUFFER_BIT)
1229
+ glDrawPixels(2,1,GL_RGB,GL_FLOAT,i2)
1230
+ glAccum(GL_ACCUM,1.0)
1231
+ # combine
1232
+ glAccum(GL_RETURN,1.0)
1233
+
1234
+ data = glReadPixels(0,0,2,1,GL_RGB,GL_FLOAT)
1235
+ assert_each_in_delta [1.0] * 2 * 3, data.unpack("f*"), 0.01
1236
+ end
1237
+
1238
+ def test_displaylists
1239
+ base = glGenLists(2)
1240
+ assert(base>0)
1241
+ glListBase(1)
1242
+ assert_equal(glGetIntegerv(GL_LIST_BASE),1)
1243
+ glListBase(0)
1244
+ assert_equal(glGetIntegerv(GL_LIST_BASE),0)
1245
+
1246
+ glNewList(base+0, GL_COMPILE)
1247
+ glBegin(GL_TRIANGLES)
1248
+ glVertex2f(0,0)
1249
+ glVertex2f(1,0)
1250
+ glVertex2f(1,1)
1251
+ glEnd()
1252
+ glEndList()
1253
+
1254
+ glNewList(base+1, GL_COMPILE)
1255
+ glBegin(GL_TRIANGLES)
1256
+ glVertex2f(0,0)
1257
+ glVertex2f(1,0)
1258
+ glVertex2f(1,1)
1259
+ glEnd()
1260
+ glEndList()
1261
+
1262
+ assert_equal(glIsList(base+0),true)
1263
+ assert_equal(glIsList(base+1),true)
1264
+ assert_equal(glIsList(base+2),false)
1265
+
1266
+ #
1267
+ buf = glFeedbackBuffer(256,GL_3D)
1268
+ glRenderMode(GL_FEEDBACK)
1269
+
1270
+ glCallList(base+0)
1271
+ glCallLists(GL_INT,[base+0,base+1])
1272
+
1273
+ count = glRenderMode(GL_RENDER)
1274
+ assert_equal(count,(3*3+2) * 3) # 3 triangles
1275
+ #
1276
+
1277
+ glDeleteLists(base,2)
1278
+
1279
+ assert_equal(glIsList(base+0),false)
1280
+ assert_equal(glIsList(base+1),false)
1281
+ end
1282
+
1283
+ def test_arrays
1284
+ glEnableClientState(GL_VERTEX_ARRAY)
1285
+
1286
+ va = [0, 0, 0, 1, 1, 1].pack("f*")
1287
+
1288
+ glVertexPointer 2, GL_FLOAT, 0, va
1289
+ assert_equal va, glGetPointerv(GL_VERTEX_ARRAY_POINTER)
1290
+ assert_equal 2, glGetIntegerv(GL_VERTEX_ARRAY_SIZE)
1291
+ assert_equal GL_FLOAT, glGetIntegerv(GL_VERTEX_ARRAY_TYPE)
1292
+ assert_equal 8, glGetIntegerv(GL_VERTEX_ARRAY_STRIDE)
1293
+
1294
+ buf = glFeedbackBuffer(256, GL_3D)
1295
+ glRenderMode(GL_FEEDBACK)
1296
+
1297
+ glDrawArrays(GL_TRIANGLES, 0, 3)
1298
+
1299
+ glBegin(GL_TRIANGLES)
1300
+ glArrayElement(0)
1301
+ glArrayElement(1)
1302
+ glArrayElement(2)
1303
+ glEnd
1304
+
1305
+ glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, [0, 1, 2].pack("C*"))
1306
+
1307
+ glInterleavedArrays(GL_V2F, 0, va)
1308
+
1309
+ glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, [0, 1, 2].pack("C*"))
1310
+
1311
+ count = glRenderMode(GL_RENDER)
1312
+ assert_equal(count, 44)
1313
+
1314
+ glDisableClientState(GL_VERTEX_ARRAY)
1315
+ end
1316
+
1317
+ def test_arrays_2
1318
+ na = [0, 1, 0].pack("f*")
1319
+ ta = [1, 0, 1, 0].pack("f*")
1320
+ ea = [0].pack("C*")
1321
+ ca = [1, 0, 1, 0].pack("f*")
1322
+
1323
+ glNormalPointer(GL_FLOAT, 0, na)
1324
+ assert_equal(GL_FLOAT, glGetIntegerv(GL_NORMAL_ARRAY_TYPE))
1325
+ assert_equal(12, glGetIntegerv(GL_NORMAL_ARRAY_STRIDE))
1326
+ assert_equal(na, glGetPointerv(GL_NORMAL_ARRAY_POINTER))
1327
+
1328
+ glTexCoordPointer(4, GL_FLOAT, 0, ta)
1329
+ assert_equal(4, glGetIntegerv(GL_TEXTURE_COORD_ARRAY_SIZE))
1330
+ assert_equal(GL_FLOAT, glGetIntegerv(GL_TEXTURE_COORD_ARRAY_TYPE))
1331
+ assert_equal(16, glGetIntegerv(GL_TEXTURE_COORD_ARRAY_STRIDE))
1332
+ assert_equal(ta, glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER))
1333
+
1334
+ glEdgeFlagPointer(0, ea)
1335
+ assert_equal(1, glGetIntegerv(GL_EDGE_FLAG_ARRAY_STRIDE))
1336
+ assert_equal(ea, glGetPointerv(GL_EDGE_FLAG_ARRAY_POINTER))
1337
+
1338
+ glColorPointer(4, GL_FLOAT, 0, ca)
1339
+ assert_equal(4, glGetIntegerv(GL_COLOR_ARRAY_SIZE))
1340
+ assert_equal(GL_FLOAT, glGetIntegerv(GL_COLOR_ARRAY_TYPE))
1341
+ assert_equal(16, glGetIntegerv(GL_COLOR_ARRAY_STRIDE))
1342
+ assert_equal(ca, glGetPointerv(GL_COLOR_ARRAY_POINTER))
1343
+
1344
+ glEnableClientState(GL_COLOR_ARRAY)
1345
+ glEnableClientState(GL_NORMAL_ARRAY)
1346
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY)
1347
+ glEnableClientState(GL_EDGE_FLAG_ARRAY)
1348
+
1349
+ glBegin(GL_TRIANGLES)
1350
+ glArrayElement(0)
1351
+ glEnd
1352
+
1353
+ assert_each_in_delta([1, 0, 1, 0], glGetDoublev(GL_CURRENT_COLOR))
1354
+ assert_equal([0, 1, 0], glGetDoublev(GL_CURRENT_NORMAL))
1355
+ assert_equal([1, 0, 1, 0], glGetDoublev(GL_CURRENT_TEXTURE_COORDS))
1356
+ assert_equal(false, glGetBooleanv(GL_EDGE_FLAG))
1357
+
1358
+ glDisableClientState(GL_EDGE_FLAG_ARRAY)
1359
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY)
1360
+ glDisableClientState(GL_NORMAL_ARRAY)
1361
+ glDisableClientState(GL_COLOR_ARRAY)
1362
+ end
1363
+ end