Artenus 2D Framework
Artenus Reference
com.annahid.libs.artenus.graphics

TextureShaderProgram

Used by the Artenus framework to render textured entities.
public class TextureShaderProgram
implements ShaderProgram

Field Summary

Modifier and TypeField and Description
protected mColorHandle
Holds the handle to the color variable in the OpenGL ES fragment shader.
protected mMVPMatrixHandle
Holds projection matrix.
protected mPositionHandle
Holds the handle to the position variable in the OpenGL ES vertex shader.
protected mProgram
Holds OpenGL shader program handle.
protected mSamplerHandle
Holds the handle to the sampler variable in the OpenGL ES fragment shader.
protected mTexCoordsHandle
Holds the handle to the texture coordinates variable in the OpenGL ES vertex shader.

Constructor Summary

Modifier and TypeConstructor and Description
public TextureShaderProgram()

Method Summary

Modifier and TypeMethod and Description
public voidactivate()
Activates the shader program.
public voidcleanup()
Removes any unused state created by this shader program from the rendering context.
public voidcompile()
Compiles the shader program and sets up variables and handles.
protected voidcompile(String vertexShaderCode, String fragmentShaderCode)
Compiles this shader program with given vertex and fragment shader codes.
public voiddestroy()
Destroys the shader program and frees all allocated resources.
public voidfeed(float[] mat)
Feeds a transformation matrix to this shader program.
public voidfeed(FloatBuffer vertexBuffer)
Feeds a vertex strip for the element to be drawn on the screen.
public voidfeed(float r, float g, float b, float a)
Feeds a color component to this shader program.
public voidfeed(int textureDataHandle)
Feeds a texture to this shader program.
public voidfeedTexCoords(FloatBuffer buffer)
Feeds texture a coordinate buffer to this shader program.
public static FloatBuffergetDefaultTextureBuffer()
Gets the default texture coordinates buffer, which includes the whole area of the texture image.

Methods inherited from java.lang.Object

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

Field Detail

mColorHandle
protected mColorHandle
Holds the handle to the color variable in the OpenGL ES fragment shader.
mMVPMatrixHandle
protected mMVPMatrixHandle
Holds projection matrix.
mPositionHandle
protected mPositionHandle
Holds the handle to the position variable in the OpenGL ES vertex shader.
mProgram
protected mProgram
Holds OpenGL shader program handle.
mSamplerHandle
protected mSamplerHandle
Holds the handle to the sampler variable in the OpenGL ES fragment shader.
mTexCoordsHandle
protected mTexCoordsHandle
Holds the handle to the texture coordinates variable in the OpenGL ES vertex shader.

Constructor Detail

TextureShaderProgram
public  TextureShaderProgram()

Method Detail

activate
public void activate()
Activates the shader program. This method is normally called for each renderable, or when the shader program is switched to.
Specified By:
cleanup
public void cleanup()
Removes any unused state created by this shader program from the rendering context. This method is normally called when the shader program is no longer needed for the current frame. Note that the program may be needed for the next frame, so it should not deallocate its global resources.
Specified By:
compile
public void compile()
Compiles the shader program and sets up variables and handles.
Specified By:
compile
protected void compile(
    String vertexShaderCode,
    String fragmentShaderCode
)
Compiles this shader program with given vertex and fragment shader codes.
Parameters:
vertexShaderCodeVertex shader code
fragmentShaderCodeFragment shader code
destroy
public void destroy()
Destroys the shader program and frees all allocated resources. The shader will not be used after this method, unless the compile() method is called again.
Specified By:
feed
public void feed(
    float[] mat
)
Feeds a transformation matrix to this shader program. This matrix is also multiplied by the projection matrix and can be directly used to draw elements.
Specified By:
feed
public void feed(
    FloatBuffer vertexBuffer
)
Feeds a vertex strip for the element to be drawn on the screen.
Specified By:
feed
public void feed(
    float r,
    float g,
    float b,
    float a
)
Feeds a color component to this shader program. All shader programs in this framework are expected to accept one color component. But how they use this component is not defined.
Specified By:
feed
public void feed(
    int textureDataHandle
)
Feeds a texture to this shader program.
Parameters:
textureDataHandleTexture data handle
feedTexCoords
public void feedTexCoords(
    FloatBuffer buffer
)
Feeds texture a coordinate buffer to this shader program.
Parameters:
bufferTexture coordinate buffer
getDefaultTextureBuffer
public static FloatBuffer getDefaultTextureBuffer()
Gets the default texture coordinates buffer, which includes the whole area of the texture image.
Returns:
Default texture coordinates