index.js
function(options) {
		var gl = this.gl;

		//If no options is provided... this method does nothing.
		if (!options)
			return;

		// width, height, format, dataType, data, genMipmaps

		//If 'src' is provided, try to load the image from a path...
		if (options.src && typeof options.src==="string") {
			var img = new Image();
			var path       = options.src;
			var crossOrigin = options.crossOrigin;
			var successCB  = typeof options.onLoad === "function" ? options.onLoad : null;
			var failCB     = typeof options.onError === "function" ? options.onError : null;
			var genMipmaps = options.genMipmaps;

			var self = this;

			//If you try to render a texture that is not yet "renderable" (i.e. the 
			//async load hasn't completed yet, which is always the case in Chrome since requestAnimationFrame
			//fires before img.onload), WebGL will throw us errors. So instead we will just upload some
			//dummy data until the texture load is complete. Users can disable this with the global flag.
			if (Texture.USE_DUMMY_1x1_DATA) {
				self.uploadData(1, 1);
				this.width = this.height = 0;
			}

			img.crossOrigin = crossOrigin;


			img.onload = function(ev) {
				self.uploadImage(img, undefined, undefined, genMipmaps);
				if (typeof successCB === "function")
					successCB.call(self, ev, self);
			}
			img.onerror = function(ev) {
				if (genMipmaps) //we still need to gen mipmaps on the 1x1 dummy
					gl.generateMipmap(gl.TEXTURE_2D);
				if (typeof failCB === "function")
					failCB.call(self, ev, self);
			}
			img.onabort = function(ev) {
				if (genMipmaps) 
					gl.generateMipmap(gl.TEXTURE_2D);
				if (typeof failCB === "function")
					failCB.call(self, ev, self);
			}

			img.src = path;
		} 
		//otherwise see if we have an 'image' specified
		else if (options.image) {
			this.uploadImage(options.image, options.format, 
							options.dataType, options.data, 
							options.genMipmaps);
		}
		//otherwise assume our regular list of width/height arguments are passed
		else {
			this.uploadData(options.width, options.height, options.format, 
							options.dataType, options.data, options.genMipmaps);
		}
	}
function(options) {
		var gl = this.gl;

		//If no options is provided... this method does nothing.
		if (!options)
			return;

		// width, height, format, dataType, data, genMipmaps

		//If 'src' is provided, try to load the image from a path...
		if (options.src && typeof options.src==="string") {
			var img = new Image();
			var path       = options.src;
			var crossOrigin = options.crossOrigin;
			var successCB  = typeof options.onLoad === "function" ? options.onLoad : null;
			var failCB     = typeof options.onError === "function" ? options.onError : null;
			var genMipmaps = options.genMipmaps;

			var self = this;

			//If you try to render a texture that is not yet "renderable" (i.e. the 
			//async load hasn't completed yet, which is always the case in Chrome since requestAnimationFrame
			//fires before img.onload), WebGL will throw us errors. So instead we will just upload some
			//dummy data until the texture load is complete. Users can disable this with the global flag.
			if (Texture.USE_DUMMY_1x1_DATA) {
				self.uploadData(1, 1);
				this.width = this.height = 0;
			}

			img.crossOrigin = crossOrigin;


			img.onload = function(ev) {
				self.uploadImage(img, undefined, undefined, genMipmaps);
				if (typeof successCB === "function")
					successCB.call(self, ev, self);
			}
			img.onerror = function(ev) {
				if (genMipmaps) //we still need to gen mipmaps on the 1x1 dummy
					gl.generateMipmap(gl.TEXTURE_2D);
				if (typeof failCB === "function")
					failCB.call(self, ev, self);
			}
			img.onabort = function(ev) {
				if (genMipmaps) 
					gl.generateMipmap(gl.TEXTURE_2D);
				if (typeof failCB === "function")
					failCB.call(self, ev, self);
			}

			img.src = path;
		} 
		//otherwise see if we have an 'image' specified
		else if (options.image) {
			this.uploadImage(options.image, options.format, 
							options.dataType, options.data, 
							options.genMipmaps);
		}
		//otherwise assume our regular list of width/height arguments are passed
		else {
			this.uploadData(options.width, options.height, options.format, 
							options.dataType, options.data, options.genMipmaps);
		}
	}
function ( options ) { var gl = this . gl ; //If no options is provided... this method does nothing. if ( ! options ) return ; // width, height, format, dataType, data, genMipmaps //If 'src' is provided, try to load the image from a path... if ( options . src && typeof options . src === "string" ) { var img = new Image ( ) ; var path = options . src ; var crossOrigin = options . crossOrigin ; var successCB = typeof options . onLoad === "function" ? options . onLoad : null ; var failCB = typeof options . onError === "function" ? options . onError : null ; var genMipmaps = options . genMipmaps ; var self = this ; //If you try to render a texture that is not yet "renderable" (i.e. the  //async load hasn't completed yet, which is always the case in Chrome since requestAnimationFrame //fires before img.onload), WebGL will throw us errors. So instead we will just upload some //dummy data until the texture load is complete. Users can disable this with the global flag. if ( Texture . USE_DUMMY_1x1_DATA ) { self . uploadData ( 1 , 1 ) ; this . width = this . height = 0 ; } img . crossOrigin = crossOrigin ; img . onload = function ( ev ) { self . uploadImage ( img , undefined , undefined , genMipmaps ) ; if ( typeof successCB === "function" ) successCB . call ( self , ev , self ) ; } img . onerror = function ( ev ) { if ( genMipmaps ) //we still need to gen mipmaps on the 1x1 dummy gl . generateMipmap ( gl . TEXTURE_2D ) ; if ( typeof failCB === "function" ) failCB . call ( self , ev , self ) ; } img . onabort = function ( ev ) { if ( genMipmaps ) gl . generateMipmap ( gl . TEXTURE_2D ) ; if ( typeof failCB === "function" ) failCB . call ( self , ev , self ) ; } img . src = path ; } //otherwise see if we have an 'image' specified else if ( options . image ) { this . uploadImage ( options . image , options . format , options . dataType , options . data , options . genMipmaps ) ; } //otherwise assume our regular list of width/height arguments are passed else { this . uploadData ( options . width , options . height , options . format , options . dataType , options . data , options . genMipmaps ) ; } }
This can be called after creating a Texture to load an Image object asynchronously,
or upload image data directly. It takes the same options as the constructor.

Users will generally not need to call this directly.

@protected
@method  setup
This can be called after creating a Texture to load an Image object asynchronously or upload image data directly . It takes the same options as the constructor .