[Mac] Register platform resources for disposal

This commit is contained in:
thefiddler 2014-07-23 09:21:28 +02:00
parent 77a44b2c8e
commit 8f03b09dad

View file

@ -49,22 +49,29 @@ namespace OpenTK.Platform.MacOS
public override INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device) public override INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
{ {
return new CocoaNativeWindow(x, y, width, height, title, mode, options, device); INativeWindow window = new CocoaNativeWindow(x, y, width, height, title, mode, options, device);
RegisterResource(window);
return window;
} }
public override IDisplayDeviceDriver CreateDisplayDeviceDriver() public override IDisplayDeviceDriver CreateDisplayDeviceDriver()
{ {
// Does not implement IDisposable
return new QuartzDisplayDeviceDriver(); return new QuartzDisplayDeviceDriver();
} }
public override IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags) public override IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
{ {
return new CocoaContext(mode, window, shareContext, major, minor); IGraphicsContext context = new CocoaContext(mode, window, shareContext, major, minor);
RegisterResource(context);
return context;
} }
public override IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags) public override IGraphicsContext CreateGLContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
{ {
return new CocoaContext(handle, window, shareContext, major, minor); IGraphicsContext context = new CocoaContext(handle, window, shareContext, major, minor);
RegisterResource(context);
return context;
} }
public override GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext() public override GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
@ -98,12 +105,12 @@ namespace OpenTK.Platform.MacOS
{ {
if (!IsDisposed) if (!IsDisposed)
{ {
base.Dispose(manual);
if (manual) if (manual)
{ {
InputDriver.Dispose(); InputDriver.Dispose();
} }
base.Dispose(manual);
} }
} }