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

Use sensible defaults for depth/stencil #1991

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Use sensible defaults for depth/stencil
  • Loading branch information
Perksey committed Mar 20, 2024
commit 337374492284ce5903938d91ef21fc56ebe4a570
2 changes: 1 addition & 1 deletion examples/CSharp/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<AssemblyName>Tutorial</AssemblyName>
<LangVersion>9</LangVersion>
<LangVersion>latest</LangVersion>
<WarningsAsErrors>0618</WarningsAsErrors>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,17 @@ public interface IViewProperties
/// Preferred depth buffer bits of the window's framebuffer.
/// </summary>
/// <remarks>
/// Pass <c>null</c> or <c>-1</c> to use the system default.
/// Pass <c>-1</c> to always use the system/backend default. Uses <c>24</c> as the default if <c>null</c> and
/// <see cref="PreferredStencilBufferBits"/> is also <c>null</c>
/// </remarks>
int? PreferredDepthBufferBits { get; }

/// <summary>
/// Preferred stencil buffer bits of the window's framebuffer.
/// </summary>
/// <remarks>
/// Pass <c>null</c> or <c>-1</c> to use the system default.
/// Pass <c>-1</c> to always use the system/backend default. Uses <c>8</c> as the default if <c>null</c> and
/// <see cref="PreferredDepthBufferBits"/> is also <c>null</c>
/// </remarks>
int? PreferredStencilBufferBits { get; }

Expand All @@ -106,4 +108,4 @@ public interface IViewProperties
/// </remarks>
int? Samples { get; }
}
}
}
14 changes: 12 additions & 2 deletions src/Windowing/Silk.NET.Windowing.Glfw/GlfwWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,18 @@ protected override void CoreInitialize(WindowOptions opts)
// Set video mode (-1 = don't care)

_glfw.WindowHint(WindowHintInt.RefreshRate, opts.VideoMode.RefreshRate ?? GLFW.Glfw.DontCare);
_glfw.WindowHint(WindowHintInt.DepthBits, opts.PreferredDepthBufferBits ?? GLFW.Glfw.DontCare);
_glfw.WindowHint(WindowHintInt.StencilBits, opts.PreferredStencilBufferBits ?? GLFW.Glfw.DontCare);
_glfw.WindowHint(WindowHintInt.DepthBits, opts.PreferredDepthBufferBits switch
{
null when opts.PreferredStencilBufferBits is null => 24,
{} x => x,
_ => GLFW.Glfw.DontCare
});
_glfw.WindowHint(WindowHintInt.StencilBits, opts.PreferredStencilBufferBits switch
{
null when opts.PreferredDepthBufferBits is null => 8,
{} x => x,
_ => GLFW.Glfw.DontCare
});

_glfw.WindowHint(WindowHintInt.RedBits, opts.PreferredBitDepth?.X ?? GLFW.Glfw.DontCare);
_glfw.WindowHint(WindowHintInt.GreenBits, opts.PreferredBitDepth?.Y ?? GLFW.Glfw.DontCare);
Expand Down
Loading