Added Blit-Class

This commit is contained in:
Simon Lübeß
2024-11-03 14:44:20 +01:00
parent 139cd6e6e5
commit 4a18d3150f
4 changed files with 30 additions and 15 deletions
+27
View File
@@ -0,0 +1,27 @@
using GlitchyEngine.Content;
namespace GlitchyEngine.Renderer;
static class Blit
{
public static AssetHandle<Effect> _copyEffect;
internal static void Init()
{
_copyEffect = Content.LoadAsset("Resources/Shaders/Copy.hlsl");
}
public static void Blit(Texture2D source, RenderTarget2D destination, Effect blitEffect = _copyEffect, Viewport? viewport = null)
{
RenderCommand.UnbindRenderTargets();
RenderCommand.SetRenderTarget(destination);
RenderCommand.BindRenderTargets();
RenderCommand.SetViewport(viewport ?? Viewport(0, 0, destination.Width, destination.Height));
blitEffect.SetTexture("Texture", source);
blitEffect.ApplyChanges();
blitEffect.Bind();
FullscreenQuad.Draw();
}
}
+2
View File
@@ -414,6 +414,8 @@ namespace GlitchyEngine.Renderer
FontRenderer.Init();
Blit.Init();
#if DEBUG
s_initialized = true;
#endif