MCPcopy Create free account
hub / github.com/Ice-Hazymoon/MikuTools / createTexture

Function createTexture

utils/anime4k.js:47–78  ·  view source on GitHub ↗
(gl, filter, data, width, height)

Source from the content-addressed store, hash-verified

45}
46
47function createTexture(gl, filter, data, width, height) {
48 var texture = gl.createTexture();
49 gl.bindTexture(gl.TEXTURE_2D, texture);
50 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
51 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
52 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
53 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
54 if (data instanceof Uint8Array) {
55 gl.texImage2D(
56 gl.TEXTURE_2D,
57 0,
58 gl.RGBA,
59 width,
60 height,
61 0,
62 gl.RGBA,
63 gl.UNSIGNED_BYTE,
64 data
65 );
66 } else {
67 gl.texImage2D(
68 gl.TEXTURE_2D,
69 0,
70 gl.RGBA,
71 gl.RGBA,
72 gl.UNSIGNED_BYTE,
73 data
74 );
75 }
76 gl.bindTexture(gl.TEXTURE_2D, null);
77 return texture;
78}
79
80function bindTexture(gl, texture, unit) {
81 gl.activeTexture(gl.TEXTURE0 + unit);

Callers 1

anime4k.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected