Texture

Class with all of the initialization and methods for a texture.

Constructor

new Texture(name, path, out, callback, filter, wrap)

Construct this for the texture to be added to the HB.textures Object, so you do not have to assign the instance to a value, it gets added to 'out' automatically.

Parameters:
NameTypeDefaultDescription
namestring

Name of the texture, for indexing in the 'out' Object.

pathstring

Path in the file system to the texture file, supported formats.

outObjectHB.textures

The Object to add the texture to.

callbackfunction

Is called when the texture has finished loading, logs the loaded textures to the browser console by default.

filternumbergl.LINEAR

WebGL enum value for texture filtering, see gl.TEXTURE_MAG/MIN_FILTER on MDN.

wrapnumbergl.CLAMP_TO_EDGE

WebGL enum value for texture wrapping, see gl.TEXTURE_WRAP_S/T on MDN.

Methods

bind(slot)

(DO NOT USE) Internal method binding the texture to a specific slot.

Parameters:
NameTypeDefaultDescription
slotnumber1

Which slot.

createTexture(path, filter, wrap)

(DO NOT USE) Internal method for actually creating a texture, is called by constructor.

Parameters:
NameTypeDescription
pathstring

Path of the texture.

filternumber

WebGL enum value for texture filtering, see gl.TEXTURE_MAG/MIN_FILTER on MDN.

wrapnumber

WebGL enum value for texture wrapping, see gl.TEXTURE_WRAP_S/T on MDN.

delete()

(DO NOT USE) Internal method for deleting this texture, is called on all textures by HB.Renderer#delete.

setErrorTexture()

(DO NOT USE) Method for setting an error texture in case of a texture failing to load etc.

unbind()

(DO NOT USE) Internal method for binding an empty texture, or unbinding this one.

(static) init()

(DO NOT USE) Internal method for creating the font, circle, error texture and blank textures needed for drawing text, ellipses and colored shapes.

(static) setTextureParameters(filter, wrap)

(DO NOT USE) Internal method for setting the texure parameters, is called by HB.Texture#createTexture.

Parameters:
NameTypeDescription
filternumber

WebGL enum value for texture filtering, see gl.TEXTURE_MAG/MIN_FILTER on MDN.

wrapnumber

WebGL enum value for texture wrapping, see gl.TEXTURE_WRAP_S/T on MDN.