index.js
function Texture(context, options) {
		if (!(this instanceof Texture))
			return new Texture(context, options);
		
		//sets up base Kami object..
		BaseObject.call(this, context);

		/**
		 * When a texture is created, we keep track of the arguments provided to 
		 * its constructor. On context loss and restore, these arguments are re-supplied
		 * to the Texture, so as to re-create it in its correct form.
		 *
		 * This is mainly useful if you are procedurally creating textures and passing
		 * their data directly (e.g. for generic lookup tables in a shader). For image
		 * or media based textures, it would be better to use an AssetManager to manage
		 * the asynchronous texture upload.
		 *
		 * Upon destroying a texture, a reference to this is also lost.
		 *
		 * @property managedArgs
		 * @type {Object} the options given to the Texture constructor, or undefined
		 */
		this.managedArgs = options;

		/**
		 * The WebGLTexture which backs this Texture object. This
		 * can be used for low-level GL calls.
		 * 
		 * @type {WebGLTexture}
		 */
		this.id = null; //initialized in create()

		/**
		 * The target for this texture unit, i.e. TEXTURE_2D. Subclasses
		 * should override the create() method to change this, for correct
		 * usage with context restore.
		 * 
		 * @property target
		 * @type {GLenum}
		 * @default  gl.TEXTURE_2D
		 */
		this.target = this.context.gl.TEXTURE_2D;

		/**
		 * The width of this texture, in pixels.
		 * 
		 * @property width
		 * @readOnly
		 * @type {Number} the width
		 */
		this.width = 0; //initialized on texture upload

		/**
		 * The height of this texture, in pixels.
		 * 
		 * @property height
		 * @readOnly
		 * @type {Number} the height
		 */
		this.height = 0; //initialized on texture upload

		this.__shape = [0, 0];

		/**
		 * The S wrap parameter.
		 * @property {GLenum} wrapS
		 */
		this.wrapS = Texture.DEFAULT_WRAP;
		/**
		 * The T wrap parameter.
		 * @property {GLenum} wrapT
		 */
		this.wrapT = Texture.DEFAULT_WRAP;
		/**
		 * The minifcation filter.
		 * @property {GLenum} minFilter 
		 */
		this.minFilter = Texture.DEFAULT_FILTER;
		
		/**
		 * The magnification filter.
		 * @property {GLenum} magFilter 
		 */
		this.magFilter = Texture.DEFAULT_FILTER;

		//manage if we're dealing with a kami-context
		this.context.addManagedObject(this);
		this.create();
	}
function Texture(context, options) {
		if (!(this instanceof Texture))
			return new Texture(context, options);
		
		//sets up base Kami object..
		BaseObject.call(this, context);

		/**
		 * When a texture is created, we keep track of the arguments provided to 
		 * its constructor. On context loss and restore, these arguments are re-supplied
		 * to the Texture, so as to re-create it in its correct form.
		 *
		 * This is mainly useful if you are procedurally creating textures and passing
		 * their data directly (e.g. for generic lookup tables in a shader). For image
		 * or media based textures, it would be better to use an AssetManager to manage
		 * the asynchronous texture upload.
		 *
		 * Upon destroying a texture, a reference to this is also lost.
		 *
		 * @property managedArgs
		 * @type {Object} the options given to the Texture constructor, or undefined
		 */
		this.managedArgs = options;

		/**
		 * The WebGLTexture which backs this Texture object. This
		 * can be used for low-level GL calls.
		 * 
		 * @type {WebGLTexture}
		 */
		this.id = null; //initialized in create()

		/**
		 * The target for this texture unit, i.e. TEXTURE_2D. Subclasses
		 * should override the create() method to change this, for correct
		 * usage with context restore.
		 * 
		 * @property target
		 * @type {GLenum}
		 * @default  gl.TEXTURE_2D
		 */
		this.target = this.context.gl.TEXTURE_2D;

		/**
		 * The width of this texture, in pixels.
		 * 
		 * @property width
		 * @readOnly
		 * @type {Number} the width
		 */
		this.width = 0; //initialized on texture upload

		/**
		 * The height of this texture, in pixels.
		 * 
		 * @property height
		 * @readOnly
		 * @type {Number} the height
		 */
		this.height = 0; //initialized on texture upload

		this.__shape = [0, 0];

		/**
		 * The S wrap parameter.
		 * @property {GLenum} wrapS
		 */
		this.wrapS = Texture.DEFAULT_WRAP;
		/**
		 * The T wrap parameter.
		 * @property {GLenum} wrapT
		 */
		this.wrapT = Texture.DEFAULT_WRAP;
		/**
		 * The minifcation filter.
		 * @property {GLenum} minFilter 
		 */
		this.minFilter = Texture.DEFAULT_FILTER;
		
		/**
		 * The magnification filter.
		 * @property {GLenum} magFilter 
		 */
		this.magFilter = Texture.DEFAULT_FILTER;

		//manage if we're dealing with a kami-context
		this.context.addManagedObject(this);
		this.create();
	}
function Texture ( context , options ) { if ( ! ( this instanceof Texture ) ) return new Texture ( context , options ) ; //sets up base Kami object.. BaseObject . call ( this , context ) ; /**
		 * When a texture is created, we keep track of the arguments provided to 
		 * its constructor. On context loss and restore, these arguments are re-supplied
		 * to the Texture, so as to re-create it in its correct form.
		 *
		 * This is mainly useful if you are procedurally creating textures and passing
		 * their data directly (e.g. for generic lookup tables in a shader). For image
		 * or media based textures, it would be better to use an AssetManager to manage
		 * the asynchronous texture upload.
		 *
		 * Upon destroying a texture, a reference to this is also lost.
		 *
		 * @property managedArgs
		 * @type {Object} the options given to the Texture constructor, or undefined
		 */ this . managedArgs = options ; /**
		 * The WebGLTexture which backs this Texture object. This
		 * can be used for low-level GL calls.
		 * 
		 * @type {WebGLTexture}
		 */ this . id = null ; //initialized in create() /**
		 * The target for this texture unit, i.e. TEXTURE_2D. Subclasses
		 * should override the create() method to change this, for correct
		 * usage with context restore.
		 * 
		 * @property target
		 * @type {GLenum}
		 * @default  gl.TEXTURE_2D
		 */ this . target = this . context . gl . TEXTURE_2D ; /**
		 * The width of this texture, in pixels.
		 * 
		 * @property width
		 * @readOnly
		 * @type {Number} the width
		 */ this . width = 0 ; //initialized on texture upload /**
		 * The height of this texture, in pixels.
		 * 
		 * @property height
		 * @readOnly
		 * @type {Number} the height
		 */ this . height = 0 ; //initialized on texture upload this . __shape = [ 0 , 0 ] ; /**
		 * The S wrap parameter.
		 * @property {GLenum} wrapS
		 */ this . wrapS = Texture . DEFAULT_WRAP ; /**
		 * The T wrap parameter.
		 * @property {GLenum} wrapT
		 */ this . wrapT = Texture . DEFAULT_WRAP ; /**
		 * The minifcation filter.
		 * @property {GLenum} minFilter 
		 */ this . minFilter = Texture . DEFAULT_FILTER ; /**
		 * The magnification filter.
		 * @property {GLenum} magFilter 
		 */ this . magFilter = Texture . DEFAULT_FILTER ; //manage if we're dealing with a kami-context this . context . addManagedObject ( this ) ; this . create ( ) ; }
Creates a new texture with the optional width, height, and data.

If the constructor is passed no parameters other than the context, then
it will not be initialized and will be non-renderable. You will need to manually
uploadData or uploadImage yourself.

If the options passed includes 'src', it assumes an image is to be loaded,
and will use the width/height from that resulting image. Otherwise, it
will look for 'data', which may be a typed array or any valid "image" object.
A typed array will need its width/height passed explicitly.

If the context is a kami-context, we will try to manage the Texture object by
keeping the arguments in memory for future use.

Most users will want to use the AssetManager to create and manage their textures
with asynchronous loading and context loss.

@class  Texture
@constructor
@param  {WebGLRenderingContext|kami-context} context the WebGL context
@param  {Object} options the options to create this texture
@param {String} options.src the path to the image file, if ommitted we assume data will be given
@param {Function} options.onLoad called when the image is loaded (if src is provided)
@param {Function} options.onError called when there was an error loading the image (if src is provided)
@param {String} options.crossOrigin the image cross-origin parameter (if src is provided)
@param {ArrayBuffer} options.data some typed array with texture data, ignored if 'src' is specified
@param {GLenum} options.format the texture format, default Texture.Format.RGBA (for when data is specified)
@param {GLenum} options.type the data type, default Texture.DataType.UNSIGNED_BYTE (for when data is specified)
@param {Number} options.width the width of the texture (if we are not specifying an image URL)
@param {Number} options.height the height of the texture (if we are not specifying an image URL)
@param {Boolean} options.genMipmaps whether to generate mipmaps after upload
Creates a new texture with the optional width height and data .