Home Reference Source
import {Texture} from './core/cgl/cgl_texture.js'
public class | source

Texture

Extends:

CgTexture → Texture

A Texture

Example:

// generate a 256x256 pixel texture of random colors
const size=256;
const data = new Uint8Array(size*size*4);

for(var x=0;x<size*size*4;x++) data[ x*4+3]=255;

const tex=new CGL.Texture(cgl);
tex.initFromData(data,size,size,CGL.Texture.FILTER_NEAREST,CGL.Texture.WRAP_REPEAT);

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

anisotropic: number

public

deleted: boolean

public

filter: *

public

flip: boolean

public

flipped: boolean

public

height: *

public

image: *

public

loading: boolean

public
public

shadowMap: boolean

public
public

tex: *

public
public
public

unpackAlpha: boolean

public

width: *

public

wrap: *

Private Members
private

_cgl: *

private

_fromData: boolean

private
private
private
private

_log: *

Method Summary

Public Methods
public

returns a new texture with the same settings (does not copy texture itself)

public

compareSettings(tex: Texture): Boolean

returns true if otherTexture has same options (width/height/filter/wrap etc)

public

delete()

public

delete texture.

public

getInfo(): *

public
public
public
public

initFromData(data: Array<Number>, w: Number, h: Number, filter: Number, wrap: Number)

public

initTexture(img: Object, filter: Number)

set texture data from an image/canvas object

public
public

isPowerOfTwo(): Boolean

public
public

setFormat(o: *)

public

setSize(w: Number, h: Number)

set pixel size of texture

public
Private Methods
private

Inherited Summary

From class CgTexture
public

height: number

public

id: *

public

name: string

public
public

width: number

Public Constructors

public constructor() source

Override:

CgTexture#constructor

Public Members

public anisotropic: number source

public deleted: boolean source

public filter: * source

public flip: boolean source

public flipped: boolean source

public height: * source

Override:

CgTexture#height

public image: * source

public loading: boolean source

public pixelFormat: * source

Override:

CgTexture#pixelFormat

public shadowMap: boolean source

public shortInfoString: * source

public tex: * source

public texTarget: * source

public textureType: * source

public unpackAlpha: boolean source

public width: * source

Override:

CgTexture#width

public wrap: * source

Private Members

private _cgl: * source

private _fromData: boolean source

private _glDataFormat: * source

private _glDataType: * source

private _glInternalFormat: * source

private _log: * source

Public Methods

public clone(): Texture source

returns a new texture with the same settings (does not copy texture itself)

Return:

Texture

public compareSettings(tex: Texture): Boolean source

returns true if otherTexture has same options (width/height/filter/wrap etc)

Params:

NameTypeAttributeDescription
tex Texture

otherTexture

Return:

Boolean

public delete() source

public dispose() source

delete texture. use this when texture is no longer needed

public getInfo(): * source

Return:

*

public getInfoOneLine(): * source

Return:

*

public getInfoOneLineShort(): * source

Return:

*

public getInfoReadable(): * source

Return:

*

public initFromData(data: Array<Number>, w: Number, h: Number, filter: Number, wrap: Number) source

Params:

NameTypeAttributeDescription
data Array<Number>

rgb color array [r,g,b,a,r,g,b,a,...]

w Number

width

h Number

height

filter Number
wrap Number

public initTexture(img: Object, filter: Number) source

set texture data from an image/canvas object

Params:

NameTypeAttributeDescription
img Object

image

filter Number

public isFloatingPoint(): * source

Return:

*

public isPowerOfTwo(): Boolean source

Return:

Boolean

public printInfo() source

public setFormat(o: *) source

Params:

NameTypeAttributeDescription
o *

public setSize(w: Number, h: Number) source

set pixel size of texture

Params:

NameTypeAttributeDescription
w Number

width

h Number

height

public updateMipMap() source

Private Methods

private _setFilter() source