src/video/webgl/compositor.js
function (unit, image, filter, repeat, w, h, b, premultipliedAlpha) {
            var gl = this.gl;

            repeat = repeat || "no-repeat";

            var isPOT = me.Math.isPowerOfTwo(w || image.width) && me.Math.isPowerOfTwo(h || image.height);
            var texture = gl.createTexture();
            var rs = (repeat.search(/^repeat(-x)?$/) === 0) && isPOT ? gl.REPEAT : gl.CLAMP_TO_EDGE;
            var rt = (repeat.search(/^repeat(-y)?$/) === 0) && isPOT ? gl.REPEAT : gl.CLAMP_TO_EDGE;

            gl.activeTexture(gl.TEXTURE0 + unit);
            gl.bindTexture(gl.TEXTURE_2D, texture);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, rs);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, rt);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
            gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, (typeof premultipliedAlpha === "boolean") ? premultipliedAlpha : true);
            if (w || h || b) {
                gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, b, gl.RGBA, gl.UNSIGNED_BYTE, image);
            }
            else {
                gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
            }

            return texture;
        }
function (unit, image, filter, repeat, w, h, b, premultipliedAlpha) {
            var gl = this.gl;

            repeat = repeat || "no-repeat";

            var isPOT = me.Math.isPowerOfTwo(w || image.width) && me.Math.isPowerOfTwo(h || image.height);
            var texture = gl.createTexture();
            var rs = (repeat.search(/^repeat(-x)?$/) === 0) && isPOT ? gl.REPEAT : gl.CLAMP_TO_EDGE;
            var rt = (repeat.search(/^repeat(-y)?$/) === 0) && isPOT ? gl.REPEAT : gl.CLAMP_TO_EDGE;

            gl.activeTexture(gl.TEXTURE0 + unit);
            gl.bindTexture(gl.TEXTURE_2D, texture);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, rs);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, rt);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
            gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, (typeof premultipliedAlpha === "boolean") ? premultipliedAlpha : true);
            if (w || h || b) {
                gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, b, gl.RGBA, gl.UNSIGNED_BYTE, image);
            }
            else {
                gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
            }

            return texture;
        }
function ( unit , image , filter , repeat , w , h , b , premultipliedAlpha ) { var gl = this . gl ; repeat = repeat || "no-repeat" ; var isPOT = me . Math . isPowerOfTwo ( w || image . width ) && me . Math . isPowerOfTwo ( h || image . height ) ; var texture = gl . createTexture ( ) ; var rs = ( repeat . search ( / ^repeat(-x)?$ / ) === 0 ) && isPOT ? gl . REPEAT : gl . CLAMP_TO_EDGE ; var rt = ( repeat . search ( / ^repeat(-y)?$ / ) === 0 ) && isPOT ? gl . REPEAT : gl . CLAMP_TO_EDGE ; gl . activeTexture ( gl . TEXTURE0 + unit ) ; gl . bindTexture ( gl . TEXTURE_2D , texture ) ; gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_S , rs ) ; gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_WRAP_T , rt ) ; gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MAG_FILTER , filter ) ; gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MIN_FILTER , filter ) ; gl . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , ( typeof premultipliedAlpha === "boolean" ) ? premultipliedAlpha : true ) ; if ( w || h || b ) { gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , w , h , b , gl . RGBA , gl . UNSIGNED_BYTE , image ) ; } else { gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , gl . RGBA , gl . UNSIGNED_BYTE , image ) ; } return texture ; }
Create a texture from an image
@name createTexture
@memberOf me.WebGLRenderer.Compositor
@function
@param {Number} unit Destination texture unit
@param {Image|Canvas|ImageData|UInt8Array[]|Float32Array[]} image Source image
@param {Number} filter gl.LINEAR or gl.NEAREST
@param {String} [repeat="no-repeat"] Image repeat behavior (see {@link me.ImageLayer#repeat})
@param {Number} [w] Source image width (Only use with UInt8Array[] or Float32Array[] source image)
@param {Number} [h] Source image height (Only use with UInt8Array[] or Float32Array[] source image)
@param {Number} [b] Source image border (Only use with UInt8Array[] or Float32Array[] source image)
@param {Number} [b] Source image border (Only use with UInt8Array[] or Float32Array[] source image)
@param {Boolean} [premultipliedAlpha=true] Multiplies the alpha channel into the other color channels
@return {WebGLTexture} A texture object
Create a texture from an image