Skip to content

Commit

Permalink
[GLFW] Make IWindowInterop inherit from IDisposable
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Jun 13, 2024
1 parent 199ed9a commit 09e8e5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/Application/Aardvark.Application.Slim.GL/Application.fs
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,7 @@ module private OpenGL =
glfw.WindowHint(WindowHintBool.ScaleToMonitor, true)
glfw.WindowHint(WindowHintInt.Samples, if cfg.samples = 1 then 0 else cfg.samples)

interface IDisposable with
member x.Dispose() = cleanup()
override x.Dispose() = cleanup()
}

type OpenGlApplication private (runtime : Runtime, shaderCachePath : Option<string>, hideCocoaMenuBar : bool) as this =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ module private Vulkan =

override __.WindowHints(cfg: WindowConfig, glfw: Glfw) =
glfw.WindowHint(WindowHintClientApi.ClientApi, ClientApi.NoApi)

override __.Dispose() =
()
}

type VulkanApplication private (app : HeadlessVulkanApplication, hideCocoaMenuBar : bool) =
Expand Down
7 changes: 2 additions & 5 deletions src/Application/Aardvark.Application.Slim/GLFW.fs
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ type IWindowSurface =
abstract CreateSwapchain : V2i -> ISwapchain
abstract Handle : obj

// TODO: Inherit IDisposable (see Instance.Dispose())
type IWindowInterop =
inherit IDisposable
abstract Boot : Glfw -> unit
abstract CreateSurface : IRuntime * WindowConfig * Glfw * nativeptr<WindowHandle> -> IWindowSurface
abstract WindowHints : WindowConfig * Glfw -> unit
Expand Down Expand Up @@ -753,10 +753,7 @@ type Instance(runtime : Aardvark.Rendering.IRuntime, interop : IWindowInterop, h
if v then wait <- false

member x.Dispose() =
match interop with
| :? IDisposable as d -> d.Dispose()
| _ -> ()

interop.Dispose()
glfw.Terminate()

interface IDisposable with
Expand Down

0 comments on commit 09e8e5f

Please sign in to comment.