Class: Texture2D

Texture2D

Texture2D represents a 2D texture.


new Texture2D()

Author:
  • derschmale <http://www.derschmale.com>

Members


dataType

The texture's data type

See:

filter

A TextureFilter object defining how the texture should be filtered during sampling.


format

The texture's format

See:

height

The texture's height


maxAnisotropy

The maximum anisotropy used when sampling. Limited to capabilities#DEFAULT_TEXTURE_MAX_ANISOTROPY


name

The name of the texture.


width

The texture's width


wrapMode

A TextureWrapMode object defining how out-of-bounds sampling should be handled.

Methods


generateMipmap()

Generates a mip map chain.


initEmpty(width, height, format, dataType)

Inits an empty texture.

Parameters:
Name Type Description
width

The width of the texture.

height

The height of the texture.

format TextureFormat

The texture's format.

dataType DataType

The texture's data format.


isReady()

Defines whether data has been uploaded to the texture or not.


uploadData(data, width, height, generateMips, format, dataType)

Initializes the texture with the given data.

Parameters:
Name Type Description
data *

An typed array containing the initial data.

width number

The width of the texture.

height number

The height of the texture.

generateMips boolean

Whether or not a mip chain should be generated.

format TextureFormat

The texture's format.

dataType DataType

The texture's data format.


uploadImage(image, width, height, generateMips, format, dataType)

Initializes the texture with a given Image.

Parameters:
Name Type Description
image

The Image to upload to the texture

width

The width of the texture.

height

The height of the texture.

generateMips

Whether or not a mip chain should be generated.

format TextureFormat

The texture's format.

dataType DataType

The texture's data format.

TODO: Just use image.naturalWidth / image.naturalHeight ?