mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-25 07:05:38 +00:00
Fixed MacOS initialization by returning IntPtr from CoreGraphics methods
instead of structures wrapping CoreFoundation types.
This commit is contained in:
parent
e66d796bdb
commit
6e327798a3
|
@ -72,6 +72,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
else if (evt.EventClass == EventClass.AppleEvent)
|
||||
{
|
||||
// only event here is the apple event.
|
||||
Debug.Print("Processing apple event.");
|
||||
API.ProcessAppleEvent(inEvent);
|
||||
}
|
||||
|
||||
|
@ -90,6 +91,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
|
||||
static void MainWindowClosed(object sender, EventArgs e)
|
||||
{
|
||||
Debug.Print("Quitting application event loop.");
|
||||
API.QuitApplicationEventLoop();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
// CGRect -> HIRect
|
||||
|
||||
[DllImport(appServices,EntryPoint="CGGetActiveDisplayList")]
|
||||
internal static extern CGDisplayErr GetActiveDisplayList(int maxDisplays, IntPtr[] activeDspys, out int dspyCnt);
|
||||
internal unsafe static extern CGDisplayErr GetActiveDisplayList(int maxDisplays, IntPtr* activeDspys, out int dspyCnt);
|
||||
|
||||
[DllImport(appServices,EntryPoint="CGMainDisplayID")]
|
||||
internal static extern IntPtr MainDisplayID();
|
||||
|
@ -33,7 +33,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
internal static extern int DisplayPixelsHigh(IntPtr display);
|
||||
|
||||
[DllImport(appServices,EntryPoint="CGDisplayCurrentMode")]
|
||||
internal static extern CFDictionary DisplayCurrentMode(IntPtr display);
|
||||
internal static extern IntPtr DisplayCurrentMode(IntPtr display);
|
||||
|
||||
[DllImport(appServices,EntryPoint="CGDisplayCapture")]
|
||||
internal static extern CGDisplayErr DisplayCapture(IntPtr display);
|
||||
|
@ -42,7 +42,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
internal static extern CGDisplayErr DisplayRelease(IntPtr display);
|
||||
|
||||
[DllImport(appServices, EntryPoint = "CGDisplayAvailableModes")]
|
||||
internal static extern CFArray DisplayAvailableModes(IntPtr display);
|
||||
internal static extern IntPtr DisplayAvailableModes(IntPtr display);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace OpenTK.Platform.MacOS
|
|||
static MacOSKeyMap Keymap = new MacOSKeyMap();
|
||||
|
||||
IntPtr uppHandler;
|
||||
string title = "New Window";
|
||||
string title = "OpenTK Window";
|
||||
short mWidth, mHeight;
|
||||
bool mIsDisposed = false;
|
||||
|
||||
|
@ -81,9 +81,9 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
if (disposing)
|
||||
{
|
||||
mWindows.Remove(window.WindowRef);
|
||||
mWindows.Remove(window.WindowRef);
|
||||
|
||||
window.Dispose();
|
||||
window.Dispose();
|
||||
window = null;
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,8 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
if (uppHandler != IntPtr.Zero)
|
||||
{
|
||||
// API.RemoveEventHandler(uppHandler);
|
||||
// API.DisposeEventHandlerUPP(uppHandler);
|
||||
//API.RemoveEventHandler(uppHandler);
|
||||
//API.DisposeEventHandlerUPP(uppHandler);
|
||||
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ namespace OpenTK.Platform.MacOS
|
|||
Debug.Indent();
|
||||
|
||||
IntPtr windowRef = API.CreateNewWindow(@class, attrib, r);
|
||||
//API.SetWindowTitle(windowRef, title);
|
||||
API.SetWindowTitle(windowRef, title);
|
||||
|
||||
window = new CarbonWindowInfo(windowRef, true, false);
|
||||
|
||||
|
@ -129,7 +129,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
ConnectEvents();
|
||||
|
||||
System.Diagnostics.Debug.Print("Attached events.");
|
||||
System.Diagnostics.Debug.Print("Attached window events.");
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
|
@ -187,7 +187,6 @@ namespace OpenTK.Platform.MacOS
|
|||
API.ShowWindow(window.WindowRef);
|
||||
API.RepositionWindow(window.WindowRef, parent, WindowPositionMethod);
|
||||
API.SelectWindow(window.WindowRef);
|
||||
|
||||
}
|
||||
public void Hide()
|
||||
{
|
||||
|
@ -222,6 +221,7 @@ namespace OpenTK.Platform.MacOS
|
|||
WeakReference reference = mWindows[userData];
|
||||
CarbonGLNative window = (CarbonGLNative)reference.Target;
|
||||
|
||||
Debug.Print("Processing {0} event for {1}.", evt, window.window);
|
||||
|
||||
if (window == null)
|
||||
{
|
||||
|
@ -591,7 +591,7 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
get
|
||||
{
|
||||
return windowState;
|
||||
return windowState;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK.Platform.MacOS
|
||||
|
@ -59,6 +60,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
if (ownHandle)
|
||||
{
|
||||
Debug.Print("Disposing window {0}.", windowRef);
|
||||
Carbon.API.DisposeWindow(this.windowRef);
|
||||
windowRef = IntPtr.Zero;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,13 @@ namespace OpenTK.Platform.MacOS
|
|||
IntPtr[] displays = new IntPtr[maxDisplayCount];
|
||||
int displayCount;
|
||||
|
||||
CG.GetActiveDisplayList(maxDisplayCount, displays, out displayCount);
|
||||
unsafe
|
||||
{
|
||||
fixed(IntPtr* displayPtr = displays)
|
||||
{
|
||||
CG.GetActiveDisplayList(maxDisplayCount, displayPtr, out displayCount);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Print("CoreGraphics reported {0} displays.", displayCount);
|
||||
Debug.Indent();
|
||||
|
@ -54,12 +60,14 @@ namespace OpenTK.Platform.MacOS
|
|||
int currentHeight = CG.DisplayPixelsHigh(currentDisplay);
|
||||
Debug.Print("Display {0} is at {1}x{2}", i, currentWidth, currentHeight);
|
||||
|
||||
CFArray displayModes = CG.DisplayAvailableModes(currentDisplay);
|
||||
IntPtr displayModesPtr = CG.DisplayAvailableModes(currentDisplay);
|
||||
CFArray displayModes = new CFArray(displayModesPtr);
|
||||
Debug.Print("Supports {0} display modes.", displayModes.Count);
|
||||
|
||||
DisplayResolution opentk_dev_current_res = null;
|
||||
List<DisplayResolution> opentk_dev_available_res = new List<DisplayResolution>();
|
||||
CFDictionary currentMode = CG.DisplayCurrentMode(currentDisplay);
|
||||
IntPtr currentModePtr = CG.DisplayCurrentMode(currentDisplay);
|
||||
CFDictionary currentMode = new CFDictionary(currentModePtr);
|
||||
|
||||
for (int j = 0; j < displayModes.Count; j++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue