Making a texture from 'CreateTexture' use D3DPOOL_MANAGED?

Started by
2 comments, last by Evil Steve 16 years, 8 months ago
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
Advertisement
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.
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.

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.

This topic is closed to new replies.

Advertisement