mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 15:06:58 +00:00
[X11] Fixed GLControl on nvidia binary drivers
Nvidia drivers fail in Glx.MakeCurrent() when using a 32bpp visual on a window created with a 24bpp visual. Since we do not know the actual visual until after the context is constructed, the solution is to implicitly use 24bpp when 32bpp is requested. The loss of the alpha channel does not have a user-visible effect, since WinForms do not support translucent windows on X11.
This commit is contained in:
parent
d75a2ce439
commit
6fa70263cb
|
@ -77,7 +77,22 @@ namespace OpenTK
|
||||||
if (control == null)
|
if (control == null)
|
||||||
throw new ArgumentNullException("control");
|
throw new ArgumentNullException("control");
|
||||||
|
|
||||||
this.mode = mode;
|
// Note: the X11 window is created with a default XVisualInfo,
|
||||||
|
// that is not necessarily compatible with the desired GraphicsMode.
|
||||||
|
// This manifests in Nvidia binary drivers that fail in Glx.MakeCurrent()
|
||||||
|
// when GraphicsMode has a 32bpp color format.
|
||||||
|
// To work around this issue, we implicitly select a 24bpp color format when 32bpp is
|
||||||
|
// requested - this appears to work correctly in all cases.
|
||||||
|
// (The loss of the alpha channel does not matter, since WinForms do not support
|
||||||
|
// translucent windows on X11 in the first place.)
|
||||||
|
this.mode = new GraphicsMode(
|
||||||
|
new ColorFormat(mode.ColorFormat.Red, mode.ColorFormat.Green, mode.ColorFormat.Blue, 0),
|
||||||
|
mode.Depth,
|
||||||
|
mode.Stencil,
|
||||||
|
mode.Samples,
|
||||||
|
mode.AccumulatorFormat,
|
||||||
|
mode.Buffers,
|
||||||
|
mode.Stereo);
|
||||||
|
|
||||||
if (xplatui == null) throw new PlatformNotSupportedException(
|
if (xplatui == null) throw new PlatformNotSupportedException(
|
||||||
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform or Mono runtime version, aborting.");
|
||||||
|
@ -105,6 +120,8 @@ namespace OpenTK
|
||||||
info = (XVisualInfo)Marshal.PtrToStructure(infoPtr, typeof(XVisualInfo));
|
info = (XVisualInfo)Marshal.PtrToStructure(infoPtr, typeof(XVisualInfo));
|
||||||
|
|
||||||
// set the X11 colormap.
|
// set the X11 colormap.
|
||||||
|
// Note: this only affects windows created in the future
|
||||||
|
// (do we even need this here?)
|
||||||
SetStaticFieldValue(xplatui, "CustomVisual", info.Visual);
|
SetStaticFieldValue(xplatui, "CustomVisual", info.Visual);
|
||||||
SetStaticFieldValue(xplatui, "CustomColormap", XCreateColormap(display, rootWindow, info.Visual, 0));
|
SetStaticFieldValue(xplatui, "CustomColormap", XCreateColormap(display, rootWindow, info.Visual, 0));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue