• Advertisement
Sign in to follow this  

copy one texture to another?

This topic is 4854 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 have loaded a texture with D3DXCreateTextureFromFile. How do I copy a region of that texture into another empty texture that I created with D3DXCreateTexture. I have tried with LockRect, but not managed to get it right. Is there a directx function which can do the work for me?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
CopyRects()

Share this post


Link to post
Share on other sites
CopyRects seems to only support surfaces, must I convert my textures to surfaces and then do the CopyRects, and finally convert back to textures?

Share this post


Link to post
Share on other sites
You can access a texture's surface with the GetSurfaceLevel() method. I'm not sure that the function will work on textures created in D3DPOOL_DEFAULT though. Then, if the original texture is in D3DPOOL_SYSTEMMEM and the texture to update in D3DPOOL_DEFAULT, you can use the IDirect3D9Device::UpdateTexture() method.

Share this post


Link to post
Share on other sites
Quote:
Original post by Aldenar
You can access a texture's surface with the GetSurfaceLevel() method. I'm not sure that the function will work on textures created in D3DPOOL_DEFAULT though. Then, if the original texture is in D3DPOOL_SYSTEMMEM and the texture to update in D3DPOOL_DEFAULT, you can use the IDirect3D9Device::UpdateTexture() method.


To clarify: textures in DirectX are sort of like collections of surfaces (one for each MIP level). You don't need to convert anything, you just access what is always there, beneath the surface, as Aldenar described (though I would recommend that you look into the DX SDK help files on this one; Aldenar's description is basically correct, but hardly enough to write code from).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement