Sign in to follow this  
jdub

(DirectX)Stupid question about Textures and Lost Devices

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this