Sign in to follow this  
johnnyBravo

Making a texture from 'CreateTexture' use D3DPOOL_MANAGED?

Recommended Posts

I create a texture with
d3dDevice->CreateTexture(textureSize,textureSize,1,D3DUSAGE_RENDERTARGET,D3DFMT_R5G6B5,D3DPOOL_MANAGED,&textures[0],0);

And I then render to it. But when I lose the device I'm going to have to rerender it, unless I can some how use the D3DPOOL_MANAGED, instead of the default. But it just crashes when I use that setting, what can I do? I thought maybe some how make a copy of that texture (created from d3dpool_default) but using the d3dpool_managed flag instead, but I dont know if thats possible or how to do it. thx

Share this post


Link to post
Share on other sites
Rendertargets can only be created in the default memory pool. If you want to have a backup, you'd need to create a scratch surface in system memory and manually copy the rendertarget to it using GetRenderTargetData. Then use UpdateSurface to copy the off-screen surface back to the rendertarget when it's been re-created.

Share this post


Link to post
Share on other sites
Ok thx I'll do that,

also I didn't mention, I only render to it once during initialisation, so thats why I thought I could convert it to a normal type of texture using managed.

Share this post


Link to post
Share on other sites
1) Check your return values and it won't crash
2) Install the debug runtimes, and then if a function fails, it'll give you an error message like: "(D3D9) ERROR: Surfaces created with D3DUSAGE_RENDERTARGET can only be created in D3DPOOL_DEFAULT. CreateSurface fails with D3DERR_INVALIDPARAM." or something equally descriptive.

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