5 using SiliconStudio.Core;
7 namespace SiliconStudio.
Paradox.Graphics
12 private bool deviceHasBeenDestroyed =
false;
13 private bool deviceHasBeenPaused =
false;
22 if (deviceHasBeenDestroyed)
33 else if (deviceHasBeenPaused)
44 if (resource.OnPause())
56 resource.LifetimeState = GraphicsResourceLifetimeState.Active;
64 GraphicsDevice.Presenter.OnRecreated();
66 bool wasSomethingRecreated =
true;
67 bool hasDestroyedObjects =
true;
72 while (wasSomethingRecreated && hasDestroyedObjects)
75 wasSomethingRecreated =
false;
76 hasDestroyedObjects =
false;
82 if (resource.OnRecreate())
84 wasSomethingRecreated =
true;
85 resource.LifetimeState = GraphicsResourceLifetimeState.Active;
90 hasDestroyedObjects =
true;
96 if (hasDestroyedObjects)
99 var destroyedObjects = GraphicsDevice.Resources.Where(x => x.LifetimeState == GraphicsResourceLifetimeState.Destroyed).ToList();
100 throw new InvalidOperationException(
"Could not recreate all objects.") { Data = { {
"DestroyedObjects", destroyedObjects } } };
107 GraphicsDevice.Presenter.OnDestroyed();
111 resource.OnDestroyed();
112 resource.LifetimeState = GraphicsResourceLifetimeState.Destroyed;
116 GraphicsDevice.OnDestroyed();
125 if (resource.Reload != null)
127 resource.Reload(resource);
128 resource.LifetimeState = GraphicsResourceLifetimeState.Active;
Service providing method to access GraphicsDevice life-cycle.
A service registry is a IServiceProvider that provides methods to register and unregister services...
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
GraphicsResourceLifetimeState
Describes the lifetime state of a graphics resource.
ResumeManager(IServiceRegistry services)