ruby-opengl 0.60.1 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. metadata +36 -186
  2. data/Rakefile +0 -168
  3. data/doc/build_install.txt +0 -122
  4. data/doc/extensions.txt +0 -556
  5. data/doc/extensions.txt.in +0 -348
  6. data/doc/history.txt +0 -66
  7. data/doc/requirements_and_design.txt +0 -117
  8. data/doc/roadmap.txt +0 -28
  9. data/doc/scientific_use.txt +0 -35
  10. data/doc/supplies/page_template.html +0 -71
  11. data/doc/thanks.txt +0 -29
  12. data/doc/tutorial.txt +0 -469
  13. data/examples/NeHe/nehe_lesson02.rb +0 -117
  14. data/examples/NeHe/nehe_lesson03.rb +0 -122
  15. data/examples/NeHe/nehe_lesson04.rb +0 -133
  16. data/examples/NeHe/nehe_lesson05.rb +0 -186
  17. data/examples/NeHe/nehe_lesson36.rb +0 -303
  18. data/examples/OrangeBook/3Dlabs-License.txt +0 -33
  19. data/examples/OrangeBook/brick.frag +0 -36
  20. data/examples/OrangeBook/brick.rb +0 -376
  21. data/examples/OrangeBook/brick.vert +0 -41
  22. data/examples/OrangeBook/particle.frag +0 -17
  23. data/examples/OrangeBook/particle.rb +0 -406
  24. data/examples/OrangeBook/particle.vert +0 -38
  25. data/examples/README +0 -16
  26. data/examples/RedBook/aapoly.rb +0 -142
  27. data/examples/RedBook/aargb.rb +0 -119
  28. data/examples/RedBook/accanti.rb +0 -162
  29. data/examples/RedBook/accpersp.rb +0 -215
  30. data/examples/RedBook/alpha.rb +0 -123
  31. data/examples/RedBook/alpha3D.rb +0 -158
  32. data/examples/RedBook/bezcurve.rb +0 -105
  33. data/examples/RedBook/bezmesh.rb +0 -137
  34. data/examples/RedBook/checker.rb +0 -124
  35. data/examples/RedBook/clip.rb +0 -95
  36. data/examples/RedBook/colormat.rb +0 -135
  37. data/examples/RedBook/cube.rb +0 -69
  38. data/examples/RedBook/depthcue.rb +0 -99
  39. data/examples/RedBook/dof.rb +0 -205
  40. data/examples/RedBook/double.rb +0 -105
  41. data/examples/RedBook/drawf.rb +0 -91
  42. data/examples/RedBook/feedback.rb +0 -145
  43. data/examples/RedBook/fog.rb +0 -167
  44. data/examples/RedBook/font.rb +0 -151
  45. data/examples/RedBook/hello.rb +0 -79
  46. data/examples/RedBook/image.rb +0 -137
  47. data/examples/RedBook/jitter.rb +0 -207
  48. data/examples/RedBook/lines.rb +0 -128
  49. data/examples/RedBook/list.rb +0 -111
  50. data/examples/RedBook/material.rb +0 -275
  51. data/examples/RedBook/mipmap.rb +0 -156
  52. data/examples/RedBook/model.rb +0 -113
  53. data/examples/RedBook/movelight.rb +0 -132
  54. data/examples/RedBook/pickdepth.rb +0 -179
  55. data/examples/RedBook/planet.rb +0 -108
  56. data/examples/RedBook/quadric.rb +0 -158
  57. data/examples/RedBook/robot.rb +0 -115
  58. data/examples/RedBook/select.rb +0 -196
  59. data/examples/RedBook/smooth.rb +0 -95
  60. data/examples/RedBook/stencil.rb +0 -163
  61. data/examples/RedBook/stroke.rb +0 -167
  62. data/examples/RedBook/surface.rb +0 -166
  63. data/examples/RedBook/teaambient.rb +0 -132
  64. data/examples/RedBook/teapots.rb +0 -182
  65. data/examples/RedBook/tess.rb +0 -183
  66. data/examples/RedBook/texbind.rb +0 -147
  67. data/examples/RedBook/texgen.rb +0 -169
  68. data/examples/RedBook/texturesurf.rb +0 -128
  69. data/examples/RedBook/varray.rb +0 -159
  70. data/examples/RedBook/wrap.rb +0 -148
  71. data/examples/misc/OGLBench.rb +0 -337
  72. data/examples/misc/anisotropic.rb +0 -194
  73. data/examples/misc/fbo_test.rb +0 -356
  74. data/examples/misc/font-glut.rb +0 -46
  75. data/examples/misc/glfwtest.rb +0 -30
  76. data/examples/misc/plane.rb +0 -161
  77. data/examples/misc/readpixel.rb +0 -65
  78. data/examples/misc/sdltest.rb +0 -34
  79. data/examples/misc/trislam.rb +0 -828
  80. data/ext/common/common.h +0 -423
  81. data/ext/common/conv.h +0 -244
  82. data/ext/common/funcdef.h +0 -280
  83. data/ext/common/gl-enums.h +0 -10031
  84. data/ext/common/gl-error.h +0 -23
  85. data/ext/common/gl-types.h +0 -61
  86. data/ext/common/glu-enums.h +0 -463
  87. data/ext/gl/gl-1.0-1.1.c +0 -2817
  88. data/ext/gl/gl-1.2.c +0 -814
  89. data/ext/gl/gl-1.3.c +0 -444
  90. data/ext/gl/gl-1.4.c +0 -349
  91. data/ext/gl/gl-1.5.c +0 -225
  92. data/ext/gl/gl-2.0.c +0 -657
  93. data/ext/gl/gl-2.1.c +0 -57
  94. data/ext/gl/gl-enums.c +0 -3354
  95. data/ext/gl/gl-error.c +0 -104
  96. data/ext/gl/gl-ext-3dfx.c +0 -27
  97. data/ext/gl/gl-ext-arb.c +0 -866
  98. data/ext/gl/gl-ext-ati.c +0 -41
  99. data/ext/gl/gl-ext-ext.c +0 -890
  100. data/ext/gl/gl-ext-gremedy.c +0 -41
  101. data/ext/gl/gl-ext-nv.c +0 -679
  102. data/ext/gl/gl.c +0 -214
  103. data/ext/gl/mkrf_conf.rb +0 -34
  104. data/ext/glu/glu-enums.c +0 -164
  105. data/ext/glu/glu.c +0 -1530
  106. data/ext/glu/mkrf_conf.rb +0 -35
  107. data/ext/glut/glut.c +0 -1623
  108. data/ext/glut/mkrf_conf.rb +0 -37
  109. data/lib/opengl.rb +0 -84
  110. data/test/README +0 -10
  111. data/test/tc_common.rb +0 -98
  112. data/test/tc_ext_arb.rb +0 -467
  113. data/test/tc_ext_ati.rb +0 -33
  114. data/test/tc_ext_ext.rb +0 -551
  115. data/test/tc_ext_gremedy.rb +0 -36
  116. data/test/tc_ext_nv.rb +0 -357
  117. data/test/tc_func_10_11.rb +0 -1281
  118. data/test/tc_func_12.rb +0 -186
  119. data/test/tc_func_13.rb +0 -229
  120. data/test/tc_func_14.rb +0 -197
  121. data/test/tc_func_15.rb +0 -270
  122. data/test/tc_func_20.rb +0 -346
  123. data/test/tc_func_21.rb +0 -541
  124. data/test/tc_glu.rb +0 -310
  125. data/test/tc_include_gl.rb +0 -35
  126. data/test/tc_misc.rb +0 -54
  127. data/test/tc_require_gl.rb +0 -34
@@ -1,541 +0,0 @@
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