Sign in to follow this  
schmidt

copy one texture to another?

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

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