|
void | begin () |
| Signal the Renderer that the frame has begun. More...
|
|
void | end () |
| Signals that rendering this frame should end. More...
|
|
const Matrix4 & | getProjectionMatrix () const |
| Returns the projection matrix that will be used when rendering sprites. More...
|
|
void | setProjectionMatrix (const Matrix4 &matrix) |
| Sets the projection matrix that will be used when rendering sprites. More...
|
|
void | drawSprite (const TexturePtr &texture, const Vector2 &pos, float width, float height, const Vector2 &srcPos, float srcWidth, float srcHeight, float rotation, float opacity) |
| Draws a rectangular quadrilateral, textured with a Texture. More...
|
|
void | drawMesh (const MeshInstancePtr &meshInstance, const ShaderPtr &shader) |
| Draw a MeshInstance with a given Shader. More...
|
|
void | flush () |
| Flush GL draw calls and state, and deselect objects. More...
|
|
void | selectTexture (const TexturePtr &texture, int stage) |
| Selects and binds a Texture to a texture stage . More...
|
|
void | selectMesh (const MeshInstancePtr &meshInstance) |
| Selects and binds a MeshInstance. More...
|
|
void | selectShader (const ShaderPtr &shader) |
| Selects a Shader as current. More...
|
|
void | clearTexture (int stage) |
| Unbinds and clears the Texture at the given stage. More...
|
|
void | clearTextures () |
| Clears all texture stages. More...
|
|
void | clearMesh () |
| Unbinds and clears the current MeshInstance. More...
|
|
void | clearShader () |
| Unbinds and clears the current Shader. More...
|
|
DebugRenderer * | getDebugRenderer () const |
| Returns the DebugRenderer managed by this Renderer. More...
|
|
void | attachAsCurrent () |
| Sets this Renderer as current, allowing it to be retrieved by getCurrent(). More...
|
|
void | detachAsCurrent () |
| Unsets this Renderer as current. More...
|
|
Class managing GL state switches and draw calls.
This class stores currently selected Textures, MeshInstance, and Shader. The select
family of methods switches these currently selected objects (for example, selectShader()). These internally call bind()
and unbind()
(or begin()
and end()
) methods as necessary. The draw
family of methods in this class (for example drawMesh()) in turn use these select
methods to set up state, and then issue GL draw calls to perform rendering.
This class also provides functionality to render basic rectangular sprites. This is done through drawSprite(). Drawing done through this method will be transformed by the current projection matrix (setProjectionMatrix()). Sprites are rendered using SpriteShader. Drawing done through drawMesh() must be transformed manually in the user's Shader.
To interleave rendering performed by this class and other renderers, call flush(). This deselects all objects managed by this class putting GL into a clean state.
This class also creates and provides a DebugRenderer object which can be used to quickly implement debug shape rendering.
- See also
- Shader
-
MeshInstance
-
Texture
void Renderer::drawSprite |
( |
const TexturePtr & |
texture, |
|
|
const Vector2 & |
pos, |
|
|
float |
width, |
|
|
float |
height, |
|
|
const Vector2 & |
srcPos, |
|
|
float |
srcWidth, |
|
|
float |
srcHeight, |
|
|
float |
rotation, |
|
|
float |
opacity |
|
) |
| |
Draws a rectangular quadrilateral, textured with a Texture.
The destination rectangle is in world coordinates and gets rotated by rotation
and then the Renderer's projection matrix. The source rectangle specifies which part of the source texture
gets mapped on to the destination rectangle. The source rectangle is in GL texture coordinate space ((0.0f, 0.0f)
is lower left).
These are rendered using SpriteShader.
- Parameters
-
texture | Texture to draw |
pos | Position of the destination rectangle |
width | Width of the destination rectangle |
height | Height of the destination rectangle |
srcPos | Offset of the source rectangle in the source Texture |
srcWidth | Width of the source rectangle in the source Texture |
srcHeight | Height of the source rectangle in the source Texture |
rotation | Rendered sprite rotation in radians |
opacity | Rendered sprite transparency, in the range [0.0f, 1.0f] |