Actually dispose graphics resources

pull/14/head
cosmonaut 2022-02-22 14:29:50 -08:00
parent cb25e6feff
commit 5679dba978
2 changed files with 10 additions and 6 deletions

View File

@ -134,9 +134,12 @@ namespace MoonWorks
Draw(timestep, alpha); Draw(timestep, alpha);
GraphicsDevice.SubmitDestroyCommandBuffer();
} }
GraphicsDevice.SubmitDestroyCommandBuffer();
} }
GraphicsDevice.Dispose();
} }
private void HandleSDLEvents() private void HandleSDLEvents()

View File

@ -101,16 +101,18 @@ namespace MoonWorks.Graphics
{ {
lock (resources) lock (resources)
{ {
foreach (var resource in resources) for (var i = resources.Count - 1; i >= 0; i--)
{ {
if (resource.TryGetTarget(out var target)) var resource = resources[i];
if (resource.TryGetTarget(out var target))
{ {
target.Dispose(); target.Dispose();
} }
} }
resources.Clear(); resources.Clear();
} }
SubmitDestroyCommandBuffer();
Refresh.Refresh_DestroyDevice(Handle); Refresh.Refresh_DestroyDevice(Handle);
} }
@ -118,7 +120,6 @@ namespace MoonWorks.Graphics
} }
} }
// TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
~GraphicsDevice() ~GraphicsDevice()
{ {
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method