Sign in to follow this  

Copy a texture in D3DPOOL_SYSTEMMEM to a texture in D3DPOOL_DEFAULT

Recommended Posts

cavably    122
I need to copy a texture created in D3DPOOL_SYSTEMMEM formatted as D3DFMT_X8R8G8B8 to a texture in D3DPOOL_DEFAULT formatted as D3DFMT_A8R8G8B8. I am currently using pD3DDevice->UpdateTexture(), and it works with the retail version of Direct3D, but breaks in the debugger if I am running the debug version because the formats are different. I have tried to use D3DXLoadSurfaceFromSurface(), but it does not preserve the alpha I need. I have also tried to copy the bits with a memcpy after locking both textures, but the resulting texture appears in zig-zags. Code for memcpy:
THROW_IF_FAILED( m_pTexture->LockRect(0,&d3dlr,0,D3DLOCK_DISCARD) )
THROW_IF_FAILED( pDestTex->LockRect(0,&d3dlrDest,0,D3DLOCK_DISCARD) )

buffersize = iWidth * iHeight;

buffer = (_int32 *)d3dlr.pBits;
_int32* bufferDest = (_int32 *)d3dlrDest.pBits;

memcpy(bufferDest, buffer, sizeof(_int32)*buffersize);


Share this post

Link to post
Share on other sites
XVincentX    129
Get the surface from the textures with IDirect3DTexture9::GetSurfaceLevel and use

Share this post

Link to post
Share on other sites
Kern_d    100
Why not change your D3DPOOL_SYSTEMMEM texture to the format D3DFMT_X8R8G8B8?
The only change is in the interpretation of the device.

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