Skip to content

Commit 53ba0f8

Browse files
Fix SDL OpenGL context issues when not using OpenGL (#491)
When using Vulkan an exception will trigger when initializing the view if these API checks aren't present. Co-authored-by: EmileGr <[email protected]>
1 parent ef31c5d commit 53ba0f8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ public SdlView(void* nativeHandle, IGLContext? ctx, SdlPlatform platform) : base
5353
public override event Action<bool>? FocusChanged;
5454

5555
// Properties
56-
protected override IGLContext? CoreGLContext => _ctx ??= new SdlContext(Sdl, SdlWindow, this);
57-
protected override IVkSurface? CoreVkSurface => _vk ??= new SdlVkSurface(this);
56+
protected override IGLContext? CoreGLContext => API.API == ContextAPI.OpenGL || API.API == ContextAPI.OpenGLES
57+
? _ctx ??= new SdlContext(Sdl, SdlWindow, this)
58+
: null;
59+
protected override IVkSurface? CoreVkSurface => API.API == ContextAPI.Vulkan
60+
? _vk ??= new SdlVkSurface(this)
61+
: null;
5862
protected override nint CoreHandle => (nint) SdlWindow;
5963
internal SDL.Sdl Sdl { get; }
6064
internal SDL.Window* SdlWindow { get; private set; }

0 commit comments

Comments
 (0)