opengl 0.7.0.pre1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +8 -0
  3. data/History.txt +36 -0
  4. data/MIT-LICENSE +18 -0
  5. data/Manifest.txt +140 -0
  6. data/README.rdoc +51 -0
  7. data/Rakefile +129 -0
  8. data/Rakefile.cross +104 -0
  9. data/doc/build_install.txt +119 -0
  10. data/doc/extensions.txt.in +348 -0
  11. data/doc/history.txt +66 -0
  12. data/doc/requirements_and_design.txt +117 -0
  13. data/doc/roadmap.txt +28 -0
  14. data/doc/scientific_use.txt +35 -0
  15. data/doc/supplies/page_template.html +71 -0
  16. data/doc/thanks.txt +29 -0
  17. data/doc/tutorial.txt +469 -0
  18. data/examples/NeHe/nehe_lesson02.rb +117 -0
  19. data/examples/NeHe/nehe_lesson03.rb +122 -0
  20. data/examples/NeHe/nehe_lesson04.rb +133 -0
  21. data/examples/NeHe/nehe_lesson05.rb +186 -0
  22. data/examples/NeHe/nehe_lesson36.rb +303 -0
  23. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  24. data/examples/OrangeBook/brick.frag +36 -0
  25. data/examples/OrangeBook/brick.rb +376 -0
  26. data/examples/OrangeBook/brick.vert +41 -0
  27. data/examples/OrangeBook/particle.frag +17 -0
  28. data/examples/OrangeBook/particle.rb +406 -0
  29. data/examples/OrangeBook/particle.vert +38 -0
  30. data/examples/README +16 -0
  31. data/examples/RedBook/aapoly.rb +142 -0
  32. data/examples/RedBook/aargb.rb +119 -0
  33. data/examples/RedBook/accanti.rb +162 -0
  34. data/examples/RedBook/accpersp.rb +215 -0
  35. data/examples/RedBook/alpha.rb +123 -0
  36. data/examples/RedBook/alpha3D.rb +158 -0
  37. data/examples/RedBook/bezcurve.rb +105 -0
  38. data/examples/RedBook/bezmesh.rb +137 -0
  39. data/examples/RedBook/checker.rb +124 -0
  40. data/examples/RedBook/clip.rb +95 -0
  41. data/examples/RedBook/colormat.rb +135 -0
  42. data/examples/RedBook/cube.rb +69 -0
  43. data/examples/RedBook/depthcue.rb +99 -0
  44. data/examples/RedBook/dof.rb +205 -0
  45. data/examples/RedBook/double.rb +105 -0
  46. data/examples/RedBook/drawf.rb +91 -0
  47. data/examples/RedBook/feedback.rb +145 -0
  48. data/examples/RedBook/fog.rb +167 -0
  49. data/examples/RedBook/font.rb +151 -0
  50. data/examples/RedBook/hello.rb +79 -0
  51. data/examples/RedBook/image.rb +137 -0
  52. data/examples/RedBook/jitter.rb +207 -0
  53. data/examples/RedBook/lines.rb +128 -0
  54. data/examples/RedBook/list.rb +111 -0
  55. data/examples/RedBook/material.rb +275 -0
  56. data/examples/RedBook/mipmap.rb +156 -0
  57. data/examples/RedBook/model.rb +113 -0
  58. data/examples/RedBook/movelight.rb +132 -0
  59. data/examples/RedBook/pickdepth.rb +179 -0
  60. data/examples/RedBook/planet.rb +108 -0
  61. data/examples/RedBook/quadric.rb +158 -0
  62. data/examples/RedBook/robot.rb +115 -0
  63. data/examples/RedBook/select.rb +196 -0
  64. data/examples/RedBook/smooth.rb +95 -0
  65. data/examples/RedBook/stencil.rb +163 -0
  66. data/examples/RedBook/stroke.rb +167 -0
  67. data/examples/RedBook/surface.rb +166 -0
  68. data/examples/RedBook/teaambient.rb +132 -0
  69. data/examples/RedBook/teapots.rb +182 -0
  70. data/examples/RedBook/tess.rb +183 -0
  71. data/examples/RedBook/texbind.rb +147 -0
  72. data/examples/RedBook/texgen.rb +169 -0
  73. data/examples/RedBook/texturesurf.rb +128 -0
  74. data/examples/RedBook/varray.rb +159 -0
  75. data/examples/RedBook/wrap.rb +148 -0
  76. data/examples/misc/OGLBench.rb +337 -0
  77. data/examples/misc/anisotropic.rb +194 -0
  78. data/examples/misc/fbo_test.rb +356 -0
  79. data/examples/misc/font-glut.rb +46 -0
  80. data/examples/misc/glfwtest.rb +30 -0
  81. data/examples/misc/plane.rb +161 -0
  82. data/examples/misc/readpixel.rb +65 -0
  83. data/examples/misc/sdltest.rb +34 -0
  84. data/examples/misc/trislam.rb +828 -0
  85. data/ext/common/common.h +448 -0
  86. data/ext/common/conv.h +234 -0
  87. data/ext/common/funcdef.h +280 -0
  88. data/ext/common/gl-enums.h +10031 -0
  89. data/ext/common/gl-error.h +23 -0
  90. data/ext/common/gl-types.h +67 -0
  91. data/ext/common/glu-enums.h +463 -0
  92. data/ext/gl/extconf.rb +43 -0
  93. data/ext/gl/gl-1.0-1.1.c +2811 -0
  94. data/ext/gl/gl-1.2.c +814 -0
  95. data/ext/gl/gl-1.3.c +443 -0
  96. data/ext/gl/gl-1.4.c +348 -0
  97. data/ext/gl/gl-1.5.c +225 -0
  98. data/ext/gl/gl-2.0.c +657 -0
  99. data/ext/gl/gl-2.1.c +57 -0
  100. data/ext/gl/gl-enums.c +3354 -0
  101. data/ext/gl/gl-error.c +104 -0
  102. data/ext/gl/gl-ext-3dfx.c +27 -0
  103. data/ext/gl/gl-ext-arb.c +866 -0
  104. data/ext/gl/gl-ext-ati.c +41 -0
  105. data/ext/gl/gl-ext-ext.c +889 -0
  106. data/ext/gl/gl-ext-gremedy.c +41 -0
  107. data/ext/gl/gl-ext-nv.c +679 -0
  108. data/ext/gl/gl.c +216 -0
  109. data/ext/glu/extconf.rb +51 -0
  110. data/ext/glu/glu-enums.c +164 -0
  111. data/ext/glu/glu.c +1530 -0
  112. data/ext/glut/extconf.rb +67 -0
  113. data/ext/glut/glut.c +1624 -0
  114. data/lib/opengl.rb +89 -0
  115. data/test/README +10 -0
  116. data/test/tc_common.rb +98 -0
  117. data/test/tc_ext_arb.rb +467 -0
  118. data/test/tc_ext_ati.rb +33 -0
  119. data/test/tc_ext_ext.rb +551 -0
  120. data/test/tc_ext_gremedy.rb +36 -0
  121. data/test/tc_ext_nv.rb +357 -0
  122. data/test/tc_func_10_11.rb +1281 -0
  123. data/test/tc_func_12.rb +186 -0
  124. data/test/tc_func_13.rb +229 -0
  125. data/test/tc_func_14.rb +197 -0
  126. data/test/tc_func_15.rb +270 -0
  127. data/test/tc_func_20.rb +346 -0
  128. data/test/tc_func_21.rb +541 -0
  129. data/test/tc_glu.rb +310 -0
  130. data/test/tc_include_gl.rb +35 -0
  131. data/test/tc_misc.rb +54 -0
  132. data/test/tc_require_gl.rb +34 -0
  133. data/utils/README +11 -0
  134. data/utils/enumgen.rb +112 -0
  135. data/utils/extlistgen.rb +90 -0
  136. data/utils/mkdn2html.rb +59 -0
  137. data/utils/post-mkdn2html.rb +91 -0
  138. data/website/images/ogl.jpg +0 -0
  139. data/website/images/tab_bottom.gif +0 -0
  140. data/website/style.css +198 -0
  141. metadata +274 -0
@@ -0,0 +1,541 @@
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_21 < Test::Unit::TestCase
19
+ def setup
20
+ common_setup()
21
+ end
22
+
23
+ def teardown
24
+ common_teardown()
25
+ end
26
+
27
+ def test_gluniformmatrix21
28
+ return if not supported?(2.1)
29
+
30
+ vertex_shader_source = "#version 120\n uniform mat2x3 testmat23; uniform mat3x2 testmat32; uniform mat2x4 testmat24; uniform mat4x2 testmat42; uniform mat3x4 testmat34; uniform mat4x3 testmat43; void main() { gl_Position = gl_Vertex * testmat23[0].x * testmat32[0].x * testmat24[0].x * testmat42[0].x * testmat34[0].x * testmat43[0].x;}"
31
+
32
+ program = glCreateProgram()
33
+ vs = glCreateShader(GL_VERTEX_SHADER)
34
+
35
+ glShaderSource(vs,vertex_shader_source)
36
+ glCompileShader(vs)
37
+
38
+ assert_equal(glGetShaderiv(vs,GL_COMPILE_STATUS),GL_TRUE)
39
+ glAttachShader(program,vs)
40
+
41
+ glLinkProgram(program)
42
+ assert_equal(glGetProgramiv(program,GL_LINK_STATUS),GL_TRUE)
43
+ glUseProgram(program)
44
+
45
+ assert((tm23l = glGetUniformLocation(program,"testmat23"))>=0)
46
+ assert((tm32l = glGetUniformLocation(program,"testmat32"))>=0)
47
+ assert((tm24l = glGetUniformLocation(program,"testmat24"))>=0)
48
+ assert((tm42l = glGetUniformLocation(program,"testmat42"))>=0)
49
+ assert((tm34l = glGetUniformLocation(program,"testmat34"))>=0)
50
+ assert((tm43l = glGetUniformLocation(program,"testmat43"))>=0)
51
+
52
+ glUniformMatrix2x3fv(tm23l, GL_FALSE, [0,1, 1,0, 0,1])
53
+ assert_equal(glGetUniformfv(program,tm23l),[0,1, 1,0, 0,1])
54
+ glUniformMatrix3x2fv(tm32l, GL_FALSE, [1,0, 0,1, 1,0])
55
+ assert_equal(glGetUniformfv(program,tm32l),[1,0, 0,1, 1,0])
56
+
57
+ glUniformMatrix2x4fv(tm24l, GL_FALSE, [0,1, 1,0, 0,1, 1,0])
58
+ assert_equal(glGetUniformfv(program,tm24l),[0,1, 1,0, 0,1, 1,0])
59
+ glUniformMatrix4x2fv(tm42l, GL_FALSE, [1,0, 0,1, 1,0, 0,1])
60
+ assert_equal(glGetUniformfv(program,tm42l),[1,0, 0,1, 1,0, 0,1])
61
+
62
+ glUniformMatrix3x4fv(tm34l, GL_FALSE, [0,1,1, 1,0,1, 0,1,1, 1,0,1])
63
+ assert_equal(glGetUniformfv(program,tm34l),[0,1,1, 1,0,1, 0,1,1, 1,0,1])
64
+ glUniformMatrix4x3fv(tm43l, GL_FALSE, [1,0,0, 0,1,0, 1,0,0, 0,1,0])
65
+ assert_equal(glGetUniformfv(program,tm43l),[1,0,0, 0,1,0, 1,0,0, 0,1,0])
66
+
67
+ # 2
68
+ m = Matrix.rows([[0,1],[1,0],[0,1]])
69
+ glUniformMatrix2x3fv(tm23l, GL_FALSE, m)
70
+ assert_equal(glGetUniformfv(program,tm23l),[0,1, 1,0, 0,1])
71
+ m = Matrix.rows([[0,1,1],[0,0,1]])
72
+ glUniformMatrix3x2fv(tm32l, GL_FALSE, m)
73
+ assert_equal(glGetUniformfv(program,tm32l),[0,1,1, 0,0,1])
74
+
75
+ m = Matrix.rows([[0,1],[1,0],[0,1],[1,0]])
76
+ glUniformMatrix2x4fv(tm24l, GL_FALSE, m)
77
+ assert_equal(glGetUniformfv(program,tm24l),[0,1, 1,0, 0,1, 1,0])
78
+ m = Matrix.rows([[0,1,1,1],[0,0,1,1]])
79
+ glUniformMatrix4x2fv(tm42l, GL_FALSE, m)
80
+ assert_equal(glGetUniformfv(program,tm42l),[0,1,1,1, 0,0,1,1])
81
+
82
+ m = Matrix.rows([[0,1,0],[1,0,1],[0,1,0],[1,0,1]])
83
+ glUniformMatrix3x4fv(tm34l, GL_FALSE, m)
84
+ assert_equal(glGetUniformfv(program,tm34l),[0,1,0, 1,0,1, 0,1,0, 1,0,1])
85
+
86
+ m = Matrix.rows([[0,1,1,1],[0,0,1,1],[1,1,0,0]])
87
+ glUniformMatrix4x3fv(tm43l, GL_FALSE, m)
88
+ assert_equal(glGetUniformfv(program,tm43l),[0,1,1,1, 0,0,1,1, 1,1,0,0])
89
+
90
+ # 3
91
+ assert_raise ArgumentError do glUniformMatrix2x3fv(tm23l, GL_FALSE, [1,2,3,4]) end
92
+ assert_raise ArgumentError do glUniformMatrix3x2fv(tm32l, GL_FALSE, [1,2,3,4]) end
93
+ assert_raise ArgumentError do glUniformMatrix2x4fv(tm24l, GL_FALSE, [1,2,3,4]) end
94
+ assert_raise ArgumentError do glUniformMatrix4x2fv(tm42l, GL_FALSE, [1,2,3,4]) end
95
+ assert_raise ArgumentError do glUniformMatrix3x4fv(tm34l, GL_FALSE, [1,2,3,4]) end
96
+ assert_raise ArgumentError do glUniformMatrix4x3fv(tm43l, GL_FALSE, [1,2,3,4]) end
97
+ end
98
+
99
+ def test_pixelunpack_bitmap
100
+ return if not supported?(2.1)
101
+ glOrtho(0,$window_size,0,$window_size,0,-1)
102
+
103
+ bitmap = [ 0x55 ] * 8 # 64 bits (8x8 bitmap), stipple pattern
104
+ glPixelStorei(GL_PACK_ALIGNMENT,1)
105
+ glPixelStorei(GL_UNPACK_ALIGNMENT,1)
106
+
107
+ buffers = glGenBuffers(1)
108
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
109
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,8,bitmap.pack("C*"),GL_DYNAMIC_DRAW)
110
+
111
+ glBitmap(8,8,0,0,0,0,0)
112
+ data = glReadPixels(0,0,8,8,GL_RED,GL_UNSIGNED_BYTE)
113
+ assert_equal(data.unpack("C*"),[0,255] * 32)
114
+
115
+ glDeleteBuffers(buffers)
116
+ end
117
+
118
+ def test_pixelunpack_color_convolution
119
+ return if not supported?(2.1)
120
+
121
+ ct = ([0]*3+[1]*3+[0]*3+[1]*3).pack("f*")
122
+ ct2 = ([1]*3+[0]*3+[1]*3+[0]*3).pack("f*")
123
+
124
+ buffers = glGenBuffers(2)
125
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
126
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,4*3*4,ct,GL_DYNAMIC_DRAW)
127
+
128
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
129
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,4*3*4,ct2,GL_DYNAMIC_DRAW)
130
+
131
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
132
+ glColorTable(GL_COLOR_TABLE,GL_RGB8,4,GL_RGB,GL_FLOAT,0)
133
+ assert_equal(glGetColorTable(GL_COLOR_TABLE,GL_RGB,GL_FLOAT),ct)
134
+ glConvolutionFilter1D(GL_CONVOLUTION_1D, GL_RGB8, 4, GL_RGB, GL_FLOAT,0)
135
+ assert_equal(glGetConvolutionFilter(GL_CONVOLUTION_1D, GL_RGB, GL_FLOAT),ct)
136
+
137
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
138
+ glColorSubTable(GL_COLOR_TABLE,0,4,GL_RGB,GL_FLOAT,0)
139
+ assert_equal(glGetColorTable(GL_COLOR_TABLE,GL_RGB,GL_FLOAT),ct2)
140
+ glConvolutionFilter2D(GL_CONVOLUTION_2D, GL_RGB8, 2,2, GL_RGB, GL_FLOAT,0)
141
+ assert_equal(glGetConvolutionFilter(GL_CONVOLUTION_2D, GL_RGB, GL_FLOAT),ct2)
142
+
143
+ glDeleteBuffers(buffers)
144
+ end
145
+
146
+ def test_pixelunpack_separable
147
+ return if not supported?(2.1)
148
+
149
+ sf_a = ([0]*3+[1]*3).pack("f*")
150
+ sf_b = ([1]*3+[0]*3).pack("f*")
151
+
152
+ buffers = glGenBuffers(1)
153
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
154
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,2*3*4 *2,sf_a + sf_b,GL_DYNAMIC_DRAW)
155
+
156
+ glSeparableFilter2D(GL_SEPARABLE_2D,GL_RGB8, 2,2,GL_RGB,GL_FLOAT,0,2*3*4)
157
+ assert_equal(glGetSeparableFilter(GL_SEPARABLE_2D,GL_RGB,GL_FLOAT), [sf_a,sf_b])
158
+
159
+ glDeleteBuffers(buffers)
160
+ end
161
+
162
+ def test_pixelunpack_drawpixels
163
+ return if not supported?(2.1)
164
+
165
+ glClearColor(0,0,0,0)
166
+ glClear(GL_COLOR_BUFFER_BIT)
167
+
168
+ image = ([1.0] * 3 * 16).pack("f*")
169
+
170
+ buffers = glGenBuffers(1)
171
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
172
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,3*16*4,image,GL_DYNAMIC_DRAW)
173
+
174
+ glDrawPixels(4,4,GL_RGB,GL_FLOAT,0)
175
+
176
+ data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
177
+ assert_equal(data,image)
178
+
179
+ glDeleteBuffers(buffers)
180
+ end
181
+
182
+ def test_pixelunpack_polygonstipple
183
+ return if not supported?(2.1)
184
+
185
+ stipple = ([0x12] * 128).pack("c*")
186
+ buffers = glGenBuffers(1)
187
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
188
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,128,stipple,GL_DYNAMIC_DRAW)
189
+
190
+ glPolygonStipple(0)
191
+ assert_equal(glGetPolygonStipple(),stipple)
192
+ glDeleteBuffers(buffers)
193
+ end
194
+
195
+
196
+ def test_pixelunpack_texturecompression
197
+ return if not supported?(2.1)
198
+ return if not supported?("GL_EXT_texture_compression_s3tc")
199
+
200
+ # S3TC/DXT5 compressed 2x2 pixels stipple patterns [w,b,b,w] and [b,w,w,b]
201
+ image_1 = [0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x01,0x54,0x5C,0x5C].pack("C*")
202
+ image_2 = [0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x54,0x01,0x0D,0x0D].pack("C*")
203
+
204
+ textures = glGenTextures(3)
205
+ glBindTexture(GL_TEXTURE_1D,textures[0])
206
+ glBindTexture(GL_TEXTURE_2D,textures[1])
207
+ glBindTexture(GL_TEXTURE_3D,textures[2])
208
+
209
+ buffers = glGenBuffers(2)
210
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
211
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,16,image_1,GL_DYNAMIC_DRAW)
212
+
213
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
214
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,16,image_2,GL_DYNAMIC_DRAW)
215
+
216
+ # Note: 1D and 3D compressed textures are not supported by S3TC/DXTn, and usually not supported at all
217
+
218
+ # 1D
219
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
220
+ begin
221
+ glCompressedTexImage1D(GL_TEXTURE_1D,0,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,4,0,16,0)
222
+ assert_equal(glGetCompressedTexImage(GL_TEXTURE_1D,0), image_1)
223
+ rescue Gl::Error => err
224
+ assert(err.id == GL_INVALID_ENUM || err.id == GL_INVALID_OPERATION)
225
+ end
226
+
227
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
228
+ begin
229
+ glCompressedTexSubImage1D(GL_TEXTURE_1D,0,0,4,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,16,0)
230
+ assert_equal(glGetCompressedTexImage(GL_TEXTURE_1D,0), image_2)
231
+ rescue Gl::Error => err
232
+ assert(err.id == GL_INVALID_ENUM || err.id == GL_INVALID_OPERATION)
233
+ end
234
+
235
+ # 2D
236
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
237
+ glCompressedTexImage2D(GL_TEXTURE_2D,0,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,2,2,0,16,0)
238
+ assert_equal(glGetCompressedTexImage(GL_TEXTURE_2D,0), image_1)
239
+
240
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
241
+ glCompressedTexSubImage2D(GL_TEXTURE_2D,0,0,0,2,2,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,16,0)
242
+ assert_equal(glGetCompressedTexImage(GL_TEXTURE_2D,0), image_2)
243
+
244
+ # 3D
245
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
246
+ begin
247
+ glCompressedTexImage3D(GL_TEXTURE_3D,0,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,2,2,1,0,16,0)
248
+ assert_equal(glGetCompressedTexImage(GL_TEXTURE_3D,0), image_1)
249
+ rescue Gl::Error => err
250
+ assert(err.id == GL_INVALID_ENUM || err.id == GL_INVALID_OPERATION)
251
+ end
252
+
253
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
254
+ begin
255
+ glCompressedTexSubImage3D(GL_TEXTURE_3D,0, 0,0,0, 2,2,1, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 16, 0)
256
+ assert_equal(glGetCompressedTexImage(GL_TEXTURE_3D,0), image_2)
257
+ rescue Gl::Error => err
258
+ assert(err.id == GL_INVALID_ENUM || err.id == GL_INVALID_OPERATION)
259
+ end
260
+
261
+ glDeleteBuffers(buffers)
262
+ glDeleteTextures(textures)
263
+ end
264
+
265
+ def test_pixelunpack_texture
266
+ return if not supported?(2.1)
267
+
268
+ textures = glGenTextures(3)
269
+ image_1 = ([0,0,0,1,1,1] * 8).pack("f*") # 16 RGB pixels
270
+ image_2 = ([1,1,1,0,0,0] * 8).pack("f*") # 16 RGB pixels
271
+
272
+ buffers = glGenBuffers(2)
273
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
274
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,6*8*4,image_1,GL_DYNAMIC_DRAW)
275
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
276
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,6*8*4,image_2,GL_DYNAMIC_DRAW)
277
+
278
+ # 3D
279
+ glBindTexture(GL_TEXTURE_3D,textures[0])
280
+
281
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
282
+ glTexImage3D(GL_TEXTURE_3D,0,GL_RGB8,2,2,4,0,GL_RGB,GL_FLOAT,0)
283
+ assert_equal(glGetTexImage(GL_TEXTURE_3D,0,GL_RGB,GL_FLOAT),image_1)
284
+
285
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
286
+ glTexSubImage3D(GL_TEXTURE_3D,0, 0,0,0, 2,2,4,GL_RGB,GL_FLOAT,0)
287
+ assert_equal(glGetTexImage(GL_TEXTURE_3D,0,GL_RGB,GL_FLOAT),image_2)
288
+
289
+ # 2D
290
+ glBindTexture(GL_TEXTURE_2D,textures[1])
291
+
292
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
293
+ glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8, 4, 4, 0, GL_RGB, GL_FLOAT, 0)
294
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT), image_1)
295
+
296
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
297
+ glTexSubImage2D(GL_TEXTURE_2D,0, 0,0, 4,4,GL_RGB,GL_FLOAT,0)
298
+ assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT),image_2)
299
+
300
+ # 1D
301
+ glBindTexture(GL_TEXTURE_1D,textures[2])
302
+
303
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
304
+
305
+ glTexImage1D(GL_TEXTURE_1D,0,GL_RGB8, 16, 0, GL_RGB, GL_FLOAT, 0)
306
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT), image_1)
307
+
308
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
309
+ glTexSubImage1D(GL_TEXTURE_1D,0, 0, 16,GL_RGB,GL_FLOAT,0)
310
+ assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT),image_2)
311
+
312
+ glDeleteBuffers(buffers)
313
+ glDeleteTextures(textures)
314
+ end
315
+
316
+ def test_pixelunpack_pixelmap
317
+ return if not supported?(2.1)
318
+ data_1 = [1,2,3,4].pack("f*")
319
+ data_2 = [5,6,7,8].pack("I*")
320
+ data_3 = [9,10,11,12].pack("S*")
321
+
322
+ buffers = glGenBuffers(3)
323
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
324
+ glBufferData(GL_PIXEL_UNPACK_BUFFER,4*4+4*4+4*2,data_1+data_2+data_3,GL_DYNAMIC_DRAW)
325
+
326
+ glPixelMapfv(GL_PIXEL_MAP_I_TO_I,4,0)
327
+ assert_equal(glGetPixelMapfv(GL_PIXEL_MAP_I_TO_I), [1,2,3,4])
328
+
329
+ glPixelMapuiv(GL_PIXEL_MAP_I_TO_I,4,4*4)
330
+ assert_equal(glGetPixelMapuiv(GL_PIXEL_MAP_I_TO_I),[5,6,7,8])
331
+
332
+ glPixelMapusv(GL_PIXEL_MAP_I_TO_I,4,4*4+4*4)
333
+ assert_equal(glGetPixelMapusv(GL_PIXEL_MAP_I_TO_I),[9,10,11,12])
334
+
335
+ glDeleteBuffers(buffers)
336
+ end
337
+
338
+ def test_pixelpack_readpixels
339
+ return if not supported?(2.1)
340
+ glClearColor(0,0,0,0)
341
+ glClear(GL_COLOR_BUFFER_BIT)
342
+
343
+ image = ([1.0] * 3 * 16).pack("f*")
344
+ glDrawPixels(4,4,GL_RGB,GL_FLOAT,image)
345
+
346
+ buffers = glGenBuffers(1)
347
+ glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
348
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,4*4*4*3, nil, GL_STREAM_READ)
349
+ glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT,0)
350
+
351
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
352
+ assert_equal(data,image)
353
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
354
+
355
+ glDeleteBuffers(buffers)
356
+ end
357
+
358
+ def test_pixelpack_pixelmap
359
+ return if not supported?(2.1)
360
+
361
+ buffers = glGenBuffers(1)
362
+ glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
363
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,4*4, nil, GL_STREAM_READ)
364
+
365
+ # fv
366
+ glPixelMapfv(GL_PIXEL_MAP_I_TO_I,[1,2,3,4])
367
+ glGetPixelMapfv(GL_PIXEL_MAP_I_TO_I,0)
368
+
369
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
370
+ assert_equal([1,2,3,4].pack("f*"),data)
371
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
372
+
373
+ # uiv
374
+ glPixelMapuiv(GL_PIXEL_MAP_I_TO_I,[5,6,7,8])
375
+ glGetPixelMapuiv(GL_PIXEL_MAP_I_TO_I,0)
376
+
377
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
378
+ assert_equal([5,6,7,8].pack("I*"),data)
379
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
380
+
381
+ # usv
382
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,4*2, nil, GL_STREAM_READ)
383
+
384
+ glPixelMapusv(GL_PIXEL_MAP_I_TO_I,[9,10,11,12])
385
+ glGetPixelMapusv(GL_PIXEL_MAP_I_TO_I,0)
386
+
387
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
388
+ assert_equal([9,10,11,12].pack("S*"),data)
389
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
390
+
391
+ glDeleteBuffers(buffers)
392
+ end
393
+
394
+ def test_pixelpack_polygonstipple
395
+ return if not supported?(2.1)
396
+
397
+ stipple = [0x12] * 128
398
+
399
+ buffers = glGenBuffers(1)
400
+ glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
401
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,128, nil, GL_STREAM_READ)
402
+
403
+ glPolygonStipple(stipple.pack("c*"))
404
+ glGetPolygonStipple(0)
405
+
406
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
407
+ assert_equal(stipple.pack("c*"),data)
408
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
409
+
410
+ glDeleteBuffers(buffers)
411
+ end
412
+
413
+ def test_pixelpack_separablefilter
414
+ return if not supported?(2.1)
415
+ sf_a = ([0]*3+[1]*3).pack("f*")
416
+ sf_b = ([1]*3+[0]*3).pack("f*")
417
+
418
+ buffers = glGenBuffers(1)
419
+ glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
420
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,6*4 + 6*4, nil, GL_STREAM_READ)
421
+
422
+ glSeparableFilter2D(GL_SEPARABLE_2D,GL_RGB8, 2,2,GL_RGB,GL_FLOAT,sf_a,sf_b)
423
+ glGetSeparableFilter(GL_SEPARABLE_2D,GL_RGB,GL_FLOAT,0,6*4,0)
424
+
425
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
426
+ assert_equal(data,sf_a + sf_b)
427
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
428
+
429
+ glDeleteBuffers(buffers)
430
+ end
431
+
432
+ def test_pixelpack_convolutionfilter
433
+ return if not supported?(2.1)
434
+
435
+ cf = ([0]*3+[1]*3+[0]*3+[1]*3).pack("f*")
436
+
437
+ buffers = glGenBuffers(1)
438
+ glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
439
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,3*4*4, nil, GL_STREAM_READ)
440
+
441
+ glConvolutionFilter1D(GL_CONVOLUTION_1D, GL_RGB8, 4, GL_RGB, GL_FLOAT,cf)
442
+
443
+ glGetConvolutionFilter(GL_CONVOLUTION_1D, GL_RGB, GL_FLOAT,0)
444
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
445
+ assert_equal(data,cf)
446
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
447
+
448
+ glDeleteBuffers(buffers)
449
+ end
450
+
451
+ def test_pixelpack_histogram
452
+ return if not supported?(2.1)
453
+
454
+ glEnable(GL_HISTOGRAM)
455
+
456
+ glHistogram(GL_HISTOGRAM,1,GL_RGB8,GL_FALSE)
457
+
458
+ buffers = glGenBuffers(1)
459
+ glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
460
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,3*4, nil, GL_STREAM_READ)
461
+
462
+ glDrawPixels(2,1,GL_RGB,GL_FLOAT,[1,1,1,1,1,1].pack("f*"))
463
+ glGetHistogram(GL_HISTOGRAM,GL_FALSE,GL_RGB,GL_FLOAT,0)
464
+
465
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
466
+ assert_equal(data.unpack("f*"),[2,2,2])
467
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
468
+
469
+ glDeleteBuffers(buffers)
470
+ glDisable(GL_HISTOGRAM)
471
+ end
472
+
473
+ def test_pixelpack_minmax
474
+ return if not supported?(2.1)
475
+
476
+ glEnable(GL_MINMAX)
477
+
478
+ glMinmax(GL_MINMAX,GL_RGB8,GL_FALSE)
479
+
480
+ buffers = glGenBuffers(1)
481
+ glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
482
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,6*4, nil, GL_STREAM_READ)
483
+
484
+ glDrawPixels(2,1,GL_RGB,GL_FLOAT,[0,0,0,1,1,1].pack("f*"))
485
+ glGetMinmax(GL_MINMAX,GL_FALSE,GL_RGB,GL_FLOAT,0)
486
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
487
+ assert_equal(data.unpack("f*"),[0,0,0,1,1,1])
488
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
489
+
490
+ glDeleteBuffers(buffers)
491
+ glDisable(GL_MINMAX)
492
+ end
493
+
494
+ def test_pixelpack_teximage
495
+ return if not supported?(2.1)
496
+
497
+ textures = glGenTextures(1)
498
+ glBindTexture(GL_TEXTURE_2D,textures[0])
499
+
500
+ image = ([0,0,0,1,1,1] * 8).pack("f*") # 16 RGB pixels
501
+
502
+ buffers = glGenBuffers(1)
503
+ glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
504
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,16*3*4, nil, GL_STREAM_READ)
505
+
506
+ glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8, 4, 4, 0, GL_RGB, GL_FLOAT, image)
507
+ glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT,0)
508
+
509
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
510
+ assert_equal(data,image)
511
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
512
+
513
+ glDeleteBuffers(buffers)
514
+ glDeleteTextures(textures)
515
+ end
516
+
517
+ def test_pixelpack_compressedteximage
518
+ return if not supported?(2.1)
519
+ return if not supported?("GL_EXT_texture_compression_s3tc")
520
+
521
+ # S3TC/DXT5 compressed 2x2 pixels stipple pattern [w,b,b,w]
522
+ image = [0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x01,0x54,0x5C,0x5C].pack("C*")
523
+
524
+ textures = glGenTextures(1)
525
+ glBindTexture(GL_TEXTURE_2D,textures[0])
526
+
527
+ buffers = glGenBuffers(1)
528
+ glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
529
+ glBufferData(GL_PIXEL_PACK_BUFFER_ARB,image.size, nil, GL_STREAM_READ)
530
+
531
+ glCompressedTexImage2D(GL_TEXTURE_2D,0,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,2,2,0,16,image)
532
+ glGetCompressedTexImage(GL_TEXTURE_2D,0,0)
533
+
534
+ data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
535
+ assert_equal(data,image)
536
+ glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
537
+
538
+ glDeleteBuffers(buffers)
539
+ glDeleteTextures(textures)
540
+ end
541
+ end