mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-09-13 20:17:12 +00:00
Merge pull request #135 from thefiddler/xquartz
XQuartz support (X11 on Mac)
This commit is contained in:
commit
f889835dd5
|
@ -11,7 +11,15 @@
|
||||||
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||||
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||||
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||||
|
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||||
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||||
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
|
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
|
||||||
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
|
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
|
||||||
|
<!-- XQuartz compatibility (X11 on Mac) -->
|
||||||
|
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
|
||||||
|
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
|
||||||
|
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
|
||||||
|
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
|
||||||
|
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
|
||||||
|
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -53,9 +53,9 @@ namespace OpenTK.Platform
|
||||||
|
|
||||||
// Create regular platform backend
|
// Create regular platform backend
|
||||||
if (Configuration.RunningOnSdl2) Default = new SDL2.Sdl2Factory();
|
if (Configuration.RunningOnSdl2) Default = new SDL2.Sdl2Factory();
|
||||||
|
else if (Configuration.RunningOnX11) Default = new X11.X11Factory();
|
||||||
else if (Configuration.RunningOnWindows) Default = new Windows.WinFactory();
|
else if (Configuration.RunningOnWindows) Default = new Windows.WinFactory();
|
||||||
else if (Configuration.RunningOnMacOS) Default = new MacOS.MacOSFactory();
|
else if (Configuration.RunningOnMacOS) Default = new MacOS.MacOSFactory();
|
||||||
else if (Configuration.RunningOnX11) Default = new X11.X11Factory();
|
|
||||||
else Default = new UnsupportedPlatform();
|
else Default = new UnsupportedPlatform();
|
||||||
|
|
||||||
// Create embedded platform backend for EGL / OpenGL ES.
|
// Create embedded platform backend for EGL / OpenGL ES.
|
||||||
|
@ -70,9 +70,9 @@ namespace OpenTK.Platform
|
||||||
}
|
}
|
||||||
else if (Egl.Egl.IsSupported)
|
else if (Egl.Egl.IsSupported)
|
||||||
{
|
{
|
||||||
if (Configuration.RunningOnWindows) Embedded = new Egl.EglWinPlatformFactory();
|
if (Configuration.RunningOnX11) Embedded = new Egl.EglX11PlatformFactory();
|
||||||
|
else if (Configuration.RunningOnWindows) Embedded = new Egl.EglWinPlatformFactory();
|
||||||
else if (Configuration.RunningOnMacOS) Embedded = new Egl.EglMacPlatformFactory();
|
else if (Configuration.RunningOnMacOS) Embedded = new Egl.EglMacPlatformFactory();
|
||||||
else if (Configuration.RunningOnX11) Embedded = new Egl.EglX11PlatformFactory();
|
|
||||||
else Embedded = new UnsupportedPlatform();
|
else Embedded = new UnsupportedPlatform();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -346,7 +346,7 @@ namespace OpenTK.Platform.X11
|
||||||
public static extern ErrorCode QueryDrawable(IntPtr dpy, IntPtr drawable, GLXAttribute attribute, out int value);
|
public static extern ErrorCode QueryDrawable(IntPtr dpy, IntPtr drawable, GLXAttribute attribute, out int value);
|
||||||
|
|
||||||
[DllImport(Library, EntryPoint = "glXQueryExtension")]
|
[DllImport(Library, EntryPoint = "glXQueryExtension")]
|
||||||
public static extern bool QueryExtension(IntPtr dpy, ref int errorBase, ref int eventBase);
|
public static extern bool QueryExtension(IntPtr dpy, out int errorBase, out int eventBase);
|
||||||
|
|
||||||
[DllImport(Library, EntryPoint = "glXQueryExtensionsString")]
|
[DllImport(Library, EntryPoint = "glXQueryExtensionsString")]
|
||||||
static extern IntPtr QueryExtensionsStringInternal(IntPtr dpy, int screen);
|
static extern IntPtr QueryExtensionsStringInternal(IntPtr dpy, int screen);
|
||||||
|
@ -356,6 +356,9 @@ namespace OpenTK.Platform.X11
|
||||||
return Marshal.PtrToStringAnsi(QueryExtensionsStringInternal(dpy, screen));
|
return Marshal.PtrToStringAnsi(QueryExtensionsStringInternal(dpy, screen));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport(Library, EntryPoint = "glXQueryVersion")]
|
||||||
|
public static extern bool QueryVersion(IntPtr dpy, out int major, out int minor);
|
||||||
|
|
||||||
[DllImport(Library, EntryPoint = "glXCreateContext")]
|
[DllImport(Library, EntryPoint = "glXCreateContext")]
|
||||||
public static extern IntPtr CreateContext(IntPtr dpy, IntPtr vis, IntPtr shareList, bool direct);
|
public static extern IntPtr CreateContext(IntPtr dpy, IntPtr vis, IntPtr shareList, bool direct);
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,34 @@ namespace OpenTK.Platform.X11
|
||||||
if (window == null)
|
if (window == null)
|
||||||
throw new ArgumentNullException("window");
|
throw new ArgumentNullException("window");
|
||||||
|
|
||||||
Mode = ModeSelector.SelectGraphicsMode(
|
|
||||||
mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples,
|
|
||||||
mode.AccumulatorFormat, mode.Buffers, mode.Stereo);
|
|
||||||
|
|
||||||
// Do not move this lower, as almost everything requires the Display
|
// Do not move this lower, as almost everything requires the Display
|
||||||
// property to be correctly set.
|
// property to be correctly set.
|
||||||
Display = ((X11WindowInfo)window).Display;
|
Display = ((X11WindowInfo)window).Display;
|
||||||
|
|
||||||
|
// Check that GLX is supported. We cannot proceed to create
|
||||||
|
// an OpenGL context without the GLX extension.
|
||||||
|
int error_base;
|
||||||
|
int event_base;
|
||||||
|
int glx_major;
|
||||||
|
int glx_minor;
|
||||||
|
using (new XLock(Display))
|
||||||
|
{
|
||||||
|
bool supported = Glx.QueryExtension(Display, out error_base, out event_base);
|
||||||
|
supported &= Glx.QueryVersion(Display, out glx_major, out glx_minor);
|
||||||
|
if (supported)
|
||||||
|
{
|
||||||
|
Debug.Print("[X11] GLX supported. Version is {0}.{1}", glx_major, glx_minor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotSupportedException("[X11] GLX extension is not supported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Mode = ModeSelector.SelectGraphicsMode(
|
||||||
|
mode.ColorFormat, mode.Depth, mode.Stencil, mode.Samples,
|
||||||
|
mode.AccumulatorFormat, mode.Buffers, mode.Stereo);
|
||||||
|
|
||||||
currentWindow = (X11WindowInfo)window;
|
currentWindow = (X11WindowInfo)window;
|
||||||
currentWindow.VisualInfo = SelectVisual(Mode, currentWindow);
|
currentWindow.VisualInfo = SelectVisual(Mode, currentWindow);
|
||||||
|
|
||||||
|
|
|
@ -42,14 +42,14 @@ namespace OpenTK.Platform.X11
|
||||||
public JoystickState State;
|
public JoystickState State;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: despite what the name says, this class is Linux-specific.
|
||||||
sealed class X11Joystick : IJoystickDriver2
|
sealed class X11Joystick : IJoystickDriver2
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
readonly object sync = new object();
|
readonly object sync = new object();
|
||||||
|
|
||||||
readonly FileSystemWatcher watcher = new FileSystemWatcher(JoystickPath);
|
readonly FileSystemWatcher watcher = new FileSystemWatcher();
|
||||||
readonly FileSystemWatcher watcher_legacy = new FileSystemWatcher(JoystickPathLegacy);
|
|
||||||
|
|
||||||
readonly Dictionary<int, int> index_to_stick = new Dictionary<int, int>();
|
readonly Dictionary<int, int> index_to_stick = new Dictionary<int, int>();
|
||||||
List<JoystickDevice<X11JoyDetails>> sticks = new List<JoystickDevice<X11JoyDetails>>();
|
List<JoystickDevice<X11JoyDetails>> sticks = new List<JoystickDevice<X11JoyDetails>>();
|
||||||
|
@ -62,43 +62,38 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
public X11Joystick()
|
public X11Joystick()
|
||||||
{
|
{
|
||||||
|
string path =
|
||||||
|
Directory.Exists(JoystickPath) ? JoystickPath :
|
||||||
|
Directory.Exists(JoystickPathLegacy) ? JoystickPathLegacy :
|
||||||
|
String.Empty;
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(path))
|
||||||
|
{
|
||||||
|
watcher.Path = path;
|
||||||
|
|
||||||
watcher.Created += JoystickAdded;
|
watcher.Created += JoystickAdded;
|
||||||
watcher.Deleted += JoystickRemoved;
|
watcher.Deleted += JoystickRemoved;
|
||||||
watcher.EnableRaisingEvents = true;
|
watcher.EnableRaisingEvents = true;
|
||||||
|
|
||||||
watcher_legacy.Created += JoystickAdded;
|
OpenJoysticks(path);
|
||||||
watcher_legacy.Deleted += JoystickRemoved;
|
}
|
||||||
watcher_legacy.EnableRaisingEvents = true;
|
|
||||||
|
|
||||||
OpenJoysticks();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private Members
|
#region Private Members
|
||||||
|
|
||||||
void OpenJoysticks()
|
void OpenJoysticks(string path)
|
||||||
{
|
{
|
||||||
lock (sync)
|
lock (sync)
|
||||||
{
|
{
|
||||||
foreach (string file in Directory.GetFiles(JoystickPath))
|
foreach (string file in Directory.GetFiles(path))
|
||||||
{
|
{
|
||||||
JoystickDevice<X11JoyDetails> stick = OpenJoystick(file);
|
JoystickDevice<X11JoyDetails> stick = OpenJoystick(file);
|
||||||
if (stick != null)
|
if (stick != null)
|
||||||
{
|
{
|
||||||
//stick.Description = String.Format("USB Joystick {0} ({1} axes, {2} buttons, {3}{0})",
|
//stick.Description = String.Format("USB Joystick {0} ({1} axes, {2} buttons, {3}{0})",
|
||||||
//number, stick.Axis.Count, stick.Button.Count, JoystickPath);
|
//number, stick.Axis.Count, stick.Button.Count, path);
|
||||||
sticks.Add(stick);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string file in Directory.GetFiles(JoystickPathLegacy))
|
|
||||||
{
|
|
||||||
JoystickDevice<X11JoyDetails> stick = OpenJoystick(file);
|
|
||||||
if (stick != null)
|
|
||||||
{
|
|
||||||
//stick.Description = String.Format("USB Joystick {0} ({1} axes, {2} buttons, {3}{0})",
|
|
||||||
//number, stick.Axis.Count, stick.Button.Count, JoystickPathLegacy);
|
|
||||||
sticks.Add(stick);
|
sticks.Add(stick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -447,6 +442,7 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watcher.Dispose();
|
||||||
foreach (JoystickDevice<X11JoyDetails> js in sticks)
|
foreach (JoystickDevice<X11JoyDetails> js in sticks)
|
||||||
{
|
{
|
||||||
CloseJoystick(js);
|
CloseJoystick(js);
|
||||||
|
|
Loading…
Reference in a new issue