diff --git a/FinalEngine.Rendering.OpenGL/Buffers/OpenGLFrameBuffer.cs b/FinalEngine.Rendering.OpenGL/Buffers/OpenGLFrameBuffer.cs index 837abf1f..9f30e4ec 100644 --- a/FinalEngine.Rendering.OpenGL/Buffers/OpenGLFrameBuffer.cs +++ b/FinalEngine.Rendering.OpenGL/Buffers/OpenGLFrameBuffer.cs @@ -13,6 +13,7 @@ namespace FinalEngine.Rendering.OpenGL.Buffers; using FinalEngine.Rendering.OpenGL.Textures; using FinalEngine.Rendering.Textures; using OpenTK.Graphics.OpenGL4; +using PixelFormat = Rendering.Textures.PixelFormat; public class OpenGLFrameBuffer : IFrameBuffer, IOpenGLFrameBuffer, IDisposable { @@ -51,7 +52,15 @@ public OpenGLFrameBuffer(IOpenGLInvoker invoker, IReadOnlyList c } this.invoker.NamedFramebufferDrawBuffers(this.rendererID, attachmentCount, ref bufs[0]); - depthTarget?.Attach(FramebufferAttachment.DepthStencilAttachment, this.rendererID); + if (depthTarget != null) + { + var framebufferAttachment = FramebufferAttachment.DepthAttachment; + if (depthTarget is { Format: PixelFormat.DepthAndStencil }) + { + framebufferAttachment = FramebufferAttachment.DepthStencilAttachment; + } + depthTarget.Attach(framebufferAttachment, this.rendererID); + } var status = invoker.CheckNamedFramebufferStatus(this.rendererID, FramebufferTarget.Framebuffer); diff --git a/FinalEngine.Rendering.OpenGL/OpenGLRenderDevice.cs b/FinalEngine.Rendering.OpenGL/OpenGLRenderDevice.cs index 7a1a9834..570891cb 100644 --- a/FinalEngine.Rendering.OpenGL/OpenGLRenderDevice.cs +++ b/FinalEngine.Rendering.OpenGL/OpenGLRenderDevice.cs @@ -94,6 +94,7 @@ public OpenGLRenderDevice(IOpenGLInvoker invoker) { PixelType.Byte, TKPixelType.UnsignedByte }, { PixelType.Int, TKPixelType.UnsignedInt }, { PixelType.Short, TKPixelType.UnsignedShort }, + { PixelType.Float, TKPixelType.Float }, { PixelFormat.R, TKPixelForamt.Red }, { PixelFormat.Rg, TKPixelForamt.Rg }, { PixelFormat.Rgb, TKPixelForamt.Rgb }, @@ -104,6 +105,9 @@ public OpenGLRenderDevice(IOpenGLInvoker invoker) { SizedFormat.Rg8, SizedInternalFormat.Rg8 }, { SizedFormat.Rgb8, All.Rgb8 }, { SizedFormat.Rgba8, SizedInternalFormat.Rgba8 }, + { SizedFormat.Depth, SizedInternalFormat.DepthComponent32f }, + { SizedFormat.Depth24Stencil8, SizedInternalFormat.Depth24Stencil8 }, + { SizedFormat.Depth32fStencil8, SizedInternalFormat.Depth32fStencil8 }, { BufferUsageType.Static, BufferUsageHint.StaticDraw }, { BufferUsageType.Dynamic, BufferUsageHint.DynamicDraw }, }; diff --git a/FinalEngine.Rendering/Textures/PixelType.cs b/FinalEngine.Rendering/Textures/PixelType.cs index 05b7fb2d..9375951b 100644 --- a/FinalEngine.Rendering/Textures/PixelType.cs +++ b/FinalEngine.Rendering/Textures/PixelType.cs @@ -14,4 +14,6 @@ public enum PixelType Byte, Short, + + Float, } diff --git a/FinalEngine.Rendering/Textures/SizedFormat.cs b/FinalEngine.Rendering/Textures/SizedFormat.cs index 10b60bf4..f0aa3873 100644 --- a/FinalEngine.Rendering/Textures/SizedFormat.cs +++ b/FinalEngine.Rendering/Textures/SizedFormat.cs @@ -13,4 +13,10 @@ public enum SizedFormat Rgb8, Rgba8, + + Depth, + + Depth24Stencil8, + + Depth32fStencil8 }