From 4d7ba20a036e1ce8541ef807f9b1a51b5d024ad8 Mon Sep 17 00:00:00 2001 From: "Stefanos A." Date: Wed, 2 Oct 2013 16:26:47 +0200 Subject: [PATCH] Fixed unsetting current context in SDL2 SDL_GL_MakeCurrent(IntPtr.Zero, IntPtr.Zero) is the correct way to remove the current OpenGL context from the calling thread. Fixes threaded rendering on Windows. --- Source/OpenTK/Platform/SDL2/Sdl2GraphicsContext.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/Platform/SDL2/Sdl2GraphicsContext.cs b/Source/OpenTK/Platform/SDL2/Sdl2GraphicsContext.cs index dedc3f0d..5dee13f7 100644 --- a/Source/OpenTK/Platform/SDL2/Sdl2GraphicsContext.cs +++ b/Source/OpenTK/Platform/SDL2/Sdl2GraphicsContext.cs @@ -180,8 +180,17 @@ namespace OpenTK.Platform.SDL2 public override void MakeCurrent(IWindowInfo window) { - var sdl_window = window as Sdl2WindowInfo; - if (SDL.SDL_GL_MakeCurrent(sdl_window != null ? sdl_window.Handle : IntPtr.Zero, SdlContext.Handle) < 0) + int result = 0; + if (window != null) + { + result = SDL.SDL_GL_MakeCurrent(window.Handle, SdlContext.Handle); + } + else + { + result = SDL.SDL_GL_MakeCurrent(IntPtr.Zero, IntPtr.Zero); + } + + if (result < 0) { Debug.Print("SDL2 MakeCurrent failed with: {0}", SDL.SDL_GetError()); }