Skip to content

Commit e8a3300

Browse files
committed
Slightly adjust the SDL logic to try and encourage system opinions for -1
1 parent dd365c7 commit e8a3300

File tree

1 file changed

+49
-19
lines changed

1 file changed

+49
-19
lines changed

src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -149,29 +149,59 @@ protected void CoreInitialize
149149
IsClosingVal = false;
150150

151151
// Set window GL attributes
152-
Sdl.GLSetAttribute(GLattr.DepthSize,
153-
opts.PreferredDepthBufferBits is null || opts.PreferredDepthBufferBits == -1
154-
? 24 : opts.PreferredDepthBufferBits.Value);
155-
156-
Sdl.GLSetAttribute(GLattr.StencilSize,
157-
opts.PreferredStencilBufferBits is null || opts.PreferredStencilBufferBits == -1
158-
? 8 : opts.PreferredStencilBufferBits.Value);
152+
if (opts.PreferredDepthBufferBits != -1)
153+
{
154+
Sdl.GLSetAttribute
155+
(
156+
GLattr.DepthSize,
157+
opts.PreferredDepthBufferBits ?? 24
158+
);
159+
}
159160

160-
Sdl.GLSetAttribute(GLattr.RedSize,
161-
opts.PreferredBitDepth is null || opts.PreferredBitDepth.Value.X == -1
162-
? 8 : opts.PreferredBitDepth.Value.X);
161+
if (opts.PreferredStencilBufferBits != -1)
162+
{
163+
Sdl.GLSetAttribute
164+
(
165+
GLattr.StencilSize,
166+
opts.PreferredStencilBufferBits ?? 8
167+
);
168+
}
163169

164-
Sdl.GLSetAttribute(GLattr.GreenSize,
165-
opts.PreferredBitDepth is null || opts.PreferredBitDepth.Value.Y == -1
166-
? 8 : opts.PreferredBitDepth.Value.Y);
170+
if (opts.PreferredBitDepth?.X != -1)
171+
{
172+
Sdl.GLSetAttribute
173+
(
174+
GLattr.RedSize,
175+
opts.PreferredBitDepth?.X ?? 8
176+
);
177+
}
167178

168-
Sdl.GLSetAttribute(GLattr.BlueSize,
169-
opts.PreferredBitDepth is null || opts.PreferredBitDepth.Value.Z == -1
170-
? 8 : opts.PreferredBitDepth.Value.Z);
179+
if (opts.PreferredBitDepth?.Y != -1)
180+
{
181+
Sdl.GLSetAttribute
182+
(
183+
GLattr.GreenSize,
184+
opts.PreferredBitDepth?.Y ?? 8
185+
);
186+
}
171187

172-
Sdl.GLSetAttribute(GLattr.AlphaSize,
173-
opts.PreferredBitDepth is null || opts.PreferredBitDepth.Value.W == -1
174-
? 8 : opts.PreferredBitDepth.Value.W);
188+
if (opts.PreferredBitDepth?.Z != -1)
189+
{
190+
Sdl.GLSetAttribute
191+
(
192+
GLattr.BlueSize,
193+
opts.PreferredBitDepth?.Z ?? 8
194+
);
195+
}
196+
197+
if (opts.PreferredBitDepth?.W != -1)
198+
{
199+
Sdl.GLSetAttribute
200+
(
201+
GLattr.AlphaSize,
202+
opts.PreferredBitDepth?.W ?? 8
203+
);
204+
}
175205

176206
Sdl.GLSetAttribute(GLattr.Multisamplebuffers, (opts.Samples == null || opts.Samples == -1) ? 0 : 1);
177207
Sdl.GLSetAttribute(GLattr.Multisamplesamples, (opts.Samples == null || opts.Samples == -1) ? 0 : opts.Samples.Value);

0 commit comments

Comments
 (0)