Improved MSDF generation and rendering

This commit is contained in:
Simon Lübeß
2021-09-20 15:42:10 +02:00
parent 2afff4ec20
commit 3f1f5736b5
6 changed files with 197 additions and 178 deletions
+25 -25
View File
@@ -9,6 +9,27 @@ namespace GlitchyEngine.Renderer
public class Renderer2D
{
enum DrawOrder
{
/// Immediately draw the sprites.
Immediate,
/**
* Deferres rendering until the call of End().
* Sorts the sprites by their texture.
*/
SortByTexture,
/**
* Deferres rendering until the call of End().
* Sorts the sprites so that the backmost will be drawn first and the frontmost last.
*/
BackToFront,
/**
* Deferres rendering until the call of End().
* Sorts the sprites so that the frontmost will be drawn first and the backmost last.
*/
FrontToBack
}
struct RenderVertex : IVertexData
{
public Vector2 Position;
@@ -66,6 +87,10 @@ namespace GlitchyEngine.Renderer
private BatchVertex[] _rawInstances = new BatchVertex[1024] ~ delete _;
private uint32 _setInstances = 0;
Matrix _projection;
DrawOrder _drawOrder;
/// The effect that is currently being used to draw the sprites.
private Effect _currentEffect ~ _?.ReleaseRef();
@@ -160,31 +185,6 @@ namespace GlitchyEngine.Renderer
instancingBinding.SetIndexBuffer(quadBinding.GetIndexBuffer(), 0);
}
Matrix _projection;
DrawOrder _drawOrder;
enum DrawOrder
{
/// Immediately draw the sprites.
Immediate,
/**
* Deferres rendering until the call of End().
* Sorts the sprites by their texture.
*/
SortByTexture,
/**
* Deferres rendering until the call of End().
* Sorts the sprites so that the backmost will be drawn first and the frontmost last.
*/
BackToFront,
/**
* Deferres rendering until the call of End().
* Sorts the sprites so that the frontmost will be drawn first and the backmost last.
*/
FrontToBack
}
/**
* Initializes the renderer.
* @param drawOrder Determines if and how the sprites will be ordered before rendering.