mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-03-30 11:16:56 +00:00
[X11] Use the correct visual info for the context
This also fixes a potential NRE.
This commit is contained in:
parent
6fa70263cb
commit
0f1776bdd0
|
@ -93,7 +93,7 @@ namespace OpenTK.Platform.X11
|
||||||
Mode = currentWindow.GraphicsMode;
|
Mode = currentWindow.GraphicsMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Mode.Index.HasValue)
|
if (Mode == null || !Mode.Index.HasValue)
|
||||||
{
|
{
|
||||||
Mode = ModeSelector.SelectGraphicsMode(mode, out visual, out fbconfig);
|
Mode = ModeSelector.SelectGraphicsMode(mode, out visual, out fbconfig);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
if (Handle == ContextHandle.Zero)
|
if (Handle == ContextHandle.Zero)
|
||||||
{
|
{
|
||||||
Handle = CreateContextLegacy(Display, currentWindow.VisualInfo, direct, shareHandle);
|
Handle = CreateContextLegacy(Display, visual, direct, shareHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Handle != ContextHandle.Zero)
|
if (Handle != ContextHandle.Zero)
|
||||||
|
@ -201,19 +201,18 @@ namespace OpenTK.Platform.X11
|
||||||
}
|
}
|
||||||
|
|
||||||
static ContextHandle CreateContextLegacy(IntPtr display,
|
static ContextHandle CreateContextLegacy(IntPtr display,
|
||||||
XVisualInfo info, bool direct, ContextHandle shareContext)
|
IntPtr info, bool direct, ContextHandle shareContext)
|
||||||
{
|
{
|
||||||
Debug.Write("Using legacy context creation... ");
|
Debug.Write("Using legacy context creation... ");
|
||||||
IntPtr context;
|
IntPtr context;
|
||||||
|
|
||||||
using (new XLock(display))
|
using (new XLock(display))
|
||||||
{
|
{
|
||||||
// Cannot pass a Property by reference.
|
context = Glx.CreateContext(display, info, shareContext.Handle, direct);
|
||||||
context = Glx.CreateContext(display, ref info, shareContext.Handle, direct);
|
|
||||||
if (context == IntPtr.Zero)
|
if (context == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(String.Format("failed. Trying direct: {0}... ", !direct));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue