(DirectX)Stupid question about Textures and Lost Devices
Do I have to destroy and then reload Textures each time the device is lost?
Here is what I am currently doing:
void LoadContent()
{
LoadTexture("...\\MyTexture.png", out CharacterTexture);
}
void UnloadContent()
{
this.CharacterTexture.Dispose();
}
I have noticed that Sprites have OnDeviceLost() and OnDeviceRestored() methods. Why can't I call these methods on Textures instead of reloading them?
Is this MDX?
Anyway if a texture is created in D3DPOOL_MANAGED (I think it's called Pool.Managed in MDX), then it doesn't need to be re-created. The runtime will back up its contents in system memory, and automatically restore it for you when a lost device scenario occurs. However if it was created in D3DPOOL_DEFAULT (Pool.Default), then you have to destroy it and create a new one.
The Sprite class has the OnDeviceLost and OnDeviceRestored methods because it's not actually a resource...it's a class that maintains its own resources internally (specifically, a dynamic vertex buffer). Therefore it gives you methods to let it know that it should destroy and recreate those resources.
Anyway if a texture is created in D3DPOOL_MANAGED (I think it's called Pool.Managed in MDX), then it doesn't need to be re-created. The runtime will back up its contents in system memory, and automatically restore it for you when a lost device scenario occurs. However if it was created in D3DPOOL_DEFAULT (Pool.Default), then you have to destroy it and create a new one.
The Sprite class has the OnDeviceLost and OnDeviceRestored methods because it's not actually a resource...it's a class that maintains its own resources internally (specifically, a dynamic vertex buffer). Therefore it gives you methods to let it know that it should destroy and recreate those resources.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement