Added RenderTarget2D

This commit is contained in:
Simon Lübeß
2021-09-17 12:58:33 +02:00
parent d051b392d0
commit 266d7a4651
9 changed files with 77 additions and 38 deletions
@@ -3,8 +3,6 @@ using System;
namespace GlitchyEngine.Renderer
{
public class RenderTarget;
public class GraphicsContext : RefCounted
{
private RasterizerState _currentRasterizerState;
@@ -25,7 +23,7 @@ namespace GlitchyEngine.Renderer
* @remarks When @RenderTarget is null the backbuffer will be bound.
* @BindRenderTargets has to be called in order to bind the rendertargets.
*/
public extern void SetRenderTarget(RenderTarget renderTarget, int slot = 0);
public extern void SetRenderTarget(RenderTarget2D renderTarget, int slot = 0);
/**
* Binds all.
@@ -41,7 +39,7 @@ namespace GlitchyEngine.Renderer
* @param color The color to clear the render target with.
* @remarks When @renderTarget is null the backbuffer will be cleared.
*/
public extern void ClearRenderTarget(RenderTarget renderTarget, ColorRGBA color);
public extern void ClearRenderTarget(RenderTarget2D renderTarget, ColorRGBA color);
//public abstract void SetViewport(Viewport viewport);
+1 -1
View File
@@ -27,7 +27,7 @@ namespace GlitchyEngine.Renderer
}
[Inline]
public static void Clear(RenderTarget renderTarget, ColorRGBA color)
public static void Clear(RenderTarget2D renderTarget, ColorRGBA color)
{
_rendererAPI.Clear(renderTarget, color);
}
@@ -0,0 +1,25 @@
using System;
namespace GlitchyEngine.Renderer
{
public class RenderTarget2D : Texture2D
{
public this(GraphicsContext context, uint32 width, uint32 height, Format format, uint32 arraySize = 1, uint32 mipLevels = 1, CPUAccessFlags cpuAccess = .None)
: base(context)
{
Texture2DDesc desc;
desc.Width = width;
desc.Height = height;
desc.Format = format;
desc.ArraySize = arraySize;
desc.MipLevels = mipLevels;
// RenderTargets only can do default (I think)
desc.Usage = .Default;
desc.CpuAccess = cpuAccess;
CreateRenderTargetPlatform(desc);
}
protected extern void CreateRenderTargetPlatform(Texture2DDesc desc);
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ namespace GlitchyEngine.Renderer
public extern void Init();
public extern void Clear(RenderTarget renderTarget, ColorRGBA clearColor);
public extern void Clear(RenderTarget2D renderTarget, ColorRGBA clearColor);
public extern void Clear(DepthStencilTarget target, float depthValue, uint8 stencilValue, DepthStencilClearFlag clearFlags);
+3 -3
View File
@@ -78,7 +78,7 @@ namespace GlitchyEngine.Renderer
public this(GraphicsContext context, Texture2DDesc desc) : base(context)
{
PrepareTexturePlatform(desc);
PrepareTexturePlatform(desc, false);
}
public void SetData<T>(T* data, uint32 arraySlice = 0, uint32 mipSlice = 0)
@@ -98,12 +98,12 @@ namespace GlitchyEngine.Renderer
protected extern void LoadTexturePlatform();
protected extern void CreateTexturePlatform(Texture2DDesc desc, void* data, uint32 linePitch);
protected extern void CreateTexturePlatform(Texture2DDesc desc, bool isRenderTarget, void* data, uint32 linePitch);
/**
* Prepares the texture so that a call to SetData can successfully upload the data to the gpu.
*/
protected extern void PrepareTexturePlatform(Texture2DDesc desc);
protected extern void PrepareTexturePlatform(Texture2DDesc desc, bool isRenderTarget);
protected extern Result<void> PlatformSetData(void* data, uint32 elementSize, uint32 destX,
uint32 destY, uint32 destWidth, uint32 destHeight, uint32 arraySlice, uint32 mipLevel, GlitchyEngine.Renderer.MapType mapType);