Start of text renderer component

- UC, LC, IC, RC tags
This commit is contained in:
Simon Lübeß
2024-03-14 22:17:57 +01:00
parent a87820c7da
commit e703452b94
6 changed files with 265 additions and 21 deletions
+21
View File
@@ -3,6 +3,7 @@ using GlitchyEngine.Content;
using GlitchyEngine.Math;
using System;
using GlitchyEngine.World.Components;
using GlitchyEngine.Renderer.Text;
namespace GlitchyEngine.World;
@@ -24,6 +25,10 @@ class SceneRenderer
public RenderTargetGroup CompositeTarget => _compositeTarget;
Font _font ~ _.ReleaseRef();
FontRenderer.PreparedText _smallLinesInfo;
public this()
{
RenderTargetGroupDescription desc = .(100, 100,
@@ -47,6 +52,8 @@ class SceneRenderer
_cameraTarget.[Friend]Identifier = "Camera Target";
_gammaCorrectEffect = Content.LoadAsset("Resources/Shaders/GammaCorrect.hlsl");
_font = new Font(@"C:\Windows\Fonts\arial.ttf", 24);
}
/// Sets the size of the viewport into which the scene will be rendered.
@@ -204,6 +211,20 @@ class SceneRenderer
Renderer2D.DrawCircle(transform.WorldTransform, circle, entity.Index);
}
for (var (entity, transform, text, editorFlags) in Scene._ecsWorld.Enumerate<TransformComponent, TextRendererComponent, EditorFlagsComponent>())
{
if (editorFlags.Flags.HasFlag(.HideInScene))
continue;
_smallLinesInfo = FontRenderer.PrepareText(_font, text.Text, 24, .Black);
FontRenderer.DrawText(_smallLinesInfo, transform.WorldTransform * Matrix.Scaling(1.0f / 24.0f));
_smallLinesInfo.ReleaseRef();
}
//FontRenderer.DrawText(_smallLinesInfo, 0, 0);
Renderer2D.EndScene();