mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Added Blit-Class
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -414,6 +414,8 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
FontRenderer.Init();
|
||||
|
||||
Blit.Init();
|
||||
|
||||
#if DEBUG
|
||||
s_initialized = true;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user