Copying part of one texture into another
Hi,
Can anyone tell me the best way to copy one IDirect3DTexture9 to another?
I specifically want to be able to copy part of one to part of another. I will be doing so at initialisation, so speed is not paramount.
I am trying to attach together several procedurally generated textures to create a single one, thus avoiding unnecessary SetTexture() calls at run time.
Many thanks
Simon
StretchRect and UpdateSurface can do what you want. Each has different limitations. UpdateSurface only works from a surface in the SYSMEM pool to one in the DEFAULT pool. StretchRect is more flexible but can only copy onto a render target (except for off-screen planes, which can be copied onto other off-screen planes).
If you want to copy everything into a normal texture in the MANAGED pool, the easiest way is probably to lock the end result (or use GetRenderTarget and lock the result of that) and copy to the texture.
If you want to copy everything into a normal texture in the MANAGED pool, the easiest way is probably to lock the end result (or use GetRenderTarget and lock the result of that) and copy to the texture.
Can I simply lock both textures and perform a pixel to pixel looping copy, if both textures were of identical format?
If so how would I perform that copy?
Thanks
Si
If so how would I perform that copy?
Thanks
Si
Render to a texture. If you want to copy the top-left quarter of your texture, render a quad from u = 0 -> 0.5 and v = 0 -> 0.5. Just make sure you render to the entire texture (basically rendering fullscreen, but to the texture).
blaze, u r a genius! thats such an easier way of doing it. I got rendering to textures working the other day.
I'll try it right now!
Thanks
I'll try it right now!
Thanks
You can use D3DXLoadSurfaceFromSurface to copy parts from one texture top level surface to another one. If your texture destination texture has mipmaps you should call D3DXFilterTexture as final operation to regenerate all mips.
Quote:Original post by sipickles
blaze, u r a genius! thats such an easier way of doing it. I got rendering to textures working the other day.
If you're going to use render targets, I'd suggest using StretchRect. Why go the ugly way when there's a function that already does what you want?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement