Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add depth format to framebuffer #302

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion FinalEngine.Rendering.OpenGL/Buffers/OpenGLFrameBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -51,7 +52,15 @@ public OpenGLFrameBuffer(IOpenGLInvoker invoker, IReadOnlyList<IOpenGLTexture> 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);

Expand Down
4 changes: 4 additions & 0 deletions FinalEngine.Rendering.OpenGL/OpenGLRenderDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
};
Expand Down
2 changes: 2 additions & 0 deletions FinalEngine.Rendering/Textures/PixelType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public enum PixelType
Byte,

Short,

Float,
}
6 changes: 6 additions & 0 deletions FinalEngine.Rendering/Textures/SizedFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
Rgb8,

Rgba8,

Depth,

Depth24Stencil8,

Depth32fStencil8

Check warning on line 21 in FinalEngine.Rendering/Textures/SizedFormat.cs

View workflow job for this annotation

GitHub Actions / build_editor_common

Check warning on line 21 in FinalEngine.Rendering/Textures/SizedFormat.cs

View workflow job for this annotation

GitHub Actions / build_rendering_opengl

Check warning on line 21 in FinalEngine.Rendering/Textures/SizedFormat.cs

View workflow job for this annotation

GitHub Actions / build_editor_view_models

Check warning on line 21 in FinalEngine.Rendering/Textures/SizedFormat.cs

View workflow job for this annotation

GitHub Actions / build_runtime

Check warning on line 21 in FinalEngine.Rendering/Textures/SizedFormat.cs

View workflow job for this annotation

GitHub Actions / build_rendering

Check warning on line 21 in FinalEngine.Rendering/Textures/SizedFormat.cs

View workflow job for this annotation

GitHub Actions / build_editor_desktop

}
Loading