Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2012-11-19 0:05

Class SpiderGL.WebGL.Texture

The SpiderGL.WebGL.Texture is the base class for all WebGLTexture object wrappers, i.e. SpiderGL.WebGL.Texture2D and SpiderGL.WebGL.TextureCubeMap.

Class Summary
Constructor Attributes Constructor Name and Description
 
SpiderGL.WebGL.Texture(gl, target, options)
Creates a SpiderGL.WebGL.Texture.
Field Summary
Field Attributes Field Name and Description
 
Gets/Sets the automatic mipmap generation.
 
Gets/Sets the colorspace conversionpolicy.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_AUTO_GENERATE_MIPMAP
Default value for SpiderGL.WebGL.Texture#autoMipmap
<static>  
SpiderGL.WebGL.Texture.DEFAULT_BORDER
Default texture border when calling setImage
<static>  
SpiderGL.WebGL.Texture.DEFAULT_FORMAT
Default texture input data format when calling setImage or setSubImage.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_INTERNAL_FORMAT
Default texture internal format when calling setImage.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_LEVEL
Default texture level when calling setImage.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_MAG_FILTER
Default texture magnification filter.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_MIN_FILTER
Default texture minification filter.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_TYPE
Default texture input data type when calling setImage or setSubImage.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_UNPACK_COLORSPACE_CONVERSION
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_COLORSPACE_CONVERSION_WEBGL when calling setImage or setSubImage.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_UNPACK_FLIP_Y
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL when calling setImage or setSubImage.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL when calling setImage or setSubImage.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_WRAP_S
Default texture wrap mode in horizontal direction.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_WRAP_T
Default texture wrap mode in vertical direction.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_X_OFFSET
Default texture sub-image x offset when calling setSubImage.
<static>  
SpiderGL.WebGL.Texture.DEFAULT_Y_OFFSET
Default texture sub-image y offset when calling setSubImage.
 
Gets/Sets the flip Y policy.
<readonly>  
Gets the texture image internal format.
<readonly>  
Gets the texture image height.
<readonly>  
Tests if the texture is ready to use.
 
Gets/Sets the texture magnification filter.
 
Gets/Sets the texture minification filter.
 
Gets/Sets the premultiply alpha policy.
<readonly>  
Gets the texture image width.
 
Gets/Sets the texture horizontal wrap mode.
 
Gets/Sets the texture vertical wrap mode.
Fields borrowed from class SpiderGL.WebGL.ObjectGL:
gl, handle, isValid, target
Fields borrowed from class SpiderGL.Core.ObjectBase:
uid

Method Summary

Method Attributes Method Name and Description
 
bind(unit)
Binds the texture to the appropriate target for SpiderGL.WebGL.Texture2D and SpiderGL.WebGL.TextureCubeMap.
 
Destroys the WebGLTexture.
 
Generates the mipmap pyramid.
 
Gets the texture sampling (filtering and addressing) mode.
 
setSampler(sampler)
Sets the texture sampling (filtering and addressing) mode.
 
unbind(unit)
Binds "null" to the appropriate texture target for SpiderGL.WebGL.Texture2D and SpiderGL.WebGL.TextureCubeMap.
<static>  
SpiderGL.WebGL.Texture.unbind(gl)

Class Detail

SpiderGL.WebGL.Texture(gl, target, options)
Creates a SpiderGL.WebGL.Texture. SpiderGL.WebGL.Texture is the base class for WebGLTexture object wrappers (SpiderGL.WebGL.Texture2D and SpiderGL.WebGL.TextureCubeMap) and must not be directly used.
var tex1 = new SpiderGL.WebGL.Texture2D(gl, {
	internalFormat : gl.RGBA,              // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_INTERNAL_FORMAT
	width          : 256,
	height         : 128,
	border         : 0,                    // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_BORDER
	format         : gl.RGBA,              // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_FORMAT
	type           : gl.UNSIGNED_BYTE,     // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_TYPE
	data           : new Uint8Array(...),  // if omitted or null, the texture is initialized to zero by the WebGLRenderingContext
	magFilter      : gl.LINEAR,            // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_MAG_FILTER
	minFilter      : gl.LINEAR,            // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_MIN_FILTER
	wrapS          : gl.CLAMP_TO_EDGE,     // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_WRAP_S
	wrapT          : gl.CLAMP_TO_EDGE,     // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_WRAP_T
	autoMipmap     : true,                 // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_AUTO_GENERATE_MIPMAP
	generateMipmap : false,                // if specified, overrides autoMipmap for this implicit call to setImage
	flipYPolicy                : true,     // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_UNPACK_FLIP_Y
	flipY                      : false,    // if specified, overrides flipYPolicy for this implicit call to setImage
	premultiplyAlphaPolicy     : true,     // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
	premultiplyAlpha           : false,    // if specified, overrides premultiplyAlphaPolicy for this implicit call to setImage
	colorspaceConversionPolicy : true,     // if omitted, defaults to SpiderGL.WebGL.Texture.DEFAULT_UNPACK_COLORSPACE_CONVERSION
	colorspaceConversion       : false     // if specified, overrides colorspaceConversionPolicy for this implicit call to setImage
});

var tex2 = new SpiderGL.WebGL.TextureCubeMap(gl, {
	url : [
		http://someurl.org/cubemap_pos_x.png,
		http://someurl.org/cubemap_neg_x.png,
		http://someurl.org/cubemap_pos_y.png,
		http://someurl.org/cubemap_neg_y.png,
		http://someurl.org/cubemap_pos_z.png,
		http://someurl.org/cubemap_neg_z.png
	],
	onCancel   : function () { ... },
	onError    : function () { ... },
	onProgress : function () { ... },
	onLoad     : function () { ... },
	wrapS      : gl.REPEAT,
	magFilter  : gl.NEAREST
});
Parameters:
{WebGLRenderingContext} gl
A WebGLRenderingContext hijacked with SpiderGL.WebGL.Context.hijack.
{number} target
Texture-specific target.
{object} options Optional
Optional parameters.
{WebGLTexture} options.handle Optional
If defined, the provided texture will be wrapped and its sampling parameters will be queried to the rendering context; as texture image base level width and height can not be retrieved, they should be specified with the width and height optional parameters. If handle is not specified, an internal texture will be created.
{string|array} options.url Optional
The url of the texture image to load. It has precedence over the data optional parameter. For SpiderGL.Texture.Texture2D, url is a string. For SpiderGL.Texture.TextureCubeMap, url is an array of six strings, one for each cube map face, in the order [+X, -X, +Y, -Y, +Z, -Z].
{ArrayBuffer|ArrayBufferView|ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} options.data Optional
The texture image pixel data.
{number} options.internalFormat Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_INTERNAL_FORMAT
The texture internal format.
{number} options.width Optional
If data is null or a typed array, specifies the texture image width. If handle is provided, the width parameter will supply the width information, not querable to the WebGLRenderingContext.
{number} options.height Optional
If data is null or a typed array, specifies the texture image height. If handle is provided, the width parameter will supply the height information, not querable to the WebGLRenderingContext.
{number} options.border Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_BORDER
Texture border.
{number} options.format Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_FORMAT
The format parameter used for WebGLRenderingContext.texImage2D.
{number} options.type Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_TYPE
The type parameter used for WebGLRenderingContext.texImage2D.
{number} options.magFilter Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_MAG_FILTER
Texture magnification filter (see SpiderGL.WebGL.Texture#magFilter).
{number} options.minFilter Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_MIN_FILTER
Texture minnification filter (see SpiderGL.WebGL.Texture#minFilter).
{number} options.wrapS Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_WRAP_S
Texture horizontal wrap mode (see SpiderGL.WebGL.Texture#wrapS).
{number} options.wrapT Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_WRAP_T
Texture vertical wrap mode (see SpiderGL.WebGL.Texture#wrapT).
{bool} options.autoMipmap Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_AUTO_GENERATE_MIPMAP
If true, mipmaps are automatically generated when calling setImage or setSubImage (see SpiderGL.WebGL.Texture#autoMipmap).
{bool} options.generateMipmap Optional
If specified, overrides autoMipmap for this call.
{bool} options.flipYPolicy Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_UNPACK_FLIP_Y
WebGL unpack flip Y policy (see SpiderGL.WebGL.Texture#flipYPolicy).
{bool} options.flipY Optional
If specified, overrides flipYPolicy for this call.
{bool} options.premultiplyAlphaPolicy Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
WebGL unpack premultiply alpha policy (see SpiderGL.WebGL.Texture#premultiplyAlphaPolicy).
{bool} options.premultiplyAlpha Optional
If specified, overrides premultiplyAlphaPolicy for this call.
{number} options.colorspaceConversionPolicy Optional, Default: SpiderGL.WebGL.Texture.DEFAULT_UNPACK_COLORSPACE_CONVERSION
WebGL unpack colorspace conversion policy (see SpiderGL.WebGL.Texture#colorspaceConversionPolicy).
{number} options.colorspaceConversion Optional
If specified, overrides colorspaceConversionPolicy for this call.
{function} options.onCancel Optional
If url is specified, this function will be called if image data loading is cancelled.
{function} options.onError Optional
If url is specified, this function will be called if an error occurs when loading image data.
{function} options.onProgress Optional
If url is specified, this function will be called during the image loading progress.
{function} options.onSuccess Optional
If url is specified, this function will be called when image data has been successfully loaded.
See:
SpiderGL.WebGL.Texture2D
SpiderGL.WebGL.TextureCubeMap
SpiderGL.WebGL.Framebuffer
SpiderGL.WebGL.ObjectGL

Field Detail

{bool} autoMipmap
Gets/Sets the automatic mipmap generation.
Default Value:
SpiderGL.WebGL.Texture.DEFAULT_AUTO_GENERATE_MIPMAP
{number} colorspaceConversionPolicy
Gets/Sets the colorspace conversionpolicy. It specifies the image data colorpsce conversion policy when unpacking pixel data in setData or setSubData. If set to SpiderGL.Core.DONT_CARE, the current WebGLRenderingContext setting will be used (i.e. nothing will be changed). Otherwise, the specified value will be used and then restored after image data has been set.
Default Value:
SpiderGL.WebGL.Context.DEFAULT_UNPACK_COLORSPACE_CONVERSION
<static> {bool} SpiderGL.WebGL.Texture.DEFAULT_AUTO_GENERATE_MIPMAP
Default value for SpiderGL.WebGL.Texture#autoMipmap
Default Value:
false
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_BORDER
Default texture border when calling setImage
Default Value:
0
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_FORMAT
Default texture input data format when calling setImage or setSubImage.
Default Value:
WebGLRenderingContext.RGBA
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_INTERNAL_FORMAT
Default texture internal format when calling setImage.
Default Value:
WebGLRenderingContext.RGBA
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_LEVEL
Default texture level when calling setImage.
Default Value:
0
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_MAG_FILTER
Default texture magnification filter.
Default Value:
WebGLRenderingContext.LINEAR
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_MIN_FILTER
Default texture minification filter.
Default Value:
WebGLRenderingContext.LINEAR
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_TYPE
Default texture input data type when calling setImage or setSubImage.
Default Value:
WebGLRenderingContext.UNSIGNED_BYTE
<static> SpiderGL.WebGL.Texture.DEFAULT_UNPACK_COLORSPACE_CONVERSION
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_COLORSPACE_CONVERSION_WEBGL when calling setImage or setSubImage.
See:
SpiderGL.WebGL.Texture.DEFAULT_UNPACK_FLIP_Y
SpiderGL.WebGL.Texture.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
Default Value:
WebGLRenderingContext.NONE
<static> SpiderGL.WebGL.Texture.DEFAULT_UNPACK_FLIP_Y
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL when calling setImage or setSubImage.
See:
SpiderGL.WebGL.Texture.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
SpiderGL.WebGL.Texture.DEFAULT_UNPACK_COLORSPACE_CONVERSION
Default Value:
true
<static> SpiderGL.WebGL.Texture.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
Default value for pixel unpack parameter WebGLRenderingContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL when calling setImage or setSubImage.
See:
SpiderGL.WebGL.Texture.DEFAULT_UNPACK_FLIP_Y
SpiderGL.WebGL.Texture.DEFAULT_UNPACK_COLORSPACE_CONVERSION
Default Value:
true
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_WRAP_S
Default texture wrap mode in horizontal direction.
Default Value:
WebGLRenderingContext.REPEAT
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_WRAP_T
Default texture wrap mode in vertical direction.
Default Value:
WebGLRenderingContext.REPEAT
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_X_OFFSET
Default texture sub-image x offset when calling setSubImage.
Default Value:
0
<static> {number} SpiderGL.WebGL.Texture.DEFAULT_Y_OFFSET
Default texture sub-image y offset when calling setSubImage.
Default Value:
0
{bool} flipYPolicy
Gets/Sets the flip Y policy. It specifies the image data vertical flipping policy when unpacking pixel data in setData or setSubData. If set to true, the WebGL pixel unpack parameter WebGLRenderingContext.UNPACK_FLIP_Y will be set to true If set to false, the WebGL pixel unpack parameter WebGLRenderingContext.UNPACK_FLIP_Y will be set to false In either case, the unpack parameter will be restored. If set to SpiderGL.Core.DONT_CARE, the current WebGLRenderingContext setting will be used (i.e. nothing will be changed).
Default Value:
SpiderGL.WebGL.Context.DEFAULT_UNPACK_FLIP_Y
<readonly> {number} format
Gets the texture image internal format.
<readonly> {number} height
Gets the texture image height.
<readonly> {bool} isReady
Tests if the texture is ready to use. A texture is considered ready if all its associated images (one for 2D textures, six for cube maps) have width and height greater than zero.
{number} magFilter
Gets/Sets the texture magnification filter.
{number} minFilter
Gets/Sets the texture minification filter.
{bool} premultuplyAlphaPolicy
Gets/Sets the premultiply alpha policy. It specifies the image data premultiply alpha policy when unpacking pixel data in setData or setSubData. If set to true, the WebGL pixel unpack parameter WebGLRenderingContext.UNPACK_PREMULTIPLY_ALPHA will be set to true If set to false, the WebGL pixel unpack parameter WebGLRenderingContext.UNPACK_PREMULTIPLY_ALPHA will be set to false In either case, the unpack parameter will be restored after image data has been set If set to SpiderGL.Core.DONT_CARE, the current WebGLRenderingContext setting will be used (i.e. nothing will be changed).
Default Value:
SpiderGL.WebGL.Context.DEFAULT_UNPACK_PREMULTIPLY_ALPHA
<readonly> {number} width
Gets the texture image width.
{number} wrapS
Gets/Sets the texture horizontal wrap mode.
{number} wrapT
Gets/Sets the texture vertical wrap mode.

Method Detail

  • bind(unit)
    Binds the texture to the appropriate target for SpiderGL.WebGL.Texture2D and SpiderGL.WebGL.TextureCubeMap.
    Parameters:
    {number} unit
    The unit (zero-based index) to which bind the texture. If not specified, the current texture unit is used.
    See:
    unbind
  • destroy()
    Destroys the WebGLTexture. After destruction, the handle is set to null and this object should not be used anymore.
    See:
    SpiderGL.WebGL.ObjectGL#destroy
  • generateMipmap()
    Generates the mipmap pyramid.
  • {object} getSampler()
    Gets the texture sampling (filtering and addressing) mode.
    Returns:
    {object} The sampling options. The returned object will have the following properties: magFilter, minFilter, wrapS, wrapT.
  • setSampler(sampler)
    Sets the texture sampling (filtering and addressing) mode. It is a utility function to specify the addressing and filtering parameters at once. Only the specified properties will be changed. To restore the default value, specify the property with value SpiderGL.Core.DEFAULT.
    Parameters:
    {object} sampler
    The sampling options.
    {number} sampler.magFilter Optional
    Texture magnification filter (see SpiderGL.WebGL.Texture#magFilter).
    {number} sampler.minFilter Optional
    Texture minnification filter (see SpiderGL.WebGL.Texture#minFilter).
    {number} sampler.wrapS Optional
    Texture horizontal wrap mode (see SpiderGL.WebGL.Texture#wrapS).
    {number} sampler.wrapT Optional
    Texture vertical wrap mode (see SpiderGL.WebGL.Texture#wrapT).
  • unbind(unit)
    Binds "null" to the appropriate texture target for SpiderGL.WebGL.Texture2D and SpiderGL.WebGL.TextureCubeMap. This method is provided only for simmetry with bind and is not relative to the object state.
    Parameters:
    {number} unit
    The unit (zero-based index) to which bind the null texture. If not specified, the current texture unit is used.
    See:
    bind
  • <static> SpiderGL.WebGL.Texture.unbind(gl)
    Parameters:
    gl