Archived

This topic is now archived and is closed to further replies.

ZaCO

Loading a part of a .tga image to a DirectX8 _texture_

Recommended Posts

I''m not sure about loading a "part" of a TGA image onto a texture, but D3DX has a set of functions to load textures, and I''m pretty sure that they can read TGAs.

If you want to do it yourself, loading uncompressed TGAs isn''t too hard if you know the format.

Have a look at www.wotsit.org and you''ll find a document on the format.

Hope this helps,

- Pete

Share this post


Link to post
Share on other sites
Yes, exactly here I have the problem. I have one HUGE .tga file. I just can''t load it to video memory. What I want to do is to load a small rectangle from it to a cache page. D3DXLoadSurfaceFromFile() can do it for surfaces but D3DXCreateTextureFromFile() take''s no RECTs.. =(

sorry about my english..

Share this post


Link to post
Share on other sites
Ah I see.

Hmm it wouldn''t be too hard to load it yourself (taking only the part of the image you want) into a memory buffer, then have D3DX load that into a texture.

I''ve not used D3D 8 in any great detail, just OpenGL, but I''m sure D3DX can load a texture from a memory buffer.

- Pete

Share this post


Link to post
Share on other sites
If I have understood correctly from DirectX''s help I can only load the whole image to a texture (from file.. and I didn''t find any functions to load it from a memory buffer (in D3DX)). I could load a RECT from a file to a surface or create a surface from a memory buffer.. is there a way to copy the data from a surface to a texture? this would solve the problem.

Share this post


Link to post
Share on other sites
I''m getting a little out of my element here, but I think you''ll need to use 2 functions:

D3DXCreateTexture
Use this to create a texture in the size and format you want.

D3DXLoadSurfaceFromMemory
Get the surface from the texture, using IDirect3DTexture8::GetSurfaceLevel (), and load it from memory using this function.

Hope this helps, I''m not sure if I can give any more info, but post back if you''ve got problems anwyay!

- Pete

Share this post


Link to post
Share on other sites