More nullable fixes, make SetTransform a part of base Renderer.
This commit is contained in:
@@ -107,14 +107,7 @@ namespace DaggerFramework.Rendering
|
||||
|
||||
public override void DrawCircle(float radius, Color color)
|
||||
{
|
||||
Raylib.DrawCircle((int)_position.X, (int)_position.Y, radius, DaggerColorToRaylibColor(color));
|
||||
}
|
||||
|
||||
public override void SetTransform(Vector2 position, Vector2 offset, float rotation = 0)
|
||||
{
|
||||
_position = position;
|
||||
_offset = offset;
|
||||
_rotation = rotation;
|
||||
Raylib.DrawCircle((int)transformPosition.X, (int)transformPosition.Y, radius, DaggerColorToRaylibColor(color));
|
||||
}
|
||||
|
||||
public override void DrawTexture(Texture2d texture, Color tint)
|
||||
@@ -124,7 +117,7 @@ namespace DaggerFramework.Rendering
|
||||
LoadTexture(texture);
|
||||
}
|
||||
|
||||
Raylib.DrawTextureV(_texturePool[texture.Handle], _position, DaggerColorToRaylibColor(tint));
|
||||
Raylib.DrawTextureV(_texturePool[texture.Handle], transformPosition, DaggerColorToRaylibColor(tint));
|
||||
}
|
||||
|
||||
public override void DrawRectangle(Vector2 size, Color color)
|
||||
@@ -132,16 +125,16 @@ namespace DaggerFramework.Rendering
|
||||
// Raylib.DrawRectangleV(_position, size, SystemColorToRaylibColor(color));
|
||||
Raylib.DrawRectanglePro(new Rectangle()
|
||||
{
|
||||
x = _position.X,
|
||||
y = _position.Y,
|
||||
x = transformPosition.X,
|
||||
y = transformPosition.Y,
|
||||
width = size.X,
|
||||
height = size.Y
|
||||
}, _offset, _rotation, DaggerColorToRaylibColor(color));
|
||||
}, transformOffset, transformRotation, DaggerColorToRaylibColor(color));
|
||||
}
|
||||
|
||||
public override void DrawDebugText(string text, int fontSize, Color color)
|
||||
{
|
||||
Raylib.DrawText(text, (int)_position.X, (int)_position.Y, fontSize, DaggerColorToRaylibColor(color));
|
||||
Raylib.DrawText(text, (int)transformPosition.X, (int)transformPosition.Y, fontSize, DaggerColorToRaylibColor(color));
|
||||
}
|
||||
|
||||
public override void DrawSdfText(string text, int fontSize, Color color)
|
||||
@@ -191,7 +184,7 @@ namespace DaggerFramework.Rendering
|
||||
}
|
||||
|
||||
var rayFont = _fontPool[font.Handle];
|
||||
Raylib.DrawTextPro(rayFont, text, _position, Vector2.Zero, _rotation, font.Size, 0.0f, DaggerColorToRaylibColor(color));
|
||||
Raylib.DrawTextPro(rayFont, text, transformPosition, transformOffset, transformRotation, font.Size, 0.0f, DaggerColorToRaylibColor(color));
|
||||
}
|
||||
|
||||
protected override int GetMonitorWidth(int monitorId)
|
||||
@@ -266,8 +259,6 @@ namespace DaggerFramework.Rendering
|
||||
|
||||
private List<Texture2D> _texturePool = new();
|
||||
private List<Raylib_cs.Font> _fontPool = new();
|
||||
private Vector2 _position, _offset;
|
||||
private float _rotation;
|
||||
private Vector2 _windowSize;
|
||||
private bool _vsync;
|
||||
private string _windowTitle = string.Empty;
|
||||
|
||||
@@ -79,13 +79,25 @@ namespace DaggerFramework.Rendering
|
||||
/// <param name="color">Background color.</param>
|
||||
public abstract void ClearBackground(Color color);
|
||||
|
||||
public void ResetTransform()
|
||||
{
|
||||
transformPosition = Vector2.Zero;
|
||||
transformOffset = Vector2.Zero;
|
||||
transformRotation = 0.0f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets transforms for the next draw operation.
|
||||
/// </summary>
|
||||
/// <param name="position">Global transform position.</param>
|
||||
/// <param name="offset">Local offset point around which shapes will rotate.</param>
|
||||
/// <param name="rotation">Rotation.</param>
|
||||
public abstract void SetTransform(Vector2 position, Vector2 offset, float rotation = 0.0f);
|
||||
public void SetTransform(Vector2 position, Vector2 offset, float rotation = 0.0f)
|
||||
{
|
||||
transformPosition = position;
|
||||
transformOffset = offset;
|
||||
transformRotation = rotation;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the transform for the next draw operation.
|
||||
/// </summary>
|
||||
@@ -127,6 +139,9 @@ namespace DaggerFramework.Rendering
|
||||
/// <param name="id">Texture to draw.</param>
|
||||
/// <param name="tint">Texture tint.</param>
|
||||
public abstract void DrawTexture(Texture2d texture, Color tint);
|
||||
|
||||
protected Vector2 transformPosition, transformOffset;
|
||||
protected float transformRotation;
|
||||
}
|
||||
|
||||
public enum Msaa
|
||||
|
||||
@@ -100,12 +100,6 @@ namespace DaggerFramework.Rendering
|
||||
return;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetTransform(Vector2 position, Vector2 offset, float rotation = 0)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void SetTransform(Matrix4x4 transform)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user