ruby-opengl 0.33.0 → 0.40.0

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