From 0f1776bdd0ed9501deb994cc5fef00d662d86ac2 Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Sun, 20 Jul 2014 11:31:02 +0200 Subject: [PATCH] [X11] Use the correct visual info for the context This also fixes a potential NRE. --- Source/OpenTK/Platform/X11/X11GLContext.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/OpenTK/Platform/X11/X11GLContext.cs b/Source/OpenTK/Platform/X11/X11GLContext.cs index a1c95a39..d86a3481 100644 --- a/Source/OpenTK/Platform/X11/X11GLContext.cs +++ b/Source/OpenTK/Platform/X11/X11GLContext.cs @@ -93,7 +93,7 @@ namespace OpenTK.Platform.X11 Mode = currentWindow.GraphicsMode; } - if (!Mode.Index.HasValue) + if (Mode == null || !Mode.Index.HasValue) { Mode = ModeSelector.SelectGraphicsMode(mode, out visual, out fbconfig); } @@ -120,7 +120,7 @@ namespace OpenTK.Platform.X11 if (Handle == ContextHandle.Zero) { - Handle = CreateContextLegacy(Display, currentWindow.VisualInfo, direct, shareHandle); + Handle = CreateContextLegacy(Display, visual, direct, shareHandle); } if (Handle != ContextHandle.Zero) @@ -201,19 +201,18 @@ namespace OpenTK.Platform.X11 } static ContextHandle CreateContextLegacy(IntPtr display, - XVisualInfo info, bool direct, ContextHandle shareContext) + IntPtr info, bool direct, ContextHandle shareContext) { Debug.Write("Using legacy context creation... "); IntPtr context; using (new XLock(display)) { - // Cannot pass a Property by reference. - context = Glx.CreateContext(display, ref info, shareContext.Handle, direct); + context = Glx.CreateContext(display, info, shareContext.Handle, direct); if (context == IntPtr.Zero) { Debug.WriteLine(String.Format("failed. Trying direct: {0}... ", !direct)); - context = Glx.CreateContext(display, ref info, IntPtr.Zero, !direct); + context = Glx.CreateContext(display, info, shareContext.Handle, !direct); } }