• Advertisement
Sign in to follow this  

Copy a texture in D3DPOOL_SYSTEMMEM to a texture in D3DPOOL_DEFAULT

This topic is 3573 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
Advertisement
Get the surface from the textures with IDirect3DTexture9::GetSurfaceLevel and use

http://msdn.microsoft.com/en-us/library/bb205857(VS.85).aspx

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
Sign in to follow this  

  • Advertisement