ruby-opengl 0.40.1 → 0.50.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.
- data/Rakefile +2 -2
- data/doc/build_install.txt +48 -28
- data/doc/extensions.txt +361 -0
- data/doc/history.txt +8 -2
- data/doc/requirements_and_design.txt +0 -13
- data/doc/roadmap.txt +11 -13
- data/doc/supplies/page_template.html +11 -5
- data/doc/thanks.txt +2 -4
- data/doc/tutorial.txt +1 -4
- data/examples/{nehe_lesson02.rb → NeHe/nehe_lesson02.rb} +0 -0
- data/examples/{nehe_lesson03.rb → NeHe/nehe_lesson03.rb} +0 -0
- data/examples/{nehe_lesson04.rb → NeHe/nehe_lesson04.rb} +0 -0
- data/examples/{nehe_lesson05.rb → NeHe/nehe_lesson05.rb} +0 -0
- data/examples/NeHe/nehe_lesson36.rb +303 -0
- data/examples/OrangeBook/3Dlabs-License.txt +33 -0
- data/examples/OrangeBook/brick.frag +36 -0
- data/examples/OrangeBook/brick.rb +388 -0
- data/examples/OrangeBook/brick.vert +41 -0
- data/examples/OrangeBook/particle.frag +17 -0
- data/examples/OrangeBook/particle.rb +424 -0
- data/examples/OrangeBook/particle.vert +38 -0
- data/examples/README +13 -83
- data/examples/RedBook/aaindex.rb +97 -0
- data/examples/RedBook/aapoly.rb +142 -0
- data/examples/RedBook/aargb.rb +119 -0
- data/examples/RedBook/accanti.rb +162 -0
- data/examples/RedBook/accpersp.rb +215 -0
- data/examples/RedBook/alpha.rb +123 -0
- data/examples/RedBook/alpha3D.rb +158 -0
- data/examples/RedBook/bezcurve.rb +105 -0
- data/examples/RedBook/bezmesh.rb +137 -0
- data/examples/RedBook/checker.rb +124 -0
- data/examples/RedBook/clip.rb +95 -0
- data/examples/RedBook/colormat.rb +135 -0
- data/examples/RedBook/cube.rb +69 -0
- data/examples/RedBook/depthcue.rb +99 -0
- data/examples/RedBook/dof.rb +205 -0
- data/examples/{legacy → RedBook}/double.rb +59 -58
- data/examples/{legacy → RedBook}/drawf.rb +47 -54
- data/examples/RedBook/feedback.rb +145 -0
- data/examples/RedBook/fog.rb +167 -0
- data/examples/RedBook/font.rb +151 -0
- data/examples/RedBook/hello.rb +79 -0
- data/examples/RedBook/image.rb +137 -0
- data/examples/{legacy → RedBook}/jitter.rb +60 -62
- data/examples/RedBook/lines.rb +128 -0
- data/examples/RedBook/list.rb +111 -0
- data/examples/RedBook/material.rb +275 -0
- data/examples/RedBook/mipmap.rb +156 -0
- data/examples/{legacy → RedBook}/model.rb +66 -72
- data/examples/{legacy → RedBook}/movelight.rb +67 -75
- data/examples/RedBook/pickdepth.rb +179 -0
- data/examples/{legacy → RedBook}/planet.rb +62 -66
- data/examples/RedBook/quadric.rb +158 -0
- data/examples/RedBook/robot.rb +115 -0
- data/examples/RedBook/select.rb +196 -0
- data/examples/RedBook/smooth.rb +95 -0
- data/examples/RedBook/stencil.rb +163 -0
- data/examples/RedBook/stroke.rb +167 -0
- data/examples/RedBook/surface.rb +166 -0
- data/examples/RedBook/teaambient.rb +132 -0
- data/examples/RedBook/teapots.rb +182 -0
- data/examples/RedBook/tess.rb +183 -0
- data/examples/RedBook/texbind.rb +147 -0
- data/examples/RedBook/texgen.rb +169 -0
- data/examples/RedBook/texturesurf.rb +128 -0
- data/examples/RedBook/varray.rb +159 -0
- data/examples/RedBook/wrap.rb +148 -0
- data/examples/misc/anisotropic.rb +194 -0
- data/examples/misc/font-glut.rb +46 -0
- data/examples/{plane.rb → misc/plane.rb} +0 -0
- data/examples/misc/readpixel.rb +65 -0
- data/examples/{smooth.rb → misc/smooth.rb} +0 -0
- data/examples/{test.rb → misc/test.rb} +0 -0
- data/ext/common/common.h +252 -70
- data/ext/common/gl-enums.h +6102 -7334
- data/ext/common/gl-types.h +47 -0
- data/ext/common/glu-enums.h +469 -0
- data/ext/gl/gl-1.0-1.1.c +842 -2464
- data/ext/gl/gl-1.2.c +217 -281
- data/ext/gl/gl-1.3.c +113 -133
- data/ext/gl/gl-1.4.c +98 -334
- data/ext/gl/gl-1.5.c +28 -34
- data/ext/gl/gl-2.0.c +26 -235
- data/ext/gl/gl-2.1.c +31 -124
- data/ext/gl/gl-enums.c +786 -631
- data/ext/gl/gl-ext-arb.c +66 -0
- data/ext/gl/gl-ext-ext.c +218 -0
- data/ext/gl/gl.c +138 -31
- data/ext/gl/mkrf_conf.rb +1 -0
- data/ext/glu/glu-enums.c +163 -0
- data/ext/glu/glu.c +1003 -1205
- data/ext/glu/mkrf_conf.rb +1 -0
- data/ext/glut/glut.c +1056 -1175
- data/lib/opengl.rb +90 -3
- data/test/tc_common.rb +26 -13
- data/test/tc_ext_arb.rb +73 -0
- data/test/tc_ext_ext.rb +74 -0
- data/test/tc_func_12.rb +8 -8
- data/test/tc_func_13.rb +17 -11
- data/test/tc_func_14.rb +8 -8
- data/test/tc_func_15.rb +190 -2
- data/test/tc_func_20.rb +36 -10
- data/test/tc_func_21.rb +445 -2
- data/test/tc_glu.rb +305 -0
- data/test/tc_misc.rb +1 -0
- metadata +84 -68
- data/doc/screenshots.txt +0 -23
- data/examples/legacy/COPYRIGHT +0 -8
- data/examples/legacy/aaindex.rb +0 -98
- data/examples/legacy/aapoly.rb +0 -153
- data/examples/legacy/aargb.rb +0 -139
- data/examples/legacy/accanti.rb +0 -159
- data/examples/legacy/accpersp.rb +0 -216
- data/examples/legacy/alpha.rb +0 -133
- data/examples/legacy/alpha3D.rb +0 -165
- data/examples/legacy/bezcurve.rb +0 -107
- data/examples/legacy/bezmesh.rb +0 -131
- data/examples/legacy/checker.rb +0 -121
- data/examples/legacy/clip.rb +0 -104
- data/examples/legacy/colormat.rb +0 -145
- data/examples/legacy/cube.rb +0 -73
- data/examples/legacy/depthcue.rb +0 -101
- data/examples/legacy/dof.rb +0 -212
- data/examples/legacy/feedback.rb +0 -152
- data/examples/legacy/fog.rb +0 -172
- data/examples/legacy/font-glut.rb +0 -41
- data/examples/legacy/font.rb +0 -158
- data/examples/legacy/hello.rb +0 -75
- data/examples/legacy/image.rb +0 -145
- data/examples/legacy/lines.rb +0 -135
- data/examples/legacy/list.rb +0 -120
- data/examples/legacy/material.rb +0 -290
- data/examples/legacy/mipmap.rb +0 -159
- data/examples/legacy/pickdepth.rb +0 -180
- data/examples/legacy/quadric.rb +0 -180
- data/examples/legacy/readpixel.rb +0 -59
- data/examples/legacy/robot.rb +0 -120
- data/examples/legacy/select.rb +0 -207
- data/examples/legacy/smooth.rb +0 -41
- data/examples/legacy/stencil.rb +0 -154
- data/examples/legacy/stroke.rb +0 -170
- data/examples/legacy/surface.rb +0 -170
- data/examples/legacy/teaambient.rb +0 -132
- data/examples/legacy/teapots.rb +0 -188
- data/examples/legacy/tess.rb +0 -222
- data/examples/legacy/texbind.rb +0 -157
- data/examples/legacy/texgen.rb +0 -171
- data/examples/legacy/texturesurf.rb +0 -128
- data/examples/legacy/varray.rb +0 -167
- data/examples/legacy/wrap.rb +0 -158
- data/lib/gl_prev.rb +0 -46
- data/lib/glu_prev.rb +0 -46
- data/lib/glut_prev.rb +0 -45
data/test/tc_func_14.rb
CHANGED
@@ -25,7 +25,7 @@ class Test_14 < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_arrays_2
|
28
|
-
return if not supported?(
|
28
|
+
return if not supported?(1.4)
|
29
29
|
sc = [0,1,0, 1,0,1].pack("f*")
|
30
30
|
fc = [1, 0].pack("f*")
|
31
31
|
|
@@ -61,7 +61,7 @@ class Test_14 < Test::Unit::TestCase
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_arrays_3
|
64
|
-
return if not supported?(
|
64
|
+
return if not supported?(1.4)
|
65
65
|
va = [0,0, 1,0, 1,1, 0,0, 1,0, 0,1].pack("f*")
|
66
66
|
glVertexPointer(2,GL_FLOAT,0,va)
|
67
67
|
|
@@ -70,7 +70,7 @@ class Test_14 < Test::Unit::TestCase
|
|
70
70
|
buf = glFeedbackBuffer(256,GL_3D)
|
71
71
|
glRenderMode(GL_FEEDBACK)
|
72
72
|
|
73
|
-
glMultiDrawArrays(GL_POLYGON, [0,3], [3,3]
|
73
|
+
glMultiDrawArrays(GL_POLYGON, [0,3], [3,3])
|
74
74
|
|
75
75
|
i1 = [0,1,2].pack("C*")
|
76
76
|
i2 = [3,4,5].pack("C*")
|
@@ -82,7 +82,7 @@ class Test_14 < Test::Unit::TestCase
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_glblendfuncseparate
|
85
|
-
return if not supported?(
|
85
|
+
return if not supported?(1.4)
|
86
86
|
glBlendFuncSeparate(GL_SRC_COLOR,GL_SRC_COLOR,GL_SRC_COLOR,GL_SRC_COLOR)
|
87
87
|
assert_equal(glGetIntegerv(GL_BLEND_SRC_RGB),GL_SRC_COLOR)
|
88
88
|
assert_equal(glGetIntegerv(GL_BLEND_SRC_ALPHA),GL_SRC_COLOR)
|
@@ -91,7 +91,7 @@ class Test_14 < Test::Unit::TestCase
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def test_glpointparameter
|
94
|
-
return if not supported?(
|
94
|
+
return if not supported?(1.4)
|
95
95
|
glPointParameterf(GL_POINT_SIZE_MIN,2.0)
|
96
96
|
assert_equal(glGetDoublev(GL_POINT_SIZE_MIN),2.0)
|
97
97
|
|
@@ -106,7 +106,7 @@ class Test_14 < Test::Unit::TestCase
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def test_glfogcoord
|
109
|
-
return if not supported?(
|
109
|
+
return if not supported?(1.4)
|
110
110
|
|
111
111
|
glFogCoordf(2.0)
|
112
112
|
assert_equal(glGetDoublev(GL_CURRENT_FOG_COORD),2.0)
|
@@ -120,7 +120,7 @@ class Test_14 < Test::Unit::TestCase
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def test_glsecondarycolor
|
123
|
-
return if not supported?(
|
123
|
+
return if not supported?(1.4)
|
124
124
|
|
125
125
|
glSecondaryColor3b(2**7-1,0,2**7-1)
|
126
126
|
assert(approx_equal(glGetDoublev(GL_CURRENT_SECONDARY_COLOR),[1.0,0.0,1.0,1.0]))
|
@@ -157,7 +157,7 @@ class Test_14 < Test::Unit::TestCase
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def test_glwindowpos
|
160
|
-
return if not supported?(
|
160
|
+
return if not supported?(1.4)
|
161
161
|
# 2
|
162
162
|
glWindowPos2d(1.0,2.0)
|
163
163
|
assert_equal(glGetDoublev(GL_CURRENT_RASTER_POSITION),[1,2,0,1])
|
data/test/tc_func_15.rb
CHANGED
@@ -25,7 +25,7 @@ class Test_15 < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_query
|
28
|
-
return if not supported?(
|
28
|
+
return if not supported?(1.5)
|
29
29
|
queries = glGenQueries(2)
|
30
30
|
assert_equal(queries.size,2)
|
31
31
|
|
@@ -55,7 +55,7 @@ class Test_15 < Test::Unit::TestCase
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_buffers
|
58
|
-
return if not supported?(
|
58
|
+
return if not supported?(1.5)
|
59
59
|
buffers = glGenBuffers(2)
|
60
60
|
glBindBuffer(GL_ARRAY_BUFFER,buffers[0])
|
61
61
|
assert_equal(glIsBuffer(buffers[0]),GL_TRUE)
|
@@ -79,4 +79,192 @@ class Test_15 < Test::Unit::TestCase
|
|
79
79
|
|
80
80
|
# FIXME: GetBufferPointerv not yet implemented
|
81
81
|
end
|
82
|
+
|
83
|
+
def test_buffer_binding_element_array
|
84
|
+
return if not supported?(1.5)
|
85
|
+
|
86
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
87
|
+
va = [0,0, 0,1, 1,1].pack("f*")
|
88
|
+
glVertexPointer(2,GL_FLOAT,0,va)
|
89
|
+
|
90
|
+
#
|
91
|
+
data = [0,1,2].pack("C*")
|
92
|
+
buffers = glGenBuffers(1)
|
93
|
+
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,buffers[0])
|
94
|
+
glBufferData(GL_ELEMENT_ARRAY_BUFFER,3,data,GL_DYNAMIC_DRAW)
|
95
|
+
|
96
|
+
#
|
97
|
+
feedback = glFeedbackBuffer(256,GL_3D)
|
98
|
+
glRenderMode(GL_FEEDBACK)
|
99
|
+
|
100
|
+
glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_BYTE,0)
|
101
|
+
glDrawRangeElements(GL_TRIANGLES,0,3,3,GL_UNSIGNED_BYTE,0)
|
102
|
+
|
103
|
+
count = glRenderMode(GL_RENDER)
|
104
|
+
assert_equal(count,22)
|
105
|
+
|
106
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
107
|
+
glDeleteBuffers(buffers)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_buffer_binding_array_1
|
111
|
+
return if not supported?(1.5)
|
112
|
+
|
113
|
+
glEnableClientState(GL_VERTEX_ARRAY)
|
114
|
+
va = [0,0, 0,1, 1,1].pack("f*")
|
115
|
+
|
116
|
+
#
|
117
|
+
buffers = glGenBuffers(1)
|
118
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffers[0])
|
119
|
+
glBufferData(GL_ARRAY_BUFFER,6*4,va,GL_DYNAMIC_DRAW)
|
120
|
+
|
121
|
+
glVertexPointer(2,GL_FLOAT,0,0)
|
122
|
+
assert_equal(glGetPointerv(GL_VERTEX_ARRAY_POINTER),0)
|
123
|
+
#
|
124
|
+
feedback = glFeedbackBuffer(256,GL_3D)
|
125
|
+
glRenderMode(GL_FEEDBACK)
|
126
|
+
|
127
|
+
glDrawElements(GL_TRIANGLES,3,GL_UNSIGNED_BYTE,[0,1,2].pack("f*"))
|
128
|
+
|
129
|
+
count = glRenderMode(GL_RENDER)
|
130
|
+
assert_equal(count,11)
|
131
|
+
|
132
|
+
glDeleteBuffers(buffers)
|
133
|
+
glDisableClientState(GL_VERTEX_ARRAY)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_buffer_binding_array_2
|
137
|
+
return if not supported?(1.5)
|
138
|
+
|
139
|
+
efa = [0].pack("C*")
|
140
|
+
na = [0,1,0].pack("f*")
|
141
|
+
ca = [1,0,1,0].pack("f*")
|
142
|
+
ta = [1,0,1,0].pack("f*")
|
143
|
+
|
144
|
+
buffers = glGenBuffers(4)
|
145
|
+
# load data into buffers
|
146
|
+
buffer_efa,buffer_na,buffer_ca,buffer_ta = buffers
|
147
|
+
|
148
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_efa)
|
149
|
+
glBufferData(GL_ARRAY_BUFFER,1,efa,GL_DYNAMIC_DRAW)
|
150
|
+
|
151
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_na)
|
152
|
+
glBufferData(GL_ARRAY_BUFFER,3*4,na,GL_DYNAMIC_DRAW)
|
153
|
+
|
154
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_ca)
|
155
|
+
glBufferData(GL_ARRAY_BUFFER,4*4,ca,GL_DYNAMIC_DRAW)
|
156
|
+
|
157
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_ta)
|
158
|
+
glBufferData(GL_ARRAY_BUFFER,4*4,ta,GL_DYNAMIC_DRAW)
|
159
|
+
|
160
|
+
# load buffers into arrays
|
161
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_na)
|
162
|
+
glEdgeFlagPointer(0,0)
|
163
|
+
assert_equal(glGetPointerv(GL_EDGE_FLAG_ARRAY_POINTER),0)
|
164
|
+
|
165
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_na)
|
166
|
+
glNormalPointer(GL_FLOAT,0,0)
|
167
|
+
assert_equal(glGetPointerv(GL_NORMAL_ARRAY_POINTER),0)
|
168
|
+
|
169
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_ca)
|
170
|
+
glColorPointer(4,GL_FLOAT,0,0)
|
171
|
+
assert_equal(glGetPointerv(GL_COLOR_ARRAY_POINTER),0)
|
172
|
+
|
173
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_ta)
|
174
|
+
glTexCoordPointer(4,GL_FLOAT,0,0)
|
175
|
+
assert_equal(glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER),0)
|
176
|
+
|
177
|
+
# not really testing index
|
178
|
+
glIndexPointer(GL_INT,2,0)
|
179
|
+
assert_equal(glGetPointerv(GL_INDEX_ARRAY_POINTER),0)
|
180
|
+
|
181
|
+
# draw arrays
|
182
|
+
glEnable(GL_NORMAL_ARRAY)
|
183
|
+
glEnable(GL_COLOR_ARRAY)
|
184
|
+
glEnable(GL_TEXTURE_COORD_ARRAY)
|
185
|
+
glEnable(GL_EDGE_FLAG_ARRAY)
|
186
|
+
|
187
|
+
glBegin(GL_TRIANGLES)
|
188
|
+
glArrayElement(0)
|
189
|
+
glEnd()
|
190
|
+
|
191
|
+
assert_equal(glGetDoublev(GL_CURRENT_NORMAL),[0,1,0])
|
192
|
+
assert_equal(glGetDoublev(GL_CURRENT_COLOR),[1,0,1,0])
|
193
|
+
assert_equal(glGetDoublev(GL_CURRENT_TEXTURE_COORDS),[1,0,1,0])
|
194
|
+
assert_equal(glGetDoublev(GL_EDGE_FLAG),GL_FALSE)
|
195
|
+
|
196
|
+
glDisable(GL_EDGE_FLAG_ARRAY)
|
197
|
+
glDisable(GL_TEXTURE_COORD_ARRAY)
|
198
|
+
glDisable(GL_COLOR_ARRAY)
|
199
|
+
glDisable(GL_NORMAL_ARRAY)
|
200
|
+
|
201
|
+
glDeleteBuffers(buffers)
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_buffer_binding_array_3
|
205
|
+
return if not supported?(1.5)
|
206
|
+
|
207
|
+
sc = [0,1,0].pack("f*")
|
208
|
+
fc = [1].pack("f*")
|
209
|
+
|
210
|
+
buffers = glGenBuffers(2)
|
211
|
+
# load data into buffers
|
212
|
+
buffer_sc,buffer_fc = buffers
|
213
|
+
|
214
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_sc)
|
215
|
+
glBufferData(GL_ARRAY_BUFFER,3*4,sc,GL_DYNAMIC_DRAW)
|
216
|
+
|
217
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_fc)
|
218
|
+
glBufferData(GL_ARRAY_BUFFER,1*4,fc,GL_DYNAMIC_DRAW)
|
219
|
+
|
220
|
+
# load buffers into arrays
|
221
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_sc)
|
222
|
+
glSecondaryColorPointer(3,GL_FLOAT,0,0)
|
223
|
+
assert_equal(glGetPointerv(GL_SECONDARY_COLOR_ARRAY_POINTER),0)
|
224
|
+
|
225
|
+
glBindBuffer(GL_ARRAY_BUFFER,buffer_fc)
|
226
|
+
glFogCoordPointer(GL_FLOAT,0,0)
|
227
|
+
assert_equal(glGetPointerv(GL_FOG_COORD_ARRAY_POINTER),0)
|
228
|
+
|
229
|
+
# draw arrays
|
230
|
+
glEnableClientState(GL_SECONDARY_COLOR_ARRAY)
|
231
|
+
glEnableClientState(GL_FOG_COORD_ARRAY)
|
232
|
+
|
233
|
+
glBegin(GL_TRIANGLES)
|
234
|
+
glArrayElement(0)
|
235
|
+
glEnd()
|
236
|
+
|
237
|
+
assert_equal(glGetDoublev(GL_CURRENT_SECONDARY_COLOR),[0,1,0,1])
|
238
|
+
assert_equal(glGetDoublev(GL_CURRENT_FOG_COORD),1)
|
239
|
+
|
240
|
+
glDisableClientState(GL_SECONDARY_COLOR_ARRAY)
|
241
|
+
glDisableClientState(GL_FOG_COORD_ARRAY)
|
242
|
+
|
243
|
+
glDeleteBuffers(buffers)
|
244
|
+
end
|
245
|
+
|
246
|
+
def test_buffer_binding_array_4
|
247
|
+
return if not supported?(1.5)
|
248
|
+
va = [0,0, 1,0, 1,1, 0,0, 1,0, 0,1].pack("f*")
|
249
|
+
glVertexPointer(2,GL_FLOAT,0,va)
|
250
|
+
|
251
|
+
glEnable(GL_VERTEX_ARRAY)
|
252
|
+
|
253
|
+
buf = glFeedbackBuffer(256,GL_3D)
|
254
|
+
glRenderMode(GL_FEEDBACK)
|
255
|
+
|
256
|
+
data = [0,1,2,3,4,5]
|
257
|
+
buffers = glGenBuffers(3)
|
258
|
+
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,buffers[0])
|
259
|
+
glBufferData(GL_ELEMENT_ARRAY_BUFFER,6,data.pack("C*"),GL_DYNAMIC_DRAW)
|
260
|
+
|
261
|
+
glMultiDrawElements(GL_TRIANGLES,GL_UNSIGNED_BYTE,[3,3],[0,3])
|
262
|
+
|
263
|
+
count = glRenderMode(GL_RENDER)
|
264
|
+
assert_equal(count,(3*3+2)*2)
|
265
|
+
|
266
|
+
glDisable(GL_VERTEX_ARRAY)
|
267
|
+
glDeleteBuffers(buffers)
|
268
|
+
end
|
269
|
+
|
82
270
|
end
|
data/test/tc_func_20.rb
CHANGED
@@ -25,7 +25,7 @@ class Test_20 < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_glblendequationseparate
|
28
|
-
return if not supported?(
|
28
|
+
return if not supported?(2.0)
|
29
29
|
glBlendEquationSeparate(GL_MIN,GL_MAX)
|
30
30
|
assert_equal(glGetIntegerv(GL_BLEND_EQUATION_RGB),GL_MIN)
|
31
31
|
assert_equal(glGetIntegerv(GL_BLEND_EQUATION_ALPHA),GL_MAX)
|
@@ -35,7 +35,7 @@ class Test_20 < Test::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_stencilops
|
38
|
-
return if not supported?(
|
38
|
+
return if not supported?(2.0)
|
39
39
|
|
40
40
|
glStencilOpSeparate(GL_FRONT, GL_ZERO, GL_INCR, GL_DECR)
|
41
41
|
assert_equal(glGetIntegerv(GL_STENCIL_FAIL), GL_ZERO)
|
@@ -62,13 +62,14 @@ class Test_20 < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_gldrawbuf
|
65
|
-
return if not supported?(
|
66
|
-
glDrawBuffers([
|
67
|
-
assert_equal(glGetIntegerv(GL_DRAW_BUFFER0),
|
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)
|
68
69
|
end
|
69
70
|
|
70
71
|
def test_glvertexattrib
|
71
|
-
return if not supported?(
|
72
|
+
return if not supported?(2.0)
|
72
73
|
# 1
|
73
74
|
glVertexAttrib1d(1,2.0)
|
74
75
|
assert_equal(glGetVertexAttribdv(1,GL_CURRENT_VERTEX_ATTRIB), [2.0,0.0,0.0,1.0])
|
@@ -149,7 +150,7 @@ class Test_20 < Test::Unit::TestCase
|
|
149
150
|
end
|
150
151
|
|
151
152
|
def test_vertexattribpointer
|
152
|
-
return if not supported?(
|
153
|
+
return if not supported?(2.0)
|
153
154
|
|
154
155
|
vaa = [1,1,1,1, 2,2,2,2].pack("f*")
|
155
156
|
glVertexAttribPointer(1,4,GL_FLOAT,GL_FALSE,0,vaa)
|
@@ -166,7 +167,7 @@ class Test_20 < Test::Unit::TestCase
|
|
166
167
|
end
|
167
168
|
|
168
169
|
def test_shaders
|
169
|
-
return if not supported?(
|
170
|
+
return if not supported?(2.0)
|
170
171
|
|
171
172
|
vertex_shader_source = "void main() { gl_Position = ftransform();}"
|
172
173
|
|
@@ -214,7 +215,7 @@ class Test_20 < Test::Unit::TestCase
|
|
214
215
|
end
|
215
216
|
|
216
217
|
def test_shaders_2
|
217
|
-
return if not supported?(
|
218
|
+
return if not supported?(2.0)
|
218
219
|
|
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;}"
|
220
221
|
program = glCreateProgram()
|
@@ -287,7 +288,7 @@ class Test_20 < Test::Unit::TestCase
|
|
287
288
|
end
|
288
289
|
|
289
290
|
def test_shaders_3
|
290
|
-
return if not supported?(
|
291
|
+
return if not supported?(2.0)
|
291
292
|
|
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;}"
|
293
294
|
|
@@ -317,4 +318,29 @@ class Test_20 < Test::Unit::TestCase
|
|
317
318
|
glUniformMatrix4fv(tm4l, 1, GL_TRUE, [0,1,0,1, 1,0,1,0, 0,1,0,1, 1,0,1,0])
|
318
319
|
assert_equal(glGetUniformfv(program,tm4l),[0,1,0,1, 1,0,1,0, 0,1,0,1, 1,0,1,0])
|
319
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
|
320
346
|
end
|
data/test/tc_func_21.rb
CHANGED
@@ -25,7 +25,7 @@ class Test_21 < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_gluniformmatrix21
|
28
|
-
return if not supported?(
|
28
|
+
return if not supported?(2.1)
|
29
29
|
|
30
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
31
|
|
@@ -64,4 +64,447 @@ class Test_21 < Test::Unit::TestCase
|
|
64
64
|
glUniformMatrix4x3fv(tm43l, 1, GL_FALSE, [1,0,0, 0,1,0, 1,0,0, 0,1,0])
|
65
65
|
assert_equal(glGetUniformfv(program,tm43l),[1,0,0, 0,1,0, 1,0,0, 0,1,0])
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
|
+
def test_pixelunpack_bitmap
|
69
|
+
return if not supported?(2.1)
|
70
|
+
glOrtho(0,$window_size,0,$window_size,0,-1)
|
71
|
+
|
72
|
+
bitmap = [ 0x55 ] * 8 # 64 bits (8x8 bitmap), stipple pattern
|
73
|
+
glPixelStorei(GL_PACK_ALIGNMENT,1)
|
74
|
+
glPixelStorei(GL_UNPACK_ALIGNMENT,1)
|
75
|
+
|
76
|
+
buffers = glGenBuffers(1)
|
77
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
78
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,8,bitmap.pack("C*"),GL_DYNAMIC_DRAW)
|
79
|
+
|
80
|
+
glBitmap(8,8,0,0,0,0,0)
|
81
|
+
data = glReadPixels(0,0,8,8,GL_RED,GL_UNSIGNED_BYTE)
|
82
|
+
assert_equal(data.unpack("C*"),[0,255] * 32)
|
83
|
+
|
84
|
+
glDeleteBuffers(buffers)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_pixelunpack_color_convolution
|
88
|
+
return if not supported?(2.1)
|
89
|
+
|
90
|
+
ct = ([0]*3+[1]*3+[0]*3+[1]*3).pack("f*")
|
91
|
+
ct2 = ([1]*3+[0]*3+[1]*3+[0]*3).pack("f*")
|
92
|
+
|
93
|
+
buffers = glGenBuffers(2)
|
94
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
95
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,4*3*4,ct,GL_DYNAMIC_DRAW)
|
96
|
+
|
97
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
98
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,4*3*4,ct2,GL_DYNAMIC_DRAW)
|
99
|
+
|
100
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
101
|
+
glColorTable(GL_COLOR_TABLE,GL_RGB8,4,GL_RGB,GL_FLOAT,0)
|
102
|
+
assert_equal(glGetColorTable(GL_COLOR_TABLE,GL_RGB,GL_FLOAT),ct)
|
103
|
+
glConvolutionFilter1D(GL_CONVOLUTION_1D, GL_RGB8, 4, GL_RGB, GL_FLOAT,0)
|
104
|
+
assert_equal(glGetConvolutionFilter(GL_CONVOLUTION_1D, GL_RGB, GL_FLOAT),ct)
|
105
|
+
|
106
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
107
|
+
glColorSubTable(GL_COLOR_TABLE,0,4,GL_RGB,GL_FLOAT,0)
|
108
|
+
assert_equal(glGetColorTable(GL_COLOR_TABLE,GL_RGB,GL_FLOAT),ct2)
|
109
|
+
glConvolutionFilter2D(GL_CONVOLUTION_2D, GL_RGB8, 2,2, GL_RGB, GL_FLOAT,0)
|
110
|
+
assert_equal(glGetConvolutionFilter(GL_CONVOLUTION_2D, GL_RGB, GL_FLOAT),ct2)
|
111
|
+
|
112
|
+
glDeleteBuffers(buffers)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_pixelunpack_separable
|
116
|
+
return if not supported?(2.1)
|
117
|
+
|
118
|
+
sf_a = ([0]*3+[1]*3).pack("f*")
|
119
|
+
sf_b = ([1]*3+[0]*3).pack("f*")
|
120
|
+
|
121
|
+
buffers = glGenBuffers(1)
|
122
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
123
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,2*3*4 *2,sf_a + sf_b,GL_DYNAMIC_DRAW)
|
124
|
+
|
125
|
+
glSeparableFilter2D(GL_SEPARABLE_2D,GL_RGB8, 2,2,GL_RGB,GL_FLOAT,0,2*3*4)
|
126
|
+
assert_equal(glGetSeparableFilter(GL_SEPARABLE_2D,GL_RGB,GL_FLOAT), [sf_a,sf_b])
|
127
|
+
|
128
|
+
glDeleteBuffers(buffers)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_pixelunpack_drawpixels
|
132
|
+
return if not supported?(2.1)
|
133
|
+
|
134
|
+
glClearColor(0,0,0,0)
|
135
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
136
|
+
|
137
|
+
image = ([1.0] * 3 * 16).pack("f*")
|
138
|
+
|
139
|
+
buffers = glGenBuffers(1)
|
140
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
141
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,3*16*4,image,GL_DYNAMIC_DRAW)
|
142
|
+
|
143
|
+
glDrawPixels(4,4,GL_RGB,GL_FLOAT,0)
|
144
|
+
|
145
|
+
data = glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT)
|
146
|
+
assert_equal(data,image)
|
147
|
+
|
148
|
+
glDeleteBuffers(buffers)
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_pixelunpack_polygonstipple
|
152
|
+
return if not supported?(2.1)
|
153
|
+
|
154
|
+
stipple = ([0x12] * 128).pack("c*")
|
155
|
+
buffers = glGenBuffers(1)
|
156
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
157
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,128,stipple,GL_DYNAMIC_DRAW)
|
158
|
+
|
159
|
+
glPolygonStipple(0)
|
160
|
+
assert_equal(glGetPolygonStipple(),stipple)
|
161
|
+
glDeleteBuffers(buffers)
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
def test_pixelunpack_texturecompression
|
166
|
+
return if not supported?(2.1)
|
167
|
+
return if not supported?("GL_EXT_texture_compression_s3tc")
|
168
|
+
|
169
|
+
# S3TC/DXT5 compressed 2x2 pixels stipple patterns [w,b,b,w] and [b,w,w,b]
|
170
|
+
image_1 = [0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x01,0x54,0x5C,0x5C].pack("C*")
|
171
|
+
image_2 = [0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x54,0x01,0x0D,0x0D].pack("C*")
|
172
|
+
|
173
|
+
textures = glGenTextures(3)
|
174
|
+
glBindTexture(GL_TEXTURE_1D,textures[0])
|
175
|
+
glBindTexture(GL_TEXTURE_2D,textures[1])
|
176
|
+
glBindTexture(GL_TEXTURE_3D,textures[2])
|
177
|
+
|
178
|
+
buffers = glGenBuffers(2)
|
179
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
180
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,16,image_1,GL_DYNAMIC_DRAW)
|
181
|
+
|
182
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
183
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,16,image_2,GL_DYNAMIC_DRAW)
|
184
|
+
|
185
|
+
# Note: 1D and 3D compressed textures are not supported by S3TC/DXTn, and usually not supported at all
|
186
|
+
|
187
|
+
# 1D
|
188
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
189
|
+
glCompressedTexImage1D(GL_TEXTURE_1D,0,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,4,0,16,0)
|
190
|
+
err = glGetError()
|
191
|
+
assert(err == 0 || err == GL_INVALID_ENUM || err == GL_INVALID_OPERATION)
|
192
|
+
if (err == 0)
|
193
|
+
assert_equal(glGetCompressedTexImage(GL_TEXTURE_1D,0), image_1)
|
194
|
+
end
|
195
|
+
|
196
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
197
|
+
glCompressedTexSubImage1D(GL_TEXTURE_1D,0,0,4,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,16,0)
|
198
|
+
err = glGetError()
|
199
|
+
assert(err == 0 || err == GL_INVALID_ENUM || err == GL_INVALID_OPERATION)
|
200
|
+
if (err == 0)
|
201
|
+
assert_equal(glGetCompressedTexImage(GL_TEXTURE_1D,0), image_2)
|
202
|
+
end
|
203
|
+
|
204
|
+
# 2D
|
205
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
206
|
+
glCompressedTexImage2D(GL_TEXTURE_2D,0,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,2,2,0,16,0)
|
207
|
+
assert_equal(glGetCompressedTexImage(GL_TEXTURE_2D,0), image_1)
|
208
|
+
|
209
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
210
|
+
glCompressedTexSubImage2D(GL_TEXTURE_2D,0,0,0,2,2,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,16,0)
|
211
|
+
assert_equal(glGetCompressedTexImage(GL_TEXTURE_2D,0), image_2)
|
212
|
+
|
213
|
+
# 3D
|
214
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
215
|
+
glCompressedTexImage3D(GL_TEXTURE_3D,0,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,2,2,1,0,16,0)
|
216
|
+
err = glGetError()
|
217
|
+
assert(err == 0 || err == GL_INVALID_ENUM || err == GL_INVALID_OPERATION)
|
218
|
+
if (err == 0)
|
219
|
+
assert_equal(glGetCompressedTexImage(GL_TEXTURE_3D,0), image_1)
|
220
|
+
end
|
221
|
+
|
222
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
223
|
+
glCompressedTexSubImage3D(GL_TEXTURE_3D,0, 0,0,0, 2,2,1, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 16, 0)
|
224
|
+
err = glGetError()
|
225
|
+
assert(err == 0 || err == GL_INVALID_ENUM || err == GL_INVALID_OPERATION)
|
226
|
+
if (err == 0)
|
227
|
+
assert_equal(glGetCompressedTexImage(GL_TEXTURE_3D,0), image_2)
|
228
|
+
end
|
229
|
+
|
230
|
+
glDeleteBuffers(buffers)
|
231
|
+
glDeleteTextures(textures)
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_pixelunpack_texture
|
235
|
+
return if not supported?(2.1)
|
236
|
+
|
237
|
+
textures = glGenTextures(3)
|
238
|
+
image_1 = ([0,0,0,1,1,1] * 8).pack("f*") # 16 RGB pixels
|
239
|
+
image_2 = ([1,1,1,0,0,0] * 8).pack("f*") # 16 RGB pixels
|
240
|
+
|
241
|
+
buffers = glGenBuffers(2)
|
242
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
243
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,6*8*4,image_1,GL_DYNAMIC_DRAW)
|
244
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
245
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,6*8*4,image_2,GL_DYNAMIC_DRAW)
|
246
|
+
|
247
|
+
# 3D
|
248
|
+
glBindTexture(GL_TEXTURE_3D,textures[0])
|
249
|
+
|
250
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
251
|
+
glTexImage3D(GL_TEXTURE_3D,0,GL_RGB8,2,2,4,0,GL_RGB,GL_FLOAT,0)
|
252
|
+
assert_equal(glGetTexImage(GL_TEXTURE_3D,0,GL_RGB,GL_FLOAT),image_1)
|
253
|
+
|
254
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
255
|
+
glTexSubImage3D(GL_TEXTURE_3D,0, 0,0,0, 2,2,4,GL_RGB,GL_FLOAT,0)
|
256
|
+
assert_equal(glGetTexImage(GL_TEXTURE_3D,0,GL_RGB,GL_FLOAT),image_2)
|
257
|
+
|
258
|
+
# 2D
|
259
|
+
glBindTexture(GL_TEXTURE_2D,textures[1])
|
260
|
+
|
261
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
262
|
+
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8, 4, 4, 0, GL_RGB, GL_FLOAT, 0)
|
263
|
+
assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT), image_1)
|
264
|
+
|
265
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
266
|
+
glTexSubImage2D(GL_TEXTURE_2D,0, 0,0, 4,4,GL_RGB,GL_FLOAT,0)
|
267
|
+
assert_equal(glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT),image_2)
|
268
|
+
|
269
|
+
# 1D
|
270
|
+
glBindTexture(GL_TEXTURE_1D,textures[2])
|
271
|
+
|
272
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
273
|
+
|
274
|
+
glTexImage1D(GL_TEXTURE_1D,0,GL_RGB8, 16, 0, GL_RGB, GL_FLOAT, 0)
|
275
|
+
assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT), image_1)
|
276
|
+
|
277
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[1])
|
278
|
+
glTexSubImage1D(GL_TEXTURE_1D,0, 0, 16,GL_RGB,GL_FLOAT,0)
|
279
|
+
assert_equal(glGetTexImage(GL_TEXTURE_1D,0,GL_RGB,GL_FLOAT),image_2)
|
280
|
+
|
281
|
+
glDeleteBuffers(buffers)
|
282
|
+
glDeleteTextures(textures)
|
283
|
+
end
|
284
|
+
|
285
|
+
def test_pixelunpack_pixelmap
|
286
|
+
return if not supported?(2.1)
|
287
|
+
data_1 = [1,2,3,4].pack("f*")
|
288
|
+
data_2 = [5,6,7,8].pack("I*")
|
289
|
+
data_3 = [9,10,11,12].pack("S*")
|
290
|
+
|
291
|
+
buffers = glGenBuffers(3)
|
292
|
+
glBindBuffer(GL_PIXEL_UNPACK_BUFFER,buffers[0])
|
293
|
+
glBufferData(GL_PIXEL_UNPACK_BUFFER,4*4+4*4+4*2,data_1+data_2+data_3,GL_DYNAMIC_DRAW)
|
294
|
+
|
295
|
+
glPixelMapfv(GL_PIXEL_MAP_I_TO_I,4,0)
|
296
|
+
assert_equal(glGetPixelMapfv(GL_PIXEL_MAP_I_TO_I), [1,2,3,4])
|
297
|
+
|
298
|
+
glPixelMapuiv(GL_PIXEL_MAP_I_TO_I,4,4*4)
|
299
|
+
assert_equal(glGetPixelMapuiv(GL_PIXEL_MAP_I_TO_I),[5,6,7,8])
|
300
|
+
|
301
|
+
glPixelMapusv(GL_PIXEL_MAP_I_TO_I,4,4*4+4*4)
|
302
|
+
assert_equal(glGetPixelMapusv(GL_PIXEL_MAP_I_TO_I),[9,10,11,12])
|
303
|
+
|
304
|
+
glDeleteBuffers(buffers)
|
305
|
+
end
|
306
|
+
|
307
|
+
def test_pixelpack_readpixels
|
308
|
+
return if not supported?(2.1)
|
309
|
+
glClearColor(0,0,0,0)
|
310
|
+
glClear(GL_COLOR_BUFFER_BIT)
|
311
|
+
|
312
|
+
image = ([1.0] * 3 * 16).pack("f*")
|
313
|
+
glDrawPixels(4,4,GL_RGB,GL_FLOAT,image)
|
314
|
+
|
315
|
+
buffers = glGenBuffers(1)
|
316
|
+
glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
|
317
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,4*4*4*3, nil, GL_STREAM_READ)
|
318
|
+
glReadPixels(0,0,4,4,GL_RGB,GL_FLOAT,0)
|
319
|
+
|
320
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
321
|
+
assert_equal(data,image)
|
322
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
323
|
+
|
324
|
+
glDeleteBuffers(buffers)
|
325
|
+
end
|
326
|
+
|
327
|
+
def test_pixelpack_pixelmap
|
328
|
+
return if not supported?(2.1)
|
329
|
+
|
330
|
+
buffers = glGenBuffers(1)
|
331
|
+
glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
|
332
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,4*4, nil, GL_STREAM_READ)
|
333
|
+
|
334
|
+
# fv
|
335
|
+
glPixelMapfv(GL_PIXEL_MAP_I_TO_I,[1,2,3,4])
|
336
|
+
glGetPixelMapfv(GL_PIXEL_MAP_I_TO_I,0)
|
337
|
+
|
338
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
339
|
+
assert_equal([1,2,3,4].pack("f*"),data)
|
340
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
341
|
+
|
342
|
+
# uiv
|
343
|
+
glPixelMapuiv(GL_PIXEL_MAP_I_TO_I,[5,6,7,8])
|
344
|
+
glGetPixelMapuiv(GL_PIXEL_MAP_I_TO_I,0)
|
345
|
+
|
346
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
347
|
+
assert_equal([5,6,7,8].pack("I*"),data)
|
348
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
349
|
+
|
350
|
+
# usv
|
351
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,4*2, nil, GL_STREAM_READ)
|
352
|
+
|
353
|
+
glPixelMapusv(GL_PIXEL_MAP_I_TO_I,[9,10,11,12])
|
354
|
+
glGetPixelMapusv(GL_PIXEL_MAP_I_TO_I,0)
|
355
|
+
|
356
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
357
|
+
assert_equal([9,10,11,12].pack("S*"),data)
|
358
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
359
|
+
|
360
|
+
glDeleteBuffers(buffers)
|
361
|
+
end
|
362
|
+
|
363
|
+
def test_pixelpack_polygonstipple
|
364
|
+
return if not supported?(2.1)
|
365
|
+
|
366
|
+
stipple = [0x12] * 128
|
367
|
+
|
368
|
+
buffers = glGenBuffers(1)
|
369
|
+
glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
|
370
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,128, nil, GL_STREAM_READ)
|
371
|
+
|
372
|
+
glPolygonStipple(stipple.pack("c*"))
|
373
|
+
glGetPolygonStipple(0)
|
374
|
+
|
375
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
376
|
+
assert_equal(stipple.pack("c*"),data)
|
377
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
378
|
+
|
379
|
+
glDeleteBuffers(buffers)
|
380
|
+
end
|
381
|
+
|
382
|
+
def test_pixelpack_separablefilter
|
383
|
+
return if not supported?(2.1)
|
384
|
+
sf_a = ([0]*3+[1]*3).pack("f*")
|
385
|
+
sf_b = ([1]*3+[0]*3).pack("f*")
|
386
|
+
|
387
|
+
buffers = glGenBuffers(1)
|
388
|
+
glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
|
389
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,6*4 + 6*4, nil, GL_STREAM_READ)
|
390
|
+
|
391
|
+
glSeparableFilter2D(GL_SEPARABLE_2D,GL_RGB8, 2,2,GL_RGB,GL_FLOAT,sf_a,sf_b)
|
392
|
+
glGetSeparableFilter(GL_SEPARABLE_2D,GL_RGB,GL_FLOAT,0,6*4,0)
|
393
|
+
|
394
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
395
|
+
assert_equal(data,sf_a + sf_b)
|
396
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
397
|
+
|
398
|
+
glDeleteBuffers(buffers)
|
399
|
+
end
|
400
|
+
|
401
|
+
def test_pixelpack_convolutionfilter
|
402
|
+
return if not supported?(2.1)
|
403
|
+
|
404
|
+
cf = ([0]*3+[1]*3+[0]*3+[1]*3).pack("f*")
|
405
|
+
|
406
|
+
buffers = glGenBuffers(1)
|
407
|
+
glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
|
408
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,3*4*4, nil, GL_STREAM_READ)
|
409
|
+
|
410
|
+
glConvolutionFilter1D(GL_CONVOLUTION_1D, GL_RGB8, 4, GL_RGB, GL_FLOAT,cf)
|
411
|
+
|
412
|
+
glGetConvolutionFilter(GL_CONVOLUTION_1D, GL_RGB, GL_FLOAT,0)
|
413
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
414
|
+
assert_equal(data,cf)
|
415
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
416
|
+
|
417
|
+
glDeleteBuffers(buffers)
|
418
|
+
end
|
419
|
+
|
420
|
+
def test_pixelpack_histogram
|
421
|
+
return if not supported?(2.1)
|
422
|
+
|
423
|
+
glEnable(GL_HISTOGRAM)
|
424
|
+
|
425
|
+
glHistogram(GL_HISTOGRAM,1,GL_RGB8,GL_FALSE)
|
426
|
+
|
427
|
+
buffers = glGenBuffers(1)
|
428
|
+
glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
|
429
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,3*4, nil, GL_STREAM_READ)
|
430
|
+
|
431
|
+
glDrawPixels(2,1,GL_RGB,GL_FLOAT,[1,1,1,1,1,1].pack("f*"))
|
432
|
+
glGetHistogram(GL_HISTOGRAM,GL_FALSE,GL_RGB,GL_FLOAT,0)
|
433
|
+
|
434
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
435
|
+
assert_equal(data.unpack("f*"),[2,2,2])
|
436
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
437
|
+
|
438
|
+
glDeleteBuffers(buffers)
|
439
|
+
glDisable(GL_HISTOGRAM)
|
440
|
+
end
|
441
|
+
|
442
|
+
def test_pixelpack_minmax
|
443
|
+
return if not supported?(2.1)
|
444
|
+
|
445
|
+
glEnable(GL_MINMAX)
|
446
|
+
|
447
|
+
glMinmax(GL_MINMAX,GL_RGB8,GL_FALSE)
|
448
|
+
|
449
|
+
buffers = glGenBuffers(1)
|
450
|
+
glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
|
451
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,6*4, nil, GL_STREAM_READ)
|
452
|
+
|
453
|
+
glDrawPixels(2,1,GL_RGB,GL_FLOAT,[0,0,0,1,1,1].pack("f*"))
|
454
|
+
glGetMinmax(GL_MINMAX,GL_FALSE,GL_RGB,GL_FLOAT,0)
|
455
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
456
|
+
assert_equal(data.unpack("f*"),[0,0,0,1,1,1])
|
457
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
458
|
+
|
459
|
+
glDeleteBuffers(buffers)
|
460
|
+
glDisable(GL_MINMAX)
|
461
|
+
end
|
462
|
+
|
463
|
+
def test_pixelpack_teximage
|
464
|
+
return if not supported?(2.1)
|
465
|
+
|
466
|
+
textures = glGenTextures(1)
|
467
|
+
glBindTexture(GL_TEXTURE_2D,textures[0])
|
468
|
+
|
469
|
+
image = ([0,0,0,1,1,1] * 8).pack("f*") # 16 RGB pixels
|
470
|
+
|
471
|
+
buffers = glGenBuffers(1)
|
472
|
+
glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
|
473
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,16*3*4, nil, GL_STREAM_READ)
|
474
|
+
|
475
|
+
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8, 4, 4, 0, GL_RGB, GL_FLOAT, image)
|
476
|
+
glGetTexImage(GL_TEXTURE_2D,0,GL_RGB,GL_FLOAT,0)
|
477
|
+
|
478
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
479
|
+
assert_equal(data,image)
|
480
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
481
|
+
|
482
|
+
glDeleteBuffers(buffers)
|
483
|
+
glDeleteTextures(textures)
|
484
|
+
end
|
485
|
+
|
486
|
+
def test_pixelpack_compressedteximage
|
487
|
+
return if not supported?(2.1)
|
488
|
+
return if not supported?("GL_EXT_texture_compression_s3tc")
|
489
|
+
|
490
|
+
# S3TC/DXT5 compressed 2x2 pixels stipple pattern [w,b,b,w]
|
491
|
+
image = [0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x01,0x54,0x5C,0x5C].pack("C*")
|
492
|
+
|
493
|
+
textures = glGenTextures(1)
|
494
|
+
glBindTexture(GL_TEXTURE_2D,textures[0])
|
495
|
+
|
496
|
+
buffers = glGenBuffers(1)
|
497
|
+
glBindBuffer(GL_PIXEL_PACK_BUFFER,buffers[0])
|
498
|
+
glBufferData(GL_PIXEL_PACK_BUFFER_ARB,image.size, nil, GL_STREAM_READ)
|
499
|
+
|
500
|
+
glCompressedTexImage2D(GL_TEXTURE_2D,0,GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,2,2,0,16,image)
|
501
|
+
glGetCompressedTexImage(GL_TEXTURE_2D,0,0)
|
502
|
+
|
503
|
+
data = glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY)
|
504
|
+
assert_equal(data,image)
|
505
|
+
glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB)
|
506
|
+
|
507
|
+
glDeleteBuffers(buffers)
|
508
|
+
glDeleteTextures(textures)
|
509
|
+
end
|
510
|
+
end
|