copying textures into textures

Started by
7 comments, last by John Morris 22 years, 2 months ago
Can I copy a small texture into a larger texture (to combine a bunch of small ones into one large) somehow with DirextX 8? Or is it at least possible to make sure a texture I create has a given size regardless how big the picture is and what the computer is capable of (like, create a 256x256 texture and load a picture into it without changing the size of the texture OR the picture)
Advertisement
I think you can still lock the surface of a DD8 texture. you will have to copy the pixels manually and account for all the different formats. they should have kept DirectDraw!!!
Surfaces are still at the heart of textures. Look into the methods of the texture interface and the surface interface.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
well, I cannot use CopyRects as it requires surfaces and tells me that it cannot convert textures to surfaces.
It depends on how you often you are going to composite those "compound textures" but if you want to do it in real time then use the following pattern:

1. Create your FINAL destination texture (containing the composited imagery) in D3DPOOL_DEFAULT
2. Create your TEMPORARY destination texture (containing the composited imagery) in D3DPOOL_SYSTEM
3. Create your source textures (your small textures) in D3DPOOL_SYSTEM
4. CopyRects() all your small textures into the TEMPORARY destination texture
5. Update the FINAL destination texture from the TEMPORARY destination texture using IDirect3DDevice8::UpdateTexture() - _DONT_ use CopyRects for this step. CopyRects is
a slow legacy method that exists just to enable certain things such as
copying from vidmem to sysmem (which is slow anyways). It is not meant to
be used in performance sensitive cases.

Quote Sameer Nene (MS D3D Team):

The reason UpdateTexture forces use of system mem source and default
dest is because this is the only guaranteed high performance code path
possible with the majority of current hardware architectures that rely on
swizzling. So even if you "think" it works using DX7, you would
be horrified to know what the driver is really doing inside.

You can use sub-rect updates with UpdateTextures. LockRect automatically
marks regions dirty and UpdateTexture updates only the dirty regions.





quote:Original post by John Morris
Can I copy a small texture into a larger texture (to combine a bunch of small ones into one large) somehow with DirextX 8? Or is it at least possible to make sure a texture I create has a given size regardless how big the picture is and what the computer is capable of (like, create a 256x256 texture and load a picture into it without changing the size of the texture OR the picture)


Like I said, CopyRects() fails on me...

Anyway I don''t need a realtime solution as I only want to get the small files in one sheet to prevent having to SetTexture() for every of 80 tiles every frame. I can do that while loading the file, and it won''t be necessary afterwards.
If the textures don't change, have you though about building your "texture page" in an external program? It would take a list of images, then spits out a big texture(s) with them in. Along with this a file specfiying the uv offset to each subtexture in it.

Note, if you have all your textures in a big texture, texture wrapping/mirroring won't work, (you'll get bits of other textures as well.)

Edited by - Mark Duffill on February 21, 2002 9:25:15 AM
Call IDirect3DTexture8::GetSurfaceLevel and use the returned surface for CopyRects().

P.S: next time RTFM

quote:Original post by John Morris
Like I said, CopyRects() fails on me...

Anyway I don''t need a realtime solution as I only want to get the small files in one sheet to prevent having to SetTexture() for every of 80 tiles every frame. I can do that while loading the file, and it won''t be necessary afterwards.


*bangs head on desk*

ok thanks guys. Never mind wrapping and such, I''m not using any filtering except for rotation and scaling frames, and the sprite files all have some empty space between the actual image and the borders. And I cannot pre-make the tile sheet as the levels have different combinations of the tiles. We''ll have several thousand tiles to choose from in the end, and a unique combination of about 80 or so for all of around 100 sub-levels.

This topic is closed to new replies.

Advertisement