opengl 0.7.0.pre1 → 0.7.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +29 -0
- data/.gitignore +5 -8
- data/History.rdoc +33 -0
- data/Manifest.txt +72 -57
- data/README.rdoc +72 -25
- data/Rakefile +60 -72
- data/Rakefile.cross +5 -2
- data/{doc → docs}/build_install.txt +0 -0
- data/{doc → docs}/extensions.txt.in +0 -0
- data/{doc → docs}/history.txt +0 -0
- data/{doc → docs}/requirements_and_design.txt +0 -0
- data/{doc → docs}/roadmap.txt +0 -0
- data/{doc → docs}/scientific_use.txt +0 -0
- data/{doc → docs}/supplies/page_template.html +0 -0
- data/{doc → docs}/thanks.txt +0 -0
- data/{doc → docs}/tutorial.txt +0 -0
- data/examples/NeHe/NeHe.png +0 -0
- data/examples/NeHe/crate.png +0 -0
- data/examples/NeHe/glass.png +0 -0
- data/examples/NeHe/nehe_lesson02.rb +82 -83
- data/examples/NeHe/nehe_lesson03.rb +88 -88
- data/examples/NeHe/nehe_lesson04.rb +93 -96
- data/examples/NeHe/nehe_lesson05.rb +137 -144
- data/examples/NeHe/nehe_lesson06.rb +183 -0
- data/examples/NeHe/nehe_lesson07.rb +237 -0
- data/examples/NeHe/nehe_lesson08.rb +252 -0
- data/examples/NeHe/nehe_lesson09.rb +199 -0
- data/examples/NeHe/nehe_lesson11.rb +173 -0
- data/examples/NeHe/nehe_lesson12.rb +200 -0
- data/examples/NeHe/nehe_lesson16.rb +208 -0
- data/examples/NeHe/nehe_lesson19.rb +206 -0
- data/examples/NeHe/particle.png +0 -0
- data/examples/NeHe/star.png +0 -0
- data/examples/NeHe/tim.png +0 -0
- data/examples/RedBook/light.rb +154 -0
- data/examples/misc/OGLBench.rb +2 -2
- data/examples/misc/trislam.rb +2 -2
- data/ext/{common → opengl}/common.h +2 -11
- data/ext/{common → opengl}/conv.h +43 -31
- data/ext/{glut → opengl}/extconf.rb +14 -7
- data/ext/{common → opengl}/funcdef.h +155 -125
- data/ext/{gl → opengl}/gl-1.0-1.1.c +426 -162
- data/ext/{gl → opengl}/gl-1.2.c +70 -66
- data/ext/{gl → opengl}/gl-1.3.c +19 -19
- data/ext/{gl → opengl}/gl-1.4.c +23 -23
- data/ext/{gl → opengl}/gl-1.5.c +46 -47
- data/ext/{gl → opengl}/gl-2.0.c +66 -60
- data/ext/{gl → opengl}/gl-2.1.c +4 -4
- data/ext/{gl → opengl}/gl-enums.c +2 -1
- data/ext/{common → opengl}/gl-enums.h +0 -0
- data/ext/{gl → opengl}/gl-error.c +12 -4
- data/ext/{common → opengl}/gl-error.h +7 -2
- data/ext/{gl → opengl}/gl-ext-3dfx.c +1 -1
- data/ext/{gl → opengl}/gl-ext-arb.c +75 -70
- data/ext/{gl → opengl}/gl-ext-ati.c +3 -3
- data/ext/{gl → opengl}/gl-ext-ext.c +54 -54
- data/ext/{gl → opengl}/gl-ext-gremedy.c +3 -3
- data/ext/{gl → opengl}/gl-ext-nv.c +49 -48
- data/ext/{common → opengl}/gl-types.h +0 -0
- data/ext/{gl → opengl}/gl.c +8 -10
- data/ext/{glu → opengl}/glu-enums.c +1 -1
- data/ext/{common → opengl}/glu-enums.h +0 -0
- data/ext/{glu → opengl}/glu.c +7 -3
- data/ext/{glut → opengl}/glut.c +98 -48
- data/ext/opengl/opengl.c +11 -0
- data/lib/gl.rb +1 -0
- data/lib/glu.rb +1 -0
- data/lib/glut.rb +1 -0
- data/lib/opengl.rb +13 -14
- data/lib/opengl/test_case.rb +87 -0
- data/test/{tc_misc.rb → test_gl.rb} +2 -14
- data/test/test_gl_10_11.rb +1363 -0
- data/test/test_gl_12.rb +182 -0
- data/test/{tc_func_13.rb → test_gl_13.rb} +14 -14
- data/test/test_gl_14.rb +221 -0
- data/test/test_gl_15.rb +260 -0
- data/test/test_gl_20.rb +430 -0
- data/test/test_gl_21.rb +553 -0
- data/test/test_gl_ext_arb.rb +526 -0
- data/test/{tc_ext_ati.rb → test_gl_ext_ati.rb} +11 -14
- data/test/test_gl_ext_ext.rb +608 -0
- data/test/{tc_ext_gremedy.rb → test_gl_ext_gremedy.rb} +6 -6
- data/test/test_gl_ext_nv.rb +352 -0
- data/test/test_glu.rb +309 -0
- metadata +159 -99
- data/History.txt +0 -36
- data/ext/gl/extconf.rb +0 -43
- data/ext/glu/extconf.rb +0 -51
- data/test/README +0 -10
- data/test/tc_common.rb +0 -98
- data/test/tc_ext_arb.rb +0 -467
- data/test/tc_ext_ext.rb +0 -551
- data/test/tc_ext_nv.rb +0 -357
- data/test/tc_func_10_11.rb +0 -1281
- data/test/tc_func_12.rb +0 -186
- data/test/tc_func_14.rb +0 -197
- data/test/tc_func_15.rb +0 -270
- data/test/tc_func_20.rb +0 -346
- data/test/tc_func_21.rb +0 -541
- data/test/tc_glu.rb +0 -310
- data/test/tc_include_gl.rb +0 -35
- data/test/tc_require_gl.rb +0 -34
data/test/tc_func_20.rb
DELETED
@@ -1,346 +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_20 < Test::Unit::TestCase
|
19
|
-
def setup
|
20
|
-
common_setup()
|
21
|
-
end
|
22
|
-
|
23
|
-
def teardown
|
24
|
-
common_teardown()
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_glblendequationseparate
|
28
|
-
return if not supported?(2.0)
|
29
|
-
glBlendEquationSeparate(GL_MIN,GL_MAX)
|
30
|
-
assert_equal(glGetIntegerv(GL_BLEND_EQUATION_RGB),GL_MIN)
|
31
|
-
assert_equal(glGetIntegerv(GL_BLEND_EQUATION_ALPHA),GL_MAX)
|
32
|
-
glBlendEquationSeparate(GL_MAX,GL_MIN)
|
33
|
-
assert_equal(glGetIntegerv(GL_BLEND_EQUATION_RGB),GL_MAX)
|
34
|
-
assert_equal(glGetIntegerv(GL_BLEND_EQUATION_ALPHA),GL_MIN)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_stencilops
|
38
|
-
return if not supported?(2.0)
|
39
|
-
|
40
|
-
glStencilOpSeparate(GL_FRONT, GL_ZERO, GL_INCR, GL_DECR)
|
41
|
-
assert_equal(glGetIntegerv(GL_STENCIL_FAIL), GL_ZERO)
|
42
|
-
assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL), GL_INCR)
|
43
|
-
assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS), GL_DECR)
|
44
|
-
glStencilOpSeparate(GL_FRONT, GL_INCR, GL_DECR, GL_ZERO)
|
45
|
-
assert_equal(glGetIntegerv(GL_STENCIL_FAIL), GL_INCR)
|
46
|
-
assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL), GL_DECR)
|
47
|
-
assert_equal(glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS), GL_ZERO)
|
48
|
-
|
49
|
-
glStencilFuncSeparate(GL_FRONT, GL_LEQUAL, 1, 0)
|
50
|
-
assert_equal(glGetIntegerv(GL_STENCIL_FUNC),GL_LEQUAL)
|
51
|
-
assert_equal(glGetIntegerv(GL_STENCIL_REF),1)
|
52
|
-
assert_equal(glGetIntegerv(GL_STENCIL_VALUE_MASK),0)
|
53
|
-
glStencilFuncSeparate(GL_FRONT, GL_GEQUAL, 0, 1)
|
54
|
-
assert_equal(glGetIntegerv(GL_STENCIL_FUNC),GL_GEQUAL)
|
55
|
-
assert_equal(glGetIntegerv(GL_STENCIL_REF),0)
|
56
|
-
assert_equal(glGetIntegerv(GL_STENCIL_VALUE_MASK),1)
|
57
|
-
|
58
|
-
glStencilMaskSeparate(GL_FRONT,1)
|
59
|
-
assert_equal(glGetIntegerv( GL_STENCIL_WRITEMASK),1)
|
60
|
-
glStencilMaskSeparate(GL_FRONT,0)
|
61
|
-
assert_equal(glGetIntegerv(GL_STENCIL_WRITEMASK),0)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_gldrawbuf
|
65
|
-
return if not supported?(2.0)
|
66
|
-
glDrawBuffers([GL_FRONT_LEFT,GL_BACK_LEFT])
|
67
|
-
assert_equal(glGetIntegerv(GL_DRAW_BUFFER0),GL_FRONT_LEFT)
|
68
|
-
assert_equal(glGetIntegerv(GL_DRAW_BUFFER1),GL_BACK_LEFT)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_glvertexattrib
|
72
|
-
return if not supported?(2.0)
|
73
|
-
# 1
|
74
|
-
glVertexAttrib1d(1,2.0)
|
75
|
-
assert_equal(glGetVertexAttribdv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,0.0,0.0,1.0])
|
76
|
-
glVertexAttrib1dv(1,[3.0])
|
77
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,0.0,0.0,1.0])
|
78
|
-
glVertexAttrib1f(1,2.0)
|
79
|
-
assert_equal(glGetVertexAttribiv(1,GL_CURRENT_VERTEX_ATTRIB), [2,0,0,1])
|
80
|
-
glVertexAttrib1fv(1,[3.0])
|
81
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,0.0,0.0,1.0])
|
82
|
-
glVertexAttrib1s(1,2)
|
83
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,0.0,0.0,1.0])
|
84
|
-
glVertexAttrib1sv(1,[3])
|
85
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,0.0,0.0,1.0])
|
86
|
-
# 2
|
87
|
-
glVertexAttrib2d(1,2.0,2.0)
|
88
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,0.0,1.0])
|
89
|
-
glVertexAttrib2dv(1,[3.0,3.0])
|
90
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,0.0,1.0])
|
91
|
-
glVertexAttrib2f(1,2.0,2.0)
|
92
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,0.0,1.0])
|
93
|
-
glVertexAttrib2fv(1,[3.0,3.0])
|
94
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,0.0,1.0])
|
95
|
-
glVertexAttrib2s(1,2,2)
|
96
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,0.0,1.0])
|
97
|
-
glVertexAttrib2sv(1,[3,3])
|
98
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,0.0,1.0])
|
99
|
-
# 3
|
100
|
-
glVertexAttrib3d(1,2.0,2.0,2.0)
|
101
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,2.0,1.0])
|
102
|
-
glVertexAttrib3dv(1,[3.0,3.0,3.0])
|
103
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,3.0,1.0])
|
104
|
-
glVertexAttrib3f(1,2.0,2.0,2.0)
|
105
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,2.0,1.0])
|
106
|
-
glVertexAttrib3fv(1,[3.0,3.0,3.0])
|
107
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,3.0,1.0])
|
108
|
-
glVertexAttrib3s(1,2,2,2)
|
109
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,2.0,2.0,1.0])
|
110
|
-
glVertexAttrib3sv(1,[3,3,3])
|
111
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [3.0,3.0,3.0,1.0])
|
112
|
-
# 4N
|
113
|
-
glVertexAttrib4Nbv(1,[2**7-1,2**7-1,2**7-1,2**7-1])
|
114
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
|
115
|
-
glVertexAttrib4Niv(1,[0,0,0,0])
|
116
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
|
117
|
-
glVertexAttrib4Nsv(1,[2**15-1,2**15-1,2**15-1,2**15-1])
|
118
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
|
119
|
-
glVertexAttrib4Nub(1,0,0,0,0)
|
120
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
|
121
|
-
glVertexAttrib4Nubv(1,[2**8-1,2**8-1,2**8-1,2**8-1])
|
122
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
|
123
|
-
glVertexAttrib4Nuiv(1,[0,0,0,0])
|
124
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
|
125
|
-
glVertexAttrib4Nusv(1,[2**16-1,2**16-1,2**16-1,2**16-1])
|
126
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
|
127
|
-
# 4
|
128
|
-
glVertexAttrib4bv(1,[0,0,0,0])
|
129
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
|
130
|
-
glVertexAttrib4d(1,1,1,1,1)
|
131
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
|
132
|
-
glVertexAttrib4dv(1,[0,0,0,0])
|
133
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
|
134
|
-
glVertexAttrib4f(1,1,1,1,1)
|
135
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
|
136
|
-
glVertexAttrib4fv(1,[0,0,0,0])
|
137
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
|
138
|
-
glVertexAttrib4iv(1,[1,1,1,1])
|
139
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
|
140
|
-
glVertexAttrib4s(1,0,0,0,0)
|
141
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
|
142
|
-
glVertexAttrib4sv(1,[1,1,1,1])
|
143
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
|
144
|
-
glVertexAttrib4ubv(1,[0,0,0,0])
|
145
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
|
146
|
-
glVertexAttrib4uiv(1,[1,1,1,1])
|
147
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [1,1,1,1]))
|
148
|
-
glVertexAttrib4usv(1,[0,0,0,0])
|
149
|
-
assert(approx_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB), [0,0,0,0]))
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_vertexattribpointer
|
153
|
-
return if not supported?(2.0)
|
154
|
-
|
155
|
-
vaa = [1,1,1,1, 2,2,2,2].pack("f*")
|
156
|
-
glVertexAttribPointer(1,4,GL_FLOAT,GL_FALSE,0,vaa)
|
157
|
-
assert_equal(glGetVertexAttribPointerv(1),vaa)
|
158
|
-
|
159
|
-
glEnableVertexAttribArray(1)
|
160
|
-
|
161
|
-
glBegin(GL_POINTS)
|
162
|
-
glArrayElement(1)
|
163
|
-
glEnd()
|
164
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB),[2,2,2,2])
|
165
|
-
|
166
|
-
glDisableVertexAttribArray(1)
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_shaders
|
170
|
-
return if not supported?(2.0)
|
171
|
-
|
172
|
-
vertex_shader_source = "void main() { gl_Position = ftransform();}"
|
173
|
-
|
174
|
-
program = glCreateProgram()
|
175
|
-
assert_equal(glIsProgram(program),true)
|
176
|
-
|
177
|
-
vs = glCreateShader(GL_VERTEX_SHADER)
|
178
|
-
assert_equal(glIsShader(vs),true)
|
179
|
-
|
180
|
-
glShaderSource(vs,vertex_shader_source)
|
181
|
-
assert_equal(glGetShaderSource(vs),vertex_shader_source)
|
182
|
-
|
183
|
-
assert_equal(glGetShaderiv(vs, GL_SHADER_TYPE),GL_VERTEX_SHADER)
|
184
|
-
glCompileShader(vs)
|
185
|
-
assert_equal(glGetShaderiv(vs,GL_COMPILE_STATUS),GL_TRUE)
|
186
|
-
|
187
|
-
vslog = glGetShaderInfoLog(vs)
|
188
|
-
assert_equal(vslog.class,String)
|
189
|
-
|
190
|
-
glAttachShader(program,vs)
|
191
|
-
assert_equal(glGetAttachedShaders(program),vs)
|
192
|
-
glDetachShader(program,vs)
|
193
|
-
assert_equal(glGetAttachedShaders(program),nil)
|
194
|
-
glAttachShader(program,vs)
|
195
|
-
|
196
|
-
glValidateProgram(program)
|
197
|
-
assert_equal(glGetProgramiv(program,GL_VALIDATE_STATUS),GL_TRUE)
|
198
|
-
prlog = glGetProgramInfoLog(program)
|
199
|
-
assert_equal(prlog.class,String)
|
200
|
-
|
201
|
-
glLinkProgram(program)
|
202
|
-
assert_equal(glGetProgramiv(program,GL_LINK_STATUS),GL_TRUE)
|
203
|
-
|
204
|
-
glUseProgram(program)
|
205
|
-
assert_equal(glGetIntegerv(GL_CURRENT_PROGRAM),program)
|
206
|
-
|
207
|
-
glUseProgram(0)
|
208
|
-
|
209
|
-
glDetachShader(program,vs)
|
210
|
-
glDeleteShader(vs)
|
211
|
-
assert_equal(glIsShader(vs),false)
|
212
|
-
|
213
|
-
glDeleteProgram(program)
|
214
|
-
assert_equal(glIsProgram(program),false)
|
215
|
-
end
|
216
|
-
|
217
|
-
def test_shaders_2
|
218
|
-
return if not supported?(2.0)
|
219
|
-
|
220
|
-
vertex_shader_source = "attribute vec4 test; uniform float testvec1; uniform vec2 testvec2; uniform vec3 testvec3; uniform vec4 testvec4; uniform int testivec1; uniform ivec2 testivec2; uniform ivec3 testivec3; uniform ivec4 testivec4; void main() { gl_Position = testvec1 * test * testvec2.x * testvec3.x * testivec1 * testivec2.x * testivec3.x * testivec4.x + testvec4;}"
|
221
|
-
program = glCreateProgram()
|
222
|
-
vs = glCreateShader(GL_VERTEX_SHADER)
|
223
|
-
|
224
|
-
glShaderSource(vs,vertex_shader_source)
|
225
|
-
glCompileShader(vs)
|
226
|
-
|
227
|
-
assert_equal(glGetShaderiv(vs,GL_COMPILE_STATUS),GL_TRUE)
|
228
|
-
glAttachShader(program,vs)
|
229
|
-
|
230
|
-
glBindAttribLocation(program,2,"test")
|
231
|
-
glLinkProgram(program)
|
232
|
-
assert_equal(glGetProgramiv(program,GL_LINK_STATUS),GL_TRUE)
|
233
|
-
glUseProgram(program)
|
234
|
-
|
235
|
-
assert_equal(glGetAttribLocation(program,"test"),2)
|
236
|
-
assert((tv1l = glGetUniformLocation(program,"testvec1"))>=0)
|
237
|
-
assert((tv2l = glGetUniformLocation(program,"testvec2"))>=0)
|
238
|
-
assert((tv3l = glGetUniformLocation(program,"testvec3"))>=0)
|
239
|
-
assert((tv4l = glGetUniformLocation(program,"testvec4"))>=0)
|
240
|
-
assert((tv1il = glGetUniformLocation(program,"testivec1"))>=0)
|
241
|
-
assert((tv2il = glGetUniformLocation(program,"testivec2"))>=0)
|
242
|
-
assert((tv3il = glGetUniformLocation(program,"testivec3"))>=0)
|
243
|
-
assert((tv4il = glGetUniformLocation(program,"testivec4"))>=0)
|
244
|
-
|
245
|
-
##
|
246
|
-
assert_equal(glGetActiveAttrib(program,0),[1,GL_FLOAT_VEC4,"test"])
|
247
|
-
assert_equal(glGetActiveUniform(program,tv1il),[1,GL_INT,"testivec1"])
|
248
|
-
|
249
|
-
# f
|
250
|
-
glUniform1f(tv1l,2.0)
|
251
|
-
assert_equal(glGetUniformfv(program,tv1l),2.0)
|
252
|
-
glUniform2f(tv2l,2.0,2.0)
|
253
|
-
assert_equal(glGetUniformfv(program,tv2l),[2.0,2.0])
|
254
|
-
glUniform3f(tv3l,2.0,2.0,2.0)
|
255
|
-
assert_equal(glGetUniformfv(program,tv3l),[2.0,2.0,2.0])
|
256
|
-
glUniform4f(tv4l,2.0,2.0,2.0,2.0)
|
257
|
-
assert_equal(glGetUniformfv(program,tv4l),[2.0,2.0,2.0,2.0])
|
258
|
-
# i
|
259
|
-
glUniform1i(tv1il,3)
|
260
|
-
assert_equal(glGetUniformiv(program,tv1il),3)
|
261
|
-
glUniform2i(tv2il,3,3)
|
262
|
-
assert_equal(glGetUniformiv(program,tv2il),[3,3])
|
263
|
-
glUniform3i(tv3il,3,3,3)
|
264
|
-
assert_equal(glGetUniformiv(program,tv3il),[3,3,3])
|
265
|
-
glUniform4i(tv4il,3,3,3,3)
|
266
|
-
assert_equal(glGetUniformiv(program,tv4il),[3,3,3,3])
|
267
|
-
# fv
|
268
|
-
glUniform1fv(tv1l,[3.0])
|
269
|
-
assert_equal(glGetUniformfv(program,tv1l),3.0)
|
270
|
-
glUniform2fv(tv2l,[3.0,3.0])
|
271
|
-
assert_equal(glGetUniformfv(program,tv2l),[3.0,3.0])
|
272
|
-
glUniform3fv(tv3l,[3.0,3.0,3.0])
|
273
|
-
assert_equal(glGetUniformfv(program,tv3l),[3.0,3.0,3.0])
|
274
|
-
glUniform4fv(tv4l,[3.0,3.0,3.0,3.0])
|
275
|
-
assert_equal(glGetUniformfv(program,tv4l),[3.0,3.0,3.0,3.0])
|
276
|
-
# iv
|
277
|
-
glUniform1iv(tv1il,[2])
|
278
|
-
assert_equal(glGetUniformiv(program,tv1il),2)
|
279
|
-
glUniform2iv(tv2il,[2,2])
|
280
|
-
assert_equal(glGetUniformiv(program,tv2il),[2,2])
|
281
|
-
glUniform3iv(tv3il,[2,2,2])
|
282
|
-
assert_equal(glGetUniformiv(program,tv3il),[2,2,2])
|
283
|
-
glUniform4iv(tv4il,[2,2,2,2])
|
284
|
-
assert_equal(glGetUniformiv(program,tv4il),[2,2,2,2])
|
285
|
-
|
286
|
-
glDeleteShader(vs)
|
287
|
-
glDeleteProgram(program)
|
288
|
-
end
|
289
|
-
|
290
|
-
def test_shaders_3
|
291
|
-
return if not supported?(2.0)
|
292
|
-
|
293
|
-
vertex_shader_source = "uniform mat2 testmat2; uniform mat3 testmat3; uniform mat4 testmat4; void main() { gl_Position = gl_Vertex * testmat4[0].x * testmat3[0].x * testmat2[0].x;}"
|
294
|
-
|
295
|
-
program = glCreateProgram()
|
296
|
-
vs = glCreateShader(GL_VERTEX_SHADER)
|
297
|
-
|
298
|
-
glShaderSource(vs,vertex_shader_source)
|
299
|
-
glCompileShader(vs)
|
300
|
-
|
301
|
-
assert_equal(glGetShaderiv(vs,GL_COMPILE_STATUS),GL_TRUE)
|
302
|
-
glAttachShader(program,vs)
|
303
|
-
|
304
|
-
glLinkProgram(program)
|
305
|
-
assert_equal(glGetProgramiv(program,GL_LINK_STATUS),GL_TRUE)
|
306
|
-
glUseProgram(program)
|
307
|
-
#
|
308
|
-
assert((tm2l = glGetUniformLocation(program,"testmat2"))>=0)
|
309
|
-
assert((tm3l = glGetUniformLocation(program,"testmat3"))>=0)
|
310
|
-
assert((tm4l = glGetUniformLocation(program,"testmat4"))>=0)
|
311
|
-
|
312
|
-
glUniformMatrix2fv(tm2l, GL_TRUE, [0,1, 1,0])
|
313
|
-
assert_equal(glGetUniformfv(program,tm2l),[0,1,1,0])
|
314
|
-
|
315
|
-
glUniformMatrix3fv(tm3l, GL_TRUE, [0,1,0, 1,0,1, 0,1,0])
|
316
|
-
assert_equal(glGetUniformfv(program,tm3l),[0,1,0, 1,0,1, 0,1,0])
|
317
|
-
|
318
|
-
glUniformMatrix4fv(tm4l, GL_TRUE, [0,1,0,1, 1,0,1,0, 0,1,0,1, 1,0,1,0])
|
319
|
-
assert_equal(glGetUniformfv(program,tm4l),[0,1,0,1, 1,0,1,0, 0,1,0,1, 1,0,1,0])
|
320
|
-
end
|
321
|
-
|
322
|
-
|
323
|
-
def test_buffered_vertexattribpointer
|
324
|
-
return if not supported?(2.0)
|
325
|
-
|
326
|
-
vaa = [1,1,1,1, 2,2,2,2].pack("f*")
|
327
|
-
|
328
|
-
buffers = glGenBuffers(1)
|
329
|
-
|
330
|
-
glBindBuffer(GL_ARRAY_BUFFER,buffers[0])
|
331
|
-
glBufferData(GL_ARRAY_BUFFER,8*4,vaa,GL_DYNAMIC_DRAW)
|
332
|
-
|
333
|
-
glVertexAttribPointer(1,4,GL_FLOAT,GL_FALSE,0,0)
|
334
|
-
assert_equal(glGetVertexAttribPointerv(1),0)
|
335
|
-
|
336
|
-
glEnableVertexAttribArray(1)
|
337
|
-
|
338
|
-
glBegin(GL_POINTS)
|
339
|
-
glArrayElement(1)
|
340
|
-
glEnd()
|
341
|
-
assert_equal(glGetVertexAttribfv(1,GL_CURRENT_VERTEX_ATTRIB),[2,2,2,2])
|
342
|
-
|
343
|
-
glDisableVertexAttribArray(1)
|
344
|
-
glDeleteBuffers(buffers)
|
345
|
-
end
|
346
|
-
end
|
data/test/tc_func_21.rb
DELETED
@@ -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
|