Artenus 2D Framework
Artenus Reference
Represents a texture. A texture is an image that can be used in real-time graphics libraries. All images must be converted to instances of this class before they can be used in this framework.
public class Texture

Field Summary

Modifier and TypeField and Description
protected height
Holds the height of this Texture in pixels.
protected textureId
Holds the texture identifier associated with this Texture.
protected width
Holds the width of this Texture in pixels.

Method Summary

Modifier and TypeMethod and Description
public final voiddestroy()
Unloads this Texture.
public final voiddraw(RenderingContext ctx, float x, float y, float w, float h, float rot)
Renders this Texture on the given OpenGL context in the given rectangular region.
public final intgetHeight()
Gets the height of the Texture.
public final intgetTextureHandle()
Gets the OpenGL ES texture identifier associated with this texture.
public final intgetWidth()
Gets the width of the Texture.
public final booleanisLoaded()
Indicates whether the texture is loaded.
public final voidprepare(TextureShaderProgram program, FloatBuffer textureBuffer)
Prepares the OpenGL context for rendering this Texture.
public voidwaitLoad()
Loads the texture in the foreground.

Methods inherited from java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

height
protected height
Holds the height of this Texture in pixels.
textureId
protected textureId
Holds the texture identifier associated with this Texture.
width
protected width
Holds the width of this Texture in pixels.

Method Detail

destroy
public final void destroy()
Unloads this Texture. It is highly recommended that you do not call this method directly, as it might cause problems. TextureManager takes the responsibility for loading and unloading textures whenever required.
See Also:
draw
public final void draw(
    RenderingContext ctx,
    float x,
    float y,
    float w,
    float h,
    float rot
)
Renders this Texture on the given OpenGL context in the given rectangular region. It is recommended that you do not call this method directly.
Parameters:
xx coordinate of the region to draw the texture
yy coordinate of the region to draw the texture
wWidth of the region to draw the texture
hHeight of the region to draw the texture
rotRotation angle of the rectangular region
getHeight
public final int getHeight()
Gets the height of the Texture. This will be the processed height, so if you are using an SVG texture, it will indicate the power-of-two estimation of the height.
Returns:
The width of the texture
getTextureHandle
public final int getTextureHandle()
Gets the OpenGL ES texture identifier associated with this texture. Applications of this method are rare and it is recommended not to use this method.
Returns:
The OpenGL ES texture identifier
getWidth
public final int getWidth()
Gets the width of the Texture. This will be the processed width, so if you are using an SVG texture, it will indicate the power-of-two estimation of the width.
Returns:
The width of the texture
isLoaded
public final boolean isLoaded()
Indicates whether the texture is loaded. The texture can be displayed only when it is loaded. You normally don't need to check this directly and the framework takes all the required precautions not to allow you to use unloaded textures.
Returns:
true if loaded, or false otherwise
prepare
public final void prepare(
    TextureShaderProgram program,
    FloatBuffer textureBuffer
)
Prepares the OpenGL context for rendering this Texture. This method must be called before calling draw(RenderingContext, float, float, float, float, float) for correct rendering. However, it is recommended that you do not call any of these methods directly. The framework handles low-level rendering.
Parameters:
programShader program to use
textureBufferThe texture buffer
waitLoad
public void waitLoad()
Loads the texture in the foreground. Use this method if you need a texture to load immediately for a specific purpose. For most applications, Artenus pipeline would automatically handle texture loading and life cycle.