RenderingContext
Interface for a rendering context. It provides methods to control the state of the graphics engine, and draw sprites. Methods in this interface are meant for a 2-dimensional environment.
This interface is used internally by entities and textures to render graphics. There are rare cases where game developers need to make use of this interface. These rare cases include developing a new type of sprite which is not provided by the framework, or a new post-processing filter. In such scenarios it is necessary to use this class instead of calling OpenGL ES functions directly. This ensures that your sprite implementation is compatible with the rest of the framework. Only call OpenGL functions if what you intend to do cannot be done using the methods in this class.
public interface RenderingContext
Method Summary
Modifier and Type | Method and Description |
---|---|
public void | bindTarget(RenderTarget target) Binds a render target to this context to receive the output image. |
public void | clear(float r, float g, float b) Clears the the current render target and fills it with the specified color. |
public float | getHeight() Gets the logical height of the context. |
public float | getMatrix() Gets the current transformation matrix that is used for drawing. |
public int | getScreenHeight() Gets the real and unscaled height of the rendering area, which is normally the screen height
in a full-screen application. |
public int | getScreenWidth() Gets the real and unscaled width of the rendering area, which is normally the screen width in
a full-screen application. |
public ShaderProgram | getShader() Gets the shader program currently assigned to the rendering context. |
public float | getWidth() Gets the logical width of the context. |
public void | identity() Sets the current matrix to identity, canceling any previous transformation. |
public void | popMatrix() Pops the matrix at the top of the transformation matrix stack. |
public void | pushMatrix() Pushes a matrix on top of the transformation matrix stack. |
public void | pushMatrix(float[] mat) Pushes a pre-computed matrix on top of the transformation matrix stack. |
public void | rect() Draws the default rectangular primitive with the given state of the rendering context. |
public void | rotate(float angle) Rotates the current matrix with the given angle. |
public void | scale(float x, float y) Scales the current matrix with given factors. |
public void | setColorFilter(float r, float g, float b, float a) Sets the color filter for the given context. |
public void | setShader(ShaderProgram shader) Sets the shader program for the rendering context. |
public void | translate(float x, float y) Translates the current matrix the given distance. |
Method Detail
bindTarget | ||
---|---|---|
public void bindTarget( RenderTarget target ) Binds a render target to this context to receive the output image. If no render target is
specified, the target will be set to the screen. Binding render targets is an advanced
feature which is usually not needed in a game. Parameters:
|
clear | ||||||
---|---|---|---|---|---|---|
public void clear( float r, float g, float b ) Clears the the current render target and fills it with the specified color. Parameters:
|
getHeight |
---|
public float getHeight() Gets the logical height of the context. Artenus unifies provides uniform graphics on various
screen sizes. The logical screen dimensions are device-independent. Returns:
The height in texels |
getMatrix |
---|
public float getMatrix() Gets the current transformation matrix that is used for drawing. This is a low-level method
and is usually not needed for a game. Returns:
The transformation matrix |
getScreenHeight |
---|
public int getScreenHeight() Gets the real and unscaled height of the rendering area, which is normally the screen height
in a full-screen application. Returns:
The height of the rendering area |
getScreenWidth |
---|
public int getScreenWidth() Gets the real and unscaled width of the rendering area, which is normally the screen width in
a full-screen application. Returns:
The width of the rendering area |
getShader |
---|
public ShaderProgram getShader() Gets the shader program currently assigned to the rendering context. Returns:
The active shader program |
getWidth |
---|
public float getWidth() Gets the logical width of the context. Artenus unifies provides uniform graphics on various
screen sizes. The logical screen dimensions are device-independent. Returns:
The width in texels |
identity |
---|
public void identity() Sets the current matrix to identity, canceling any previous transformation. Calling this
method is useful only in rare cases. It is normally enough to use the matrix stack to revert
transformations. |
popMatrix |
---|
public void popMatrix() Pops the matrix at the top of the transformation matrix stack. The effective matrix will be the one underneath. Calling this method when there is only one matrix in the stack has no effect, and does not throw any exceptions. You need to be careful to pop as many matrices as you push. The framework and all renderables share the same rendering context. An imbalanced stack usage may cause unexpected rendering results. |
pushMatrix |
---|
public void pushMatrix() Pushes a matrix on top of the transformation matrix stack. Subsequent transformation calls
will only affect the top of the stack, leaving the rest of the matrices in the stack intact. |
pushMatrix | ||
---|---|---|
public void pushMatrix( float[] mat ) Pushes a pre-computed matrix on top of the transformation matrix stack. The argument can be
the return value of getMatrix() .Parameters:
|
rect |
---|
public void rect() Draws the default rectangular primitive with the given state of the rendering context. It is
up to the shader program to decide where and how this rectangle is drawn, given the state of
the rendering context. |
rotate | ||
---|---|---|
public void rotate( float angle ) Rotates the current matrix with the given angle. Parameters:
|
scale | ||||
---|---|---|---|---|
public void scale( float x, float y ) Scales the current matrix with given factors. Parameters:
|
setColorFilter | ||||||||
---|---|---|---|---|---|---|---|---|
public void setColorFilter( float r, float g, float b, float a ) Sets the color filter for the given context. The behavior of this method depends on the
shader program. But all shader programs in Artenus are required to accept color filters in
some way. Parameters:
|
setShader | ||
---|---|---|
public void setShader( ShaderProgram shader ) Sets the shader program for the rendering context. All graphical method calls after calling this method will work with the shader specified. Using this method correctly is crucial to compatibility with the framework. The following are the rules that apply to all renderables using this method:
Parameters:
|
translate | ||||
---|---|---|---|---|
public void translate( float x, float y ) Translates the current matrix the given distance. Parameters:
|