SpriteRenderer wraps batch rendering of sprites in a simple BeginSprites / AddSprite x N / EndSprite API. More...
Classes | |
class | DefaultFontShader_ |
Font's default shader. More... | |
class | DefaultShader_ |
Sprites's default shader: texture modulated by a color. More... | |
interface | ISpriteShader |
That's all the interface we require from the shaders set by user. More... | |
Public Member Functions | |
SpriteRenderer (GraphicsContextAlpha gl, uint max_sprites) | |
SpriteRenderer constructor. | |
void | Dispose () |
Dispose implementation. | |
Bounds2 | DrawTextDebug (string str, Vector2 bottom_left_start_pos, float char_height, bool draw=true, ISpriteShader shader=null) |
Debug text draw function, using a small embedded font suitable for on screen debug prints. | |
Bounds2 | DrawTextWithFontMap (string str, Vector2 bottom_left_start_pos, float char_height, bool draw, FontMap fontmap, ISpriteShader shader) |
This text draw function uses a FontMap object. | |
Bounds2 | DrawTextWithFontMap (string str, Vector2 bottom_left_start_pos, float char_height, bool draw, FontMap fontmap) |
This text draw function uses a FontMap object and SpriteRenderer's DefaultShader. | |
void | BeginSprites (TextureInfo texture_info, ISpriteShader shader, int num_sprites) |
Start batch rendering of sprites. | |
void | BeginSprites (TextureInfo texture_info, int num_sprites) |
Start batch rendering of sprites. | |
void | EndSprites () |
End batch rendering of sprites. | |
void | AddSprite (ref TRS quad, Vector2i tile_index) |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites. | |
void | AddSprite (ref TRS quad, Vector2i tile_index, ref Matrix3 mat) |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites. | |
void | AddSprite (ref TRS quad, ref TRS uv) |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites. | |
void | AddSprite (ref TRS quad, ref TRS uv, ref Matrix3 mat) |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites. | |
void | AddSprite (Vector2 bottom_left_start_pos, Vector2 x, Bounds2 uv_bounds) |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites. | |
void | AddSprite (Vector4 v0, Vector4 v1, Vector4 v2, Vector4 v3) |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites. | |
Public Attributes | |
bool | FlipU = false |
Flag that will swap the U coordinates (horizontally) of all rendered sprites/quads. | |
bool | FlipV = false |
Flag that will swap the V coordinates (vertically) of all rendered sprites/quads. | |
Properties | |
DefaultShader_ | DefaultShader [get] |
The default shader used by SpriteRenderer. | |
DefaultFontShader_ | DefaultFontShader [get] |
The default font shader used by SpriteRenderer. | |
bool | Disposed [get] |
Return true if this object been disposed. |
SpriteRenderer wraps batch rendering of sprites in a simple BeginSprites / AddSprite x N / EndSprite API.
It also provides some text rendering functions that uses FontMap.
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites.
quad | The sprite geometry. |
tile_index | Sprite UVs are specified by a tile index. |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites.
quad | The sprite geometry. |
tile_index | Sprite UVs are specified by a tile index. |
mat | A per sprite transform matrix. |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites.
quad | The sprite geometry. |
uv | Sprite UVs are specified directly using a TRS object. |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites.
quad | The sprite geometry. |
uv | Sprite UVs are specified directly using a TRS object. |
mat | A per sprite transform matrix. |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites.
One vector is enough to determine the orientation and scale of the sprite. The aspect ratio is by default the same was the size of the 'uv' domain covered (in texels).
x | The len and direction of the bottom edge of the sprite. |
bottom_left_start_pos | The bottom left point of the sprite. |
uv_bounds | The uv bounds (Bounds2 in uv domain). |
Add a sprite to batch rendering of sprites, must be called between BeginSprites and EndSprites.
In this version user specify 4 vertices as Vector4, where each Vector4's xy is the position of the vertex, and zw is the UV.
void BeginSprites | ( | TextureInfo | texture_info, |
int | num_sprites | ||
) |
Start batch rendering of sprites.
texture_info | The texture object. |
num_sprites | The maximum number of sprite you intend to draw. |
void BeginSprites | ( | TextureInfo | texture_info, |
ISpriteShader | shader, | ||
int | num_sprites | ||
) |
Start batch rendering of sprites.
texture_info | The texture object. |
shader | The shader object. |
num_sprites | The maximum number of sprite you intend to draw. |
Bounds2 DrawTextDebug | ( | string | str, |
Vector2 | bottom_left_start_pos, | ||
float | char_height, | ||
bool | draw = true , |
||
ISpriteShader | shader = null |
||
) |
Debug text draw function, using a small embedded font suitable for on screen debug prints.
Since DrawTextDebug uses very small font data, it only work with ascii text (characters from ' ' to '~', 32 to 126) Any character outside this range will be displayed as '?'. For instance "こんにちは" will be displayed as "?????".
str | The text to draw. |
bottom_left_start_pos | The bottom left of the text rectangle, in world space/units. |
char_height | The character height in world space/units. |
draw | If false, don't draw anything, just return the Bounds2 used by the text. |
shader | If no shader is specified, DefaultFontShader is used. |
Bounds2 DrawTextWithFontMap | ( | string | str, |
Vector2 | bottom_left_start_pos, | ||
float | char_height, | ||
bool | draw, | ||
FontMap | fontmap | ||
) |
This text draw function uses a FontMap object and SpriteRenderer's DefaultShader.
str | The text to draw. |
bottom_left_start_pos | The bottom left of the text rectangle, in world space/units. |
char_height | The character height in world space/units. |
draw | If false, don't draw anything, just return the Bounds2 used by the text. |
fontmap | the fontmap object (that holds the texture). |
Bounds2 DrawTextWithFontMap | ( | string | str, |
Vector2 | bottom_left_start_pos, | ||
float | char_height, | ||
bool | draw, | ||
FontMap | fontmap, | ||
ISpriteShader | shader | ||
) |
This text draw function uses a FontMap object.
str | The text to draw. |
bottom_left_start_pos | The bottom left of the text rectangle, in world space/units. |
char_height | The character height in world space/units. |
draw | If false, don't draw anything, just return the Bounds2 used by the text. |
fontmap | the fontmap object (that holds the texture). |
shader | The shader defaults to SpriteRenderer.DefaultFontShader. |