Sign in to follow this  
sipickles

Partial texture copying

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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).

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