Sign in to follow this  

Copy a texture in D3DPOOL_SYSTEMMEM to a texture in D3DPOOL_DEFAULT

This topic is 3501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);

pDestTex->UnlockRect(0);
m_pTexture->UnlockRect(0);

Share this post


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

This topic is 3501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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