From e8a330000e74882204f80c3a6a2beaf7c998684b Mon Sep 17 00:00:00 2001 From: Dylan Perks Date: Mon, 15 Apr 2024 12:57:25 -0500 Subject: [PATCH] Slightly adjust the SDL logic to try and encourage system opinions for -1 --- .../Silk.NET.Windowing.Sdl/SdlView.cs | 68 +++++++++++++------ 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs b/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs index 41fcdeed4a..bf82f3c9b5 100644 --- a/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs +++ b/src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs @@ -149,29 +149,59 @@ protected void CoreInitialize IsClosingVal = false; // Set window GL attributes - Sdl.GLSetAttribute(GLattr.DepthSize, - opts.PreferredDepthBufferBits is null || opts.PreferredDepthBufferBits == -1 - ? 24 : opts.PreferredDepthBufferBits.Value); - - Sdl.GLSetAttribute(GLattr.StencilSize, - opts.PreferredStencilBufferBits is null || opts.PreferredStencilBufferBits == -1 - ? 8 : opts.PreferredStencilBufferBits.Value); + if (opts.PreferredDepthBufferBits != -1) + { + Sdl.GLSetAttribute + ( + GLattr.DepthSize, + opts.PreferredDepthBufferBits ?? 24 + ); + } - Sdl.GLSetAttribute(GLattr.RedSize, - opts.PreferredBitDepth is null || opts.PreferredBitDepth.Value.X == -1 - ? 8 : opts.PreferredBitDepth.Value.X); + if (opts.PreferredStencilBufferBits != -1) + { + Sdl.GLSetAttribute + ( + GLattr.StencilSize, + opts.PreferredStencilBufferBits ?? 8 + ); + } - Sdl.GLSetAttribute(GLattr.GreenSize, - opts.PreferredBitDepth is null || opts.PreferredBitDepth.Value.Y == -1 - ? 8 : opts.PreferredBitDepth.Value.Y); + if (opts.PreferredBitDepth?.X != -1) + { + Sdl.GLSetAttribute + ( + GLattr.RedSize, + opts.PreferredBitDepth?.X ?? 8 + ); + } - Sdl.GLSetAttribute(GLattr.BlueSize, - opts.PreferredBitDepth is null || opts.PreferredBitDepth.Value.Z == -1 - ? 8 : opts.PreferredBitDepth.Value.Z); + if (opts.PreferredBitDepth?.Y != -1) + { + Sdl.GLSetAttribute + ( + GLattr.GreenSize, + opts.PreferredBitDepth?.Y ?? 8 + ); + } - Sdl.GLSetAttribute(GLattr.AlphaSize, - opts.PreferredBitDepth is null || opts.PreferredBitDepth.Value.W == -1 - ? 8 : opts.PreferredBitDepth.Value.W); + if (opts.PreferredBitDepth?.Z != -1) + { + Sdl.GLSetAttribute + ( + GLattr.BlueSize, + opts.PreferredBitDepth?.Z ?? 8 + ); + } + + if (opts.PreferredBitDepth?.W != -1) + { + Sdl.GLSetAttribute + ( + GLattr.AlphaSize, + opts.PreferredBitDepth?.W ?? 8 + ); + } Sdl.GLSetAttribute(GLattr.Multisamplebuffers, (opts.Samples == null || opts.Samples == -1) ? 0 : 1); Sdl.GLSetAttribute(GLattr.Multisamplesamples, (opts.Samples == null || opts.Samples == -1) ? 0 : opts.Samples.Value);