Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kdashg committed Oct 5, 2020
1 parent 71413e9 commit 6cf1e72
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions sdk/tests/js/tests/ext-texture-filter-anisotropic.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if (!gl) {
if (contextVersion >= 2) {
runSamplerTestEnabled();
}
testFiltering();
}
}

Expand Down Expand Up @@ -162,5 +163,64 @@ function runSamplerTestEnabled() {
gl.deleteSampler(sampler);
}

function makeRgbaFramebuffer(gl, w, h) {
const tex = gl.createTexture();

let was = gl.getParameter(gl.TEXTURE_2D_BINDING);
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.bindTexture(gl.TEXTURE_2D, was);

const fb = gl.createFramebuffer();
was = gl.getParameter(gl.FRAMEBUFFER_BINDING);
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0,
gl.TEXTURE_2D, tex, 0);
gl.bindFramebuffer(gl.FRAMEBUFFER, was);

return fb;
}

function testFiltering() {
const fb = makeRgbaFramebuffer(gl, 1, 1);
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);

const DATA_LEVEL_0 = new Uint8Array([
255, 0, 0, 255,
0, 255, 0, 255,
0, 255, 0, 255,
255, 0, 0, 255,
]);

const DATA_LEVEL_1 = new Uint8Array([
0, 0, 255, 255,
]);

const tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, DATA_LEVEL_0);
gl.texImage2D(gl.TEXTURE_2D, 1, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, DATA_LEVEL_1);

const VS = `
void main() {
gl_Position = vec4(0, 0, 0, 1);
}
`;
const FS = `
uniform sampler2D u_tex0;
void main() {
gl_FragColor = texture2D(u_tex0, vec2(0.3, 0.3), 0.3);
}
`;










debug("");
var successfullyParsed = true;

0 comments on commit 6cf1e72

Please sign in to comment.