Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Necessary to upload the actual image data to the GPU. Without this the texture will be blank. Called automatically
- * in most cases due to loading and caching APIs. Flagging an image source with `_invalid = true` will trigger this
- * next time the image is rendered.
- * @param {WebGLRenderingContext} gl
- * @param {Image | Canvas} image The image data to be uploaded
- * @protected
- */
- p._updateTextureImageData = function (gl, image) {
- // the bitwise & is intentional, cheap exponent 2 check
- var isNPOT = (image.width & image.width-1) || (image.height & image.height-1);
- var texture = this._textureDictionary[image._storeID];
- gl.activeTexture(gl.TEXTURE0 + texture._activeIndex);
- gl.bindTexture(gl.TEXTURE_2D, texture);
- texture.isPOT = !isNPOT;
- this.setTextureParams(gl, texture.isPOT);
- try {
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
- } catch(e) {
- var errString = "\nAn error has occurred. This is most likely due to security restrictions on WebGL images with local or cross-domain origins";
- if(console.error) {
- //TODO: LM: I recommend putting this into a log function internally, since you do it so often, and each is implemented differently.
- console.error(errString);
- console.error(e);
- } else if (console) {
- console.log(errString);
- console.log(e);
- }
- }
- image._invalid = false;
- texture._w = image.width;
- texture._h = image.height;
- if (this.vocalDebug) {
- if (isNPOT) {
- console.warn("NPOT(Non Power of Two) Texture: "+ image.src);
- }
- if (image.width > gl.MAX_TEXTURE_SIZE || image.height > gl.MAX_TEXTURE_SIZE){
- console && console.error("Oversized Texture: "+ image.width+"x"+image.height +" vs "+ gl.MAX_TEXTURE_SIZE +"max");
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement