com.annahid.libs.artenus.graphics
TextureShaderProgram
Used by the Artenus framework to render textured entities.
public class TextureShaderProgram implements ShaderProgram
Field Summary
Modifier and Type | Field 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 Type | Constructor and Description |
---|---|
public | TextureShaderProgram() |
Method Summary
Modifier and Type | Method and Description |
---|---|
public void | activate() Activates the shader program. |
public void | cleanup() Removes any unused state created by this shader program from the rendering context. |
public void | compile() Compiles the shader program and sets up variables and handles. |
protected void | compile(String vertexShaderCode, String fragmentShaderCode) Compiles this shader program with given vertex and fragment shader codes. |
public void | destroy() Destroys the shader program and frees all allocated resources. |
public void | feed(float[] mat) Feeds a transformation matrix to this shader program. |
public void | feed(FloatBuffer vertexBuffer) Feeds a vertex strip for the element to be drawn on the screen. |
public void | feed(float r, float g, float b, float a) Feeds a color component to this shader program. |
public void | feed(int textureDataHandle) Feeds a texture to this shader program. |
public void | feedTexCoords(FloatBuffer buffer) Feeds texture a coordinate buffer to this shader program. |
public static FloatBuffer | getDefaultTextureBuffer() 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. |
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:
|
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:
|
feedTexCoords | ||
---|---|---|
public void feedTexCoords( FloatBuffer buffer ) Feeds texture a coordinate buffer to this shader program. Parameters:
|
getDefaultTextureBuffer |
---|
public static FloatBuffer getDefaultTextureBuffer() Gets the default texture coordinates buffer, which includes the whole area of the texture
image. Returns:
Default texture coordinates |