Skip to content

Commit 6cf1e72

Browse files
committed
wip
1 parent 71413e9 commit 6cf1e72

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

sdk/tests/js/tests/ext-texture-filter-anisotropic.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ if (!gl) {
3434
if (contextVersion >= 2) {
3535
runSamplerTestEnabled();
3636
}
37+
testFiltering();
3738
}
3839
}
3940

@@ -162,5 +163,64 @@ function runSamplerTestEnabled() {
162163
gl.deleteSampler(sampler);
163164
}
164165

166+
function makeRgbaFramebuffer(gl, w, h) {
167+
const tex = gl.createTexture();
168+
169+
let was = gl.getParameter(gl.TEXTURE_2D_BINDING);
170+
gl.bindTexture(gl.TEXTURE_2D, tex);
171+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
172+
gl.bindTexture(gl.TEXTURE_2D, was);
173+
174+
const fb = gl.createFramebuffer();
175+
was = gl.getParameter(gl.FRAMEBUFFER_BINDING);
176+
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
177+
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0,
178+
gl.TEXTURE_2D, tex, 0);
179+
gl.bindFramebuffer(gl.FRAMEBUFFER, was);
180+
181+
return fb;
182+
}
183+
184+
function testFiltering() {
185+
const fb = makeRgbaFramebuffer(gl, 1, 1);
186+
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
187+
188+
const DATA_LEVEL_0 = new Uint8Array([
189+
255, 0, 0, 255,
190+
0, 255, 0, 255,
191+
0, 255, 0, 255,
192+
255, 0, 0, 255,
193+
]);
194+
195+
const DATA_LEVEL_1 = new Uint8Array([
196+
0, 0, 255, 255,
197+
]);
198+
199+
const tex = gl.createTexture();
200+
gl.bindTexture(gl.TEXTURE_2D, tex);
201+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, DATA_LEVEL_0);
202+
gl.texImage2D(gl.TEXTURE_2D, 1, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, DATA_LEVEL_1);
203+
204+
const VS = `
205+
void main() {
206+
gl_Position = vec4(0, 0, 0, 1);
207+
}
208+
`;
209+
const FS = `
210+
uniform sampler2D u_tex0;
211+
void main() {
212+
gl_FragColor = texture2D(u_tex0, vec2(0.3, 0.3), 0.3);
213+
}
214+
`;
215+
216+
217+
218+
219+
220+
221+
222+
223+
224+
165225
debug("");
166226
var successfullyParsed = true;

0 commit comments

Comments
 (0)