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
@@ -13,21 +13,18 @@
13
13
  # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
14
  #
15
15
 
16
- require 'test/unit'
16
+ require 'opengl/test_case'
17
17
 
18
- class Test_EXT_ATI < Test::Unit::TestCase
19
- def setup
20
- common_setup()
21
- end
18
+ class TestGlExtAti < OpenGL::TestCase
22
19
 
23
- def teardown
24
- common_teardown()
25
- end
20
+ def test_gl_ati_draw_buffers
21
+ supported? "GL_ATI_draw_buffers"
22
+
23
+ glDrawBuffersATI [GL_BACK_LEFT, GL_FRONT_LEFT]
24
+
25
+ assert_equal GL_BACK_LEFT, glGetIntegerv(GL_DRAW_BUFFER0)
26
+ assert_equal GL_FRONT_LEFT, glGetIntegerv(GL_DRAW_BUFFER1)
27
+ end
26
28
 
27
- def test_gl_ati_draw_buffers
28
- return if not supported?("GL_ATI_draw_buffers")
29
- glDrawBuffersATI([GL_BACK_LEFT,GL_FRONT_LEFT])
30
- assert_equal(glGetIntegerv(GL_DRAW_BUFFER0),GL_BACK_LEFT)
31
- assert_equal(glGetIntegerv(GL_DRAW_BUFFER1),GL_FRONT_LEFT)
32
- end
33
29
  end
30
+
@@ -0,0 +1,608 @@
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 TestGlExtExt < OpenGL::TestCase
19
+
20
+ def teardown
21
+ if Gl.is_available?("GL_EXT_framebuffer_object")
22
+ glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0)
23
+ glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0)
24
+ end
25
+
26
+ super
27
+ end
28
+
29
+ def test_gl_ext_polygon_offset
30
+ supported?("GL_EXT_polygon_offset")
31
+
32
+ glPolygonOffsetEXT(1.0, 2.0)
33
+ assert_equal(glGetIntegerv(GL_POLYGON_OFFSET_FACTOR_EXT), 1.0)
34
+ assert_equal(glGetIntegerv(GL_POLYGON_OFFSET_BIAS_EXT), 2.0)
35
+ end
36
+
37
+ def test_gl_ext_framebuffer_object
38
+ supported?("GL_EXT_framebuffer_object")
39
+ t = glGenTextures(3)
40
+ glBindTexture(GL_TEXTURE_2D, t[0])
41
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, WINDOW_SIZE, WINDOW_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil)
42
+
43
+ glBindTexture(GL_TEXTURE_1D, t[1])
44
+ glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA8, WINDOW_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil)
45
+
46
+ glBindTexture(GL_TEXTURE_3D, t[2])
47
+ glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, WINDOW_SIZE, WINDOW_SIZE, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil)
48
+
49
+ fb = glGenFramebuffersEXT(1)
50
+ assert(fb.size==1)
51
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[0])
52
+ assert_equal(glIsFramebufferEXT(fb[0]), true)
53
+
54
+ rb = glGenRenderbuffersEXT(1)
55
+ assert(rb.size==1)
56
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb[0])
57
+ assert_equal(glIsRenderbufferEXT(rb[0]), true)
58
+
59
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, WINDOW_SIZE, WINDOW_SIZE)
60
+
61
+ assert_equal WINDOW_SIZE, glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_WIDTH_EXT)
62
+ assert_equal WINDOW_SIZE, glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_HEIGHT_EXT)
63
+ assert_equal GL_DEPTH_COMPONENT24, glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_INTERNAL_FORMAT_EXT)
64
+
65
+
66
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rb[0]);
67
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, t[0], 0)
68
+
69
+ status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
70
+ assert(status == GL_FRAMEBUFFER_COMPLETE_EXT || status == GL_FRAMEBUFFER_UNSUPPORTED_EXT)
71
+
72
+ assert_equal GL_TEXTURE, glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT)
73
+
74
+ glGenerateMipmapEXT(GL_TEXTURE_2D)
75
+
76
+ glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_1D, t[1], 0)
77
+ glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_3D, t[2], 0, 0)
78
+
79
+ glDeleteRenderbuffersEXT(rb)
80
+ glDeleteFramebuffersEXT(fb)
81
+ glDeleteTextures(t)
82
+ end
83
+
84
+ def test_gl_ext_gpu_program_parameters
85
+ supported?("GL_EXT_gpu_program_parameters")
86
+
87
+ glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, 1, [1, 2, 3, 4, 5, 6, 7, 8])
88
+ assert_equal(glGetProgramEnvParameterdvARB(GL_VERTEX_PROGRAM_ARB, 1), [1, 2, 3, 4])
89
+ assert_equal(glGetProgramEnvParameterdvARB(GL_VERTEX_PROGRAM_ARB, 2), [5, 6, 7, 8])
90
+ end
91
+
92
+ def test_gl_ext_framebuffer_blit
93
+ supported?("GL_EXT_framebuffer_blit")
94
+ fbo = glGenFramebuffersEXT(2)
95
+ texture = glGenTextures(2)
96
+ data = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]
97
+
98
+ glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, fbo[0])
99
+ glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fbo[1])
100
+
101
+ glBindTexture(GL_TEXTURE_2D, texture[0])
102
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, data.pack("C*"))
103
+ glGenerateMipmapEXT(GL_TEXTURE_2D);
104
+
105
+ glBindTexture(GL_TEXTURE_2D, texture[1])
106
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil)
107
+ glGenerateMipmapEXT(GL_TEXTURE_2D);
108
+
109
+ glFramebufferTexture2DEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texture[0], 0)
110
+ glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texture[1], 0)
111
+
112
+ status = glCheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER_EXT)
113
+ assert_equal(status, GL_FRAMEBUFFER_COMPLETE_EXT)
114
+ status = glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT)
115
+ assert_equal(status, GL_FRAMEBUFFER_COMPLETE_EXT)
116
+
117
+ glBlitFramebufferEXT(0, 0, 2, 2,
118
+ 0, 0, 2, 2,
119
+ GL_COLOR_BUFFER_BIT,
120
+ GL_NEAREST)
121
+
122
+ glBindTexture(GL_TEXTURE_2D, texture[1])
123
+ tex = glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE).unpack("C*")
124
+ assert_equal(tex, data)
125
+
126
+ glDeleteTextures(texture)
127
+ glDeleteFramebuffersEXT(fbo)
128
+ end
129
+
130
+ def test_gl_ext_framebuffer_multisample
131
+ supported?("GL_EXT_framebuffer_multisample")
132
+ rb = glGenRenderbuffersEXT(1)[0]
133
+
134
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb)
135
+ glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, 4, GL_RGBA, 2, 2)
136
+ samples = glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_SAMPLES_EXT)
137
+ assert_equal(samples, 4)
138
+
139
+ glDeleteRenderbuffersEXT(rb)
140
+ end
141
+
142
+ def test_gl_ext_pointparameter
143
+ supported?("GL_EXT_point_parameters")
144
+ glPointParameterfEXT(GL_POINT_SIZE_MIN, 1.0)
145
+ assert_equal(glGetDoublev(GL_POINT_SIZE_MIN), 1.0)
146
+
147
+ glPointParameterfvEXT(GL_POINT_DISTANCE_ATTENUATION, [1, 0, 1])
148
+ assert_equal(glGetDoublev(GL_POINT_DISTANCE_ATTENUATION), [1, 0, 1])
149
+ end
150
+
151
+ def test_gl_ext_stencil_two_side
152
+ supported?("GL_EXT_stencil_two_side")
153
+ glActiveStencilFaceEXT(GL_FRONT)
154
+ assert_equal(glGetIntegerv(GL_ACTIVE_STENCIL_FACE_EXT), GL_FRONT)
155
+ glActiveStencilFaceEXT(GL_BACK)
156
+ assert_equal(glGetIntegerv(GL_ACTIVE_STENCIL_FACE_EXT), GL_BACK)
157
+ end
158
+
159
+ def test_gl_ext_stencil_clear_tag
160
+ supported?("GL_EXT_stencil_clear_tag")
161
+ glStencilClearTagEXT(1, 2)
162
+ assert_equal(glGetIntegerv(GL_STENCIL_TAG_BITS_EXT), 1)
163
+ assert_equal(glGetIntegerv(GL_STENCIL_CLEAR_TAG_VALUE_EXT), 2)
164
+ end
165
+
166
+ def test_gl_ext_secondary_color
167
+ supported?("GL_EXT_secondary_color")
168
+
169
+ glSecondaryColor3bEXT(2**7-1, 0, 2**7-1)
170
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
171
+
172
+ glSecondaryColor3bvEXT([0, 2**7-1, 0])
173
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
174
+
175
+ glSecondaryColor3dEXT(1.0, 0.0, 1.0)
176
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
177
+
178
+ glSecondaryColor3dvEXT([0.0, 1.0, 0.0])
179
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
180
+
181
+ glSecondaryColor3fEXT(1.0, 0.0, 1.0)
182
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
183
+
184
+ glSecondaryColor3fvEXT([0.0, 1.0, 0.0])
185
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
186
+
187
+ glSecondaryColor3iEXT(2**31-1, 0, 2**31-1)
188
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
189
+
190
+ glSecondaryColor3ivEXT([0, 2**31-1, 0])
191
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
192
+
193
+ glSecondaryColor3sEXT(2**15-1, 0, 2**15-1)
194
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
195
+
196
+ glSecondaryColor3svEXT([0, 2**15-1, 0])
197
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
198
+
199
+ glSecondaryColor3ubEXT(2**8-1, 0, 2**8-1)
200
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
201
+
202
+ glSecondaryColor3ubvEXT([0, 2**8-1, 0])
203
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
204
+
205
+ glSecondaryColor3uiEXT(2**32-1, 0, 2**32-1)
206
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
207
+
208
+ glSecondaryColor3uivEXT([0, 2**32-1, 0])
209
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
210
+
211
+ glSecondaryColor3usEXT(2**16-1, 0, 2**16-1)
212
+ assert_each_in_delta [1.0, 0.0, 1.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
213
+
214
+ glSecondaryColor3usvEXT([0, 2**16-1, 0])
215
+ assert_each_in_delta [0.0, 1.0, 0.0, 1.0], glGetDoublev(GL_CURRENT_SECONDARY_COLOR)
216
+
217
+ sc = [0, 1, 0, 1, 0, 1].pack("f*")
218
+
219
+ glSecondaryColorPointerEXT(3, GL_FLOAT, 0, sc)
220
+ assert_equal 3, glGetIntegerv(GL_SECONDARY_COLOR_ARRAY_SIZE)
221
+ assert_equal GL_FLOAT, glGetIntegerv(GL_SECONDARY_COLOR_ARRAY_TYPE)
222
+ assert_equal 12, glGetIntegerv(GL_SECONDARY_COLOR_ARRAY_STRIDE)
223
+ assert_equal sc, glGetPointerv(GL_SECONDARY_COLOR_ARRAY_POINTER)
224
+ glEnableClientState(GL_SECONDARY_COLOR_ARRAY)
225
+
226
+ glBegin(GL_TRIANGLES)
227
+ glArrayElement(0)
228
+ glEnd()
229
+
230
+ assert_equal([0, 1, 0, 1], glGetDoublev(GL_CURRENT_SECONDARY_COLOR))
231
+
232
+ glBegin(GL_TRIANGLES)
233
+ glArrayElement(1)
234
+ glEnd()
235
+
236
+ assert_equal([1, 0, 1, 1], glGetDoublev(GL_CURRENT_SECONDARY_COLOR))
237
+
238
+ glDisableClientState(GL_SECONDARY_COLOR_ARRAY)
239
+ end
240
+
241
+ def test_gl_ext_blend_color
242
+ supported?("GL_EXT_blend_color")
243
+ glBlendColorEXT(1.0, 0.0, 1.0, 0.0)
244
+ assert_equal([1, 0, 1, 0], glGetFloatv(GL_BLEND_COLOR_EXT))
245
+ glBlendColorEXT(0.0, 1.0, 0.0, 1.0)
246
+ assert_equal([0, 1, 0, 1], glGetFloatv(GL_BLEND_COLOR_EXT))
247
+ end
248
+
249
+ def test_gl_ext_blend_minmax
250
+ supported?("GL_EXT_blend_minmax")
251
+ glBlendEquationEXT(GL_MIN_EXT)
252
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_EXT), GL_MIN_EXT)
253
+ glBlendEquationEXT(GL_MAX_EXT)
254
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_EXT), GL_MAX_EXT)
255
+ end
256
+
257
+ def test_gl_ext_blend_func_separate
258
+ supported?("GL_EXT_blend_func_separate")
259
+ glBlendFuncSeparateEXT(GL_ZERO, GL_ONE, GL_ZERO, GL_ONE)
260
+ assert_equal(glGetIntegerv(GL_BLEND_SRC_RGB_EXT), GL_ZERO)
261
+ assert_equal(glGetIntegerv(GL_BLEND_DST_RGB_EXT), GL_ONE)
262
+ assert_equal(glGetIntegerv(GL_BLEND_SRC_ALPHA_EXT), GL_ZERO)
263
+ assert_equal(glGetIntegerv(GL_BLEND_DST_ALPHA_EXT), GL_ONE)
264
+ glBlendFuncSeparateEXT(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO)
265
+ assert_equal(glGetIntegerv(GL_BLEND_SRC_RGB_EXT), GL_ONE)
266
+ assert_equal(glGetIntegerv(GL_BLEND_DST_RGB_EXT), GL_ZERO)
267
+ assert_equal(glGetIntegerv(GL_BLEND_SRC_ALPHA_EXT), GL_ONE)
268
+ assert_equal(glGetIntegerv(GL_BLEND_DST_ALPHA_EXT), GL_ZERO)
269
+ end
270
+
271
+ def test_gl_ext_blend_equation_separate
272
+ supported?("GL_EXT_blend_equation_separate")
273
+ glBlendEquationSeparateEXT(GL_FUNC_ADD, GL_FUNC_SUBTRACT)
274
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_RGB_EXT), GL_FUNC_ADD)
275
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_ALPHA_EXT), GL_FUNC_SUBTRACT)
276
+ glBlendEquationSeparateEXT(GL_FUNC_SUBTRACT, GL_FUNC_ADD)
277
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_RGB_EXT), GL_FUNC_SUBTRACT)
278
+ assert_equal(glGetIntegerv(GL_BLEND_EQUATION_ALPHA_EXT), GL_FUNC_ADD)
279
+ end
280
+
281
+ def test_gl_ext_depth_bounds_test
282
+ supported?("GL_EXT_depth_bounds_test")
283
+ glDepthBoundsEXT(0.2, 0.8)
284
+ assert_each_in_delta [0.2, 0.8], glGetDoublev(GL_DEPTH_BOUNDS_EXT)
285
+ end
286
+
287
+ def test_gl_ext_timer_query
288
+ supported?("GL_EXT_timer_query")
289
+ queries = glGenQueries(2)
290
+ glBeginQuery(GL_TIME_ELAPSED_EXT, queries[0])
291
+ glBegin(GL_QUADS)
292
+ glVertex2i(0, 0)
293
+ glVertex2i(0, 1)
294
+ glVertex2i(1, 1)
295
+ glVertex2i(1, 0)
296
+ glEnd
297
+ glEndQuery(GL_TIME_ELAPSED_EXT)
298
+
299
+ while glGetQueryObjectiv(queries[0], GL_QUERY_RESULT_AVAILABLE)==GL_FALSE
300
+ #
301
+ end
302
+ assert(glGetQueryObjecti64vEXT(queries[0], GL_QUERY_RESULT)>0)
303
+ assert(glGetQueryObjectui64vEXT(queries[0], GL_QUERY_RESULT)>0)
304
+
305
+ glDeleteQueries(queries)
306
+ end
307
+
308
+ def test_gl_ext_texture_object
309
+ supported?("GL_EXT_texture_object")
310
+ textures = glGenTexturesEXT(2)
311
+ glBindTextureEXT(GL_TEXTURE_1D, textures[0])
312
+ glBindTextureEXT(GL_TEXTURE_2D, textures[1])
313
+ assert_equal(glIsTextureEXT(textures[0]), true)
314
+ assert_equal(glAreTexturesResidentEXT(textures).size, 2)
315
+
316
+ glPrioritizeTexturesEXT(textures, [0.5, 1.0])
317
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_1D, GL_TEXTURE_PRIORITY), 0.5)
318
+ assert_equal(glGetTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY), 1.0)
319
+
320
+ glDeleteTexturesEXT(textures)
321
+ assert_equal(glIsTextureEXT(textures[0]), false)
322
+ end
323
+
324
+ def test_gl_ext_compiled_vertex_array
325
+ supported?("GL_EXT_compiled_vertex_array")
326
+ glLockArraysEXT(1, 2)
327
+ assert_equal(glGetIntegerv(GL_ARRAY_ELEMENT_LOCK_FIRST_EXT), 1)
328
+ assert_equal(glGetIntegerv(GL_ARRAY_ELEMENT_LOCK_COUNT_EXT), 2)
329
+ glUnlockArraysEXT()
330
+ end
331
+
332
+ def test_gl_ext_fogcoord
333
+ supported?("GL_EXT_fog_coord")
334
+
335
+ glFogCoordfEXT(2.0)
336
+ assert_equal 2.0, glGetDoublev(GL_CURRENT_FOG_COORD)
337
+ glFogCoordfvEXT([3.0])
338
+ assert_equal 3.0, glGetDoublev(GL_CURRENT_FOG_COORD)
339
+
340
+ glFogCoorddEXT(2.0)
341
+ assert_equal 2.0, glGetDoublev(GL_CURRENT_FOG_COORD)
342
+ glFogCoorddvEXT([3.0])
343
+ assert_equal 3.0, glGetDoublev(GL_CURRENT_FOG_COORD)
344
+
345
+ fc = [1, 0].pack("f*")
346
+ glFogCoordPointerEXT(GL_FLOAT, 0, fc)
347
+ assert_equal GL_FLOAT, glGetIntegerv(GL_FOG_COORD_ARRAY_TYPE)
348
+ assert_equal 4, glGetIntegerv(GL_FOG_COORD_ARRAY_STRIDE)
349
+ assert_equal fc, glGetPointerv(GL_FOG_COORD_ARRAY_POINTER)
350
+
351
+ glEnableClientState(GL_FOG_COORD_ARRAY)
352
+
353
+ glBegin(GL_TRIANGLES)
354
+ glArrayElement(0)
355
+ glEnd()
356
+
357
+ assert_equal 1, glGetDoublev(GL_CURRENT_FOG_COORD)
358
+
359
+ glBegin(GL_TRIANGLES)
360
+ glArrayElement(1)
361
+ glEnd()
362
+
363
+ assert_equal 0, glGetDoublev(GL_CURRENT_FOG_COORD)
364
+
365
+ glDisableClientState(GL_FOG_COORD_ARRAY)
366
+ end
367
+
368
+ def test_gl_ext_multi_draw_arrays
369
+ supported?("GL_EXT_multi_draw_arrays")
370
+ va = [0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1].pack("f*")
371
+ glVertexPointer(2, GL_FLOAT, 0, va)
372
+
373
+ glEnableClientState(GL_VERTEX_ARRAY)
374
+
375
+ buf = glFeedbackBuffer(256, GL_3D)
376
+ glRenderMode(GL_FEEDBACK)
377
+
378
+ glMultiDrawArraysEXT(GL_POLYGON, [0, 3], [3, 3])
379
+
380
+ i1 = [0, 1, 2].pack("C*")
381
+ i2 = [3, 4, 5].pack("C*")
382
+ glMultiDrawElementsEXT(GL_TRIANGLES, GL_UNSIGNED_BYTE, [i1, i2])
383
+
384
+ count = glRenderMode(GL_RENDER)
385
+ assert_equal(count, (3*3+2)*4)
386
+ glDisableClientState(GL_VERTEX_ARRAY)
387
+ end
388
+
389
+ def test_gl_ext_drawrangeelements
390
+ supported?("GL_EXT_draw_range_elements")
391
+ va = [0, 0, 0, 1, 1, 1].pack("f*")
392
+ glVertexPointer(2, GL_FLOAT, 0, va)
393
+
394
+ buf = glFeedbackBuffer(256, GL_3D)
395
+ glRenderMode(GL_FEEDBACK)
396
+
397
+ glEnableClientState(GL_VERTEX_ARRAY)
398
+
399
+ glDrawRangeElementsEXT(GL_POINTS, 0, 2, 3, GL_UNSIGNED_BYTE, [0, 1, 2].pack("C*"))
400
+ count = glRenderMode(GL_RENDER)
401
+ assert_equal(count, 12)
402
+
403
+ glDisableClientState(GL_VERTEX_ARRAY)
404
+ end
405
+
406
+ def test_gl_ext_geometry_shader4
407
+ supported?("GL_EXT_geometry_shader4")
408
+ program = glCreateProgramObjectARB()
409
+
410
+ glProgramParameteriEXT(program, GL_GEOMETRY_INPUT_TYPE_EXT , GL_LINES_ADJACENCY_EXT)
411
+ assert_equal(glGetObjectParameterivARB(program, GL_GEOMETRY_INPUT_TYPE_EXT), GL_LINES_ADJACENCY_EXT)
412
+
413
+ glDeleteObjectARB(program)
414
+ end
415
+
416
+ def test_gl_ext_gpu_shader4
417
+ supported?(["GL_EXT_gpu_shader4", "GL_ARB_vertex_program"])
418
+
419
+ programs = glGenProgramsARB(1)
420
+ program = "!!ARBvp1.0\nTEMP vv;\nEND"
421
+
422
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, programs[0])
423
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, program)
424
+
425
+ glVertexAttribI1iEXT(1, 1)
426
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0], 1)
427
+ glVertexAttribI1uiEXT(1, 2)
428
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0], 2)
429
+ glVertexAttribI1ivEXT(1, [3])
430
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0], 3)
431
+ glVertexAttribI1uivEXT(1, [4])
432
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0], 4)
433
+
434
+ glVertexAttribI2iEXT(1, 1, 2)
435
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0, 2], [1, 2])
436
+ glVertexAttribI2uiEXT(1, 2, 3)
437
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0, 2], [2, 3])
438
+ glVertexAttribI2ivEXT(1, [3, 4])
439
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0, 2], [3, 4])
440
+ glVertexAttribI2uivEXT(1, [4, 5])
441
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0, 2], [4, 5])
442
+
443
+ glVertexAttribI3iEXT(1, 1, 2, 3)
444
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0, 3], [1, 2, 3])
445
+ glVertexAttribI3uiEXT(1, 2, 3, 4)
446
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0, 3], [2, 3, 4])
447
+ glVertexAttribI3ivEXT(1, [3, 4, 5])
448
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0, 3], [3, 4, 5])
449
+ glVertexAttribI3uivEXT(1, [4, 5, 6])
450
+ assert_equal(glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)[0, 3], [4, 5, 6])
451
+
452
+ glVertexAttribI4iEXT(1, 1, 2, 3, 4)
453
+ assert_equal [1, 2, 3, 4], glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)
454
+ glVertexAttribI4uiEXT(1, 2, 3, 4, 5)
455
+ assert_equal [2, 3, 4, 5], glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)
456
+ glVertexAttribI4ivEXT(1, [3, 4, 5, 6])
457
+ assert_equal [3, 4, 5, 6], glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)
458
+ glVertexAttribI4uivEXT(1, [4, 5, 6, 7])
459
+ assert_equal [4, 5, 6, 7], glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)
460
+
461
+ glVertexAttribI4bvEXT(1, [1, 2, 3, 4])
462
+ assert_equal [1, 2, 3, 4], glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)
463
+ glVertexAttribI4svEXT(1, [2, 3, 4, 5])
464
+ assert_equal [2, 3, 4, 5], glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)
465
+ glVertexAttribI4ubvEXT(1, [1, 2, 3, 4])
466
+ assert_equal [1, 2, 3, 4], glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)
467
+ glVertexAttribI4usvEXT(1, [2, 3, 4, 5])
468
+ assert_equal [2, 3, 4, 5], glGetVertexAttribIivEXT(1, GL_CURRENT_VERTEX_ATTRIB_ARB)
469
+
470
+ glVertexAttribIPointerEXT(1, 2, GL_INT, 0, [1, 1].pack("i*"))
471
+ assert_equal [1, 1].pack("i*"), glGetVertexAttribPointervARB(1)
472
+
473
+ glDeleteProgramsARB(programs)
474
+ end
475
+
476
+ def test_gl_ext_gpu_shader4_2
477
+ supported?(["GL_EXT_gpu_shader4", "GL_ARB_shader_objects"])
478
+
479
+ vertex_shader_source = <<-SHADER
480
+ uniform int testivec1;
481
+ uniform ivec2 testivec2;
482
+ uniform ivec3 testivec3;
483
+ uniform ivec4 testivec4;
484
+ void main() {
485
+ testivec1;
486
+ testivec2;
487
+ testivec3;
488
+ testivec4;
489
+
490
+ gl_Position = ftransform();
491
+ }
492
+ SHADER
493
+
494
+ program = glCreateProgramObjectARB()
495
+ vs = glCreateShaderObjectARB(GL_VERTEX_SHADER)
496
+ glShaderSourceARB(vs, vertex_shader_source)
497
+
498
+ glCompileShaderARB(vs)
499
+ assert(glGetObjectParameterivARB(vs, GL_OBJECT_COMPILE_STATUS_ARB),
500
+ glGetInfoLogARB(vs))
501
+
502
+ glAttachObjectARB(program, vs)
503
+ glLinkProgramARB(program)
504
+ assert glGetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB)
505
+ glUseProgramObjectARB(program)
506
+
507
+ tv1il = glGetUniformLocation program, "testivec1"
508
+ refute_equal -1, tv1il, "testivec1 missing!"
509
+
510
+ tv2il = glGetUniformLocation program, "testivec2"
511
+ refute_equal -1, tv2il, "testivec2 missing!"
512
+
513
+ tv3il = glGetUniformLocation program, "testivec3"
514
+ refute_equal -1, tv3il, "testivec3 missing!"
515
+
516
+ tv4il = glGetUniformLocation program, "testivec4"
517
+ refute_equal -1, tv4il, "testivec4 missing!"
518
+
519
+ skip "glGetUniformLocation is broken" if
520
+ glGetActiveUniform(program, tv1il).last != "testivec1"
521
+
522
+ skip "glGetUniformLocation is broken" if
523
+ glGetActiveUniform(program, tv2il).last != "testivec2"
524
+
525
+ skip "glGetUniformLocation is broken" if
526
+ glGetActiveUniform(program, tv3il).last != "testivec3"
527
+
528
+ skip "glGetUniformLocation is broken" if
529
+ glGetActiveUniform(program, tv4il).last != "testivec4"
530
+
531
+ skip "can't find documentation for glUniform1uiEXT"
532
+ glUniform1uiEXT(tv1il, 3)
533
+ assert_equal 3, glGetUniformuivEXT(program, tv1il)
534
+
535
+ glUniform1uivEXT(tv1il, [4])
536
+ assert_equal 4, glGetUniformuivEXT(program, tv1il)
537
+
538
+ glUniform2uiEXT(tv2il, 1, 2)
539
+ assert_equal [1, 2], glGetUniformuivEXT(program, tv2il)
540
+
541
+ glUniform2uivEXT(tv2il, [3, 4])
542
+ assert_equal [3, 4], glGetUniformuivEXT(program, tv2il)
543
+
544
+ glUniform3uiEXT(tv3il, 1, 2, 3)
545
+ assert_equal [1, 2, 3], glGetUniformuivEXT(program, tv3il)
546
+
547
+ glUniform3uivEXT(tv3il, [3, 4, 5])
548
+ assert_equal [3, 4, 5], glGetUniformuivEXT(program, tv3il)
549
+
550
+ glUniform4uiEXT(tv4il, 1, 2, 3, 4)
551
+ assert_equal [1, 2, 3, 4], glGetUniformuivEXT(program, tv4il)
552
+
553
+ glUniform4uivEXT(tv4il, [3, 4, 5, 6])
554
+ assert_equal [3, 4, 5, 6], glGetUniformuivEXT(program, tv4il)
555
+
556
+ glBindFragDataLocationEXT(program, 1, "test")
557
+ assert_equal -1, glGetFragDataLocationEXT(program, "test")
558
+ end
559
+
560
+ def test_gl_ext_draw_instanced
561
+ supported?("GL_EXT_draw_instanced")
562
+
563
+ glEnableClientState(GL_VERTEX_ARRAY)
564
+
565
+ va = [0, 0, 0, 1, 1, 1].pack("f*")
566
+ glVertexPointer(2, GL_FLOAT, 0, va)
567
+
568
+ buf = glFeedbackBuffer(256, GL_3D)
569
+ glRenderMode(GL_FEEDBACK)
570
+
571
+ glDrawArraysInstancedEXT(GL_TRIANGLES, 0, 3, 2)
572
+
573
+ glDrawElementsInstancedEXT(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, [0, 1, 2].pack("C*"), 2)
574
+ count = glRenderMode(GL_RENDER)
575
+ assert_equal(count, 2*2*11)
576
+
577
+ glDisableClientState(GL_VERTEX_ARRAY)
578
+ end
579
+
580
+ def test_gl_ext_texture_buffer_object
581
+ supported?("GL_EXT_texture_buffer_object")
582
+
583
+ buf = glGenBuffers(1)[0]
584
+ glBindBuffer(GL_TEXTURE_BUFFER_EXT, buf)
585
+
586
+ tex = glGenTextures(1)[0]
587
+ glBindTexture(GL_TEXTURE_BUFFER_EXT, tex)
588
+ glTexBufferEXT(GL_TEXTURE_BUFFER_EXT, GL_RGBA32F_ARB, buf)
589
+
590
+ assert_equal(glGetIntegerv(GL_TEXTURE_BINDING_BUFFER_EXT), tex)
591
+ assert_equal(glGetIntegerv(GL_TEXTURE_BUFFER_FORMAT_EXT), GL_RGBA32F_ARB)
592
+
593
+ glDeleteBuffers(buf)
594
+ glDeleteTextures(tex)
595
+ end
596
+
597
+ def test_gl_ext_texture_integer
598
+ supported?("GL_EXT_texture_integer")
599
+
600
+ glClearColorIiEXT(1, 2, 3, 4)
601
+ glClearColorIuiEXT(1, 2, 3, 4)
602
+
603
+ glTexParameterIivEXT(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, [1, 2, 3, 4])
604
+ assert_equal(glGetTexParameterIivEXT(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR), [1, 2, 3, 4])
605
+ glTexParameterIuivEXT(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, [5, 6, 7, 8])
606
+ assert_equal(glGetTexParameterIuivEXT(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR), [5, 6, 7, 8])
607
+ end
608
+ end