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
@@ -109,17 +109,7 @@ abstract class UltralightWindow
RenderCommand.Clear(_window.SwapChain.BackBuffer, .Color, .(0.7f, 0.2f, 0.2f), 1.0f, 0);
RenderCommand.UnbindRenderTargets();
RenderCommand.SetRenderTarget(_window.SwapChain.BackBuffer);
RenderCommand.BindRenderTargets();
RenderCommand.SetViewport(_window.SwapChain.BackbufferViewport);
Effect copy = Content.GetAsset<Effect>(UltralightLayer._copyEffect);
copy.SetTexture("Texture", _texture);
copy.ApplyChanges();
copy.Bind();
FullscreenQuad.Draw();
Blit.Blit(_texture, _window.SwapChain.BackBuffer, viewport: _window.SwapChain.BackbufferViewport);
}
public void Render()
-4
View File
@@ -13,8 +13,6 @@ class UltralightLayer : Layer
{
public static ULRenderer renderer;
public static AssetHandle<Effect> _copyEffect;
private List<UltralightWindow> _windows = new .() ~ DeleteContainerAndItems!(_);
public UltralightMainWindow EntityHierarchyWindow;
@@ -31,8 +29,6 @@ class UltralightLayer : Layer
EntityHierarchyWindow = new UltralightMainWindow();
_windows.Add(EntityHierarchyWindow);
_copyEffect = Content.LoadAsset("Resources/Shaders/Copy.hlsl");
}
private static void InitClipboard()
{
+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