Partial texture copying

Started by
3 comments, last by Illco 18 years, 10 months ago
Hi, I am trying to break up a texture into smaller sectors, in a grid pattern. If I wanted to split a 64 x 64 tex, for arguments sake, into individual 8x8 parts, how would i go about that? can i simply lock the source and dest rects of the textures then just copy the data across? This would be done at init, not while running.... Any suggestions much appreciated Simon
Advertisement
Yes you can do that. But be aware of the format the texture is stored in; you are working with bytes on the device and any mistake may crash the driver. A more safe (but slower) option is to make a copy in a known format (like A8R8B8G8) and then fork off the sub pictures. If you are using D3DX you can use D3DXLoadSurfaceFromSurface() to do this.

Greetz,

Illco
But D3DXLoadSurfaceFromSurface will not work for textures, will it? I thought surfaces were slightly different!

If it does work, how do i go about copying just a small section of the source texture to the destination texture?

Thanks

You could use D3DXLoadSurfaceFromSurface() if you acquired the first-level surface of the texture (IDirect3DTexture9::GetSurfaceLevel( 0 ) iirc). This can cause problems with mip-maps though.

I'm at work now, so dont have the code to hand, but I think F1CM uses StretchRect() to break up an 800x600 background into smaller 2n textures.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I meant it in the way JollyJeffers elaborated upon. It does not cause problems with mipmaps; you only have to re-generate them afterwards (you can, indeed, not just copy them because the mipmaps are computed for the full texture).

This topic is closed to new replies.

Advertisement