mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 18:15:36 +00:00
MacOS: Hack for AGL to have access to the display device specified when a NativeWindow is created.
This commit is contained in:
parent
56412367c4
commit
62b65af462
|
@ -125,10 +125,14 @@ namespace OpenTK.Platform.MacOS
|
|||
// Choose a pixel format with the attributes we specified.
|
||||
if (fullscreen)
|
||||
{
|
||||
IntPtr gdevice;
|
||||
|
||||
IntPtr gdevice;
|
||||
IntPtr cgdevice = GetQuartzDevice(carbonWindow);
|
||||
|
||||
if (cgdevice == IntPtr.Zero)
|
||||
cgdevice = QuartzDisplayDeviceDriver.MainDisplay;
|
||||
|
||||
OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(
|
||||
QuartzDisplayDeviceDriver.MainDisplay, out gdevice, false);
|
||||
cgdevice, out gdevice, false);
|
||||
|
||||
if (status != OSStatus.NoError)
|
||||
throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");
|
||||
|
@ -177,6 +181,26 @@ namespace OpenTK.Platform.MacOS
|
|||
Debug.Print("context: {0}", Handle.Handle);
|
||||
}
|
||||
|
||||
private IntPtr GetQuartzDevice(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
IntPtr windowRef = carbonWindow.WindowRef;
|
||||
|
||||
if (CarbonGLNative.WindowRefMap.ContainsKey(windowRef) == false)
|
||||
return IntPtr.Zero;
|
||||
|
||||
WeakReference nativeRef = CarbonGLNative.WindowRefMap[windowRef];
|
||||
if (nativeRef.IsAlive == false)
|
||||
return IntPtr.Zero;
|
||||
|
||||
CarbonGLNative window = nativeRef.Target as CarbonGLNative;
|
||||
|
||||
if (window == null)
|
||||
return IntPtr.Zero;
|
||||
|
||||
return QuartzDisplayDeviceDriver.HandleTo(window.TargetDisplayDevice);
|
||||
|
||||
}
|
||||
|
||||
void SetBufferRect(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
if (carbonWindow.IsControl == false)
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace OpenTK.Platform.MacOS
|
|||
Rectangle bounds, windowedBounds, clientRectangle;
|
||||
bool mIsDisposed = false;
|
||||
bool mExists = true;
|
||||
DisplayDevice mDisplayDevice;
|
||||
|
||||
WindowAttributes mWindowAttrib;
|
||||
WindowClass mWindowClass;
|
||||
|
@ -65,9 +66,16 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
#region AGL Device Hack
|
||||
|
||||
static CarbonGLNative()
|
||||
static internal Dictionary<IntPtr, WeakReference> WindowRefMap { get { return mWindows; } }
|
||||
internal DisplayDevice TargetDisplayDevice { get { return mDisplayDevice; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
static CarbonGLNative()
|
||||
{
|
||||
Application.Initialize();
|
||||
}
|
||||
|
@ -93,6 +101,8 @@ namespace OpenTK.Platform.MacOS
|
|||
WindowAttributes.StandardDocument | WindowAttributes.StandardHandler |
|
||||
WindowAttributes.InWindowMenu | WindowAttributes.LiveResize,
|
||||
new Rect((short)x, (short)y, (short)width, (short)height));
|
||||
|
||||
mDisplayDevice = device;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -106,6 +106,15 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
internal static IntPtr HandleTo(DisplayDevice displayDevice)
|
||||
{
|
||||
if (displayMap.ContainsKey(displayDevice))
|
||||
return displayMap[displayDevice];
|
||||
else
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
#region IDisplayDeviceDriver Members
|
||||
|
||||
Dictionary<IntPtr, IntPtr> storedModes = new Dictionary<IntPtr, IntPtr>();
|
||||
|
@ -173,5 +182,6 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue