Actually dispose graphics resources

main
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);
GraphicsDevice.SubmitDestroyCommandBuffer();
}
GraphicsDevice.SubmitDestroyCommandBuffer();
}
GraphicsDevice.Dispose();
}
private void HandleSDLEvents()

View File

@ -101,16 +101,18 @@ namespace MoonWorks.Graphics
{
lock (resources)
{
foreach (var resource in resources)
{
if (resource.TryGetTarget(out var target))
for (var i = resources.Count - 1; i >= 0; i--)
{
var resource = resources[i];
if (resource.TryGetTarget(out var target))
{
target.Dispose();
}
}
}
resources.Clear();
}
SubmitDestroyCommandBuffer();
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()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method