Direct3D Texture Loading Question

Recommended Posts

How would I go about loading a texture manually, and then sending the image data to DirectX to create a texture with?
(i.e. a Direct3D equivalent to glTexImage2D)
I can''t use D3DXCreateTextureFromFile because my textures are stored in a archive file.
Any help is greatly appreciated.

Share this post

Link to post

Share on other sites

Could you be more specific about what would be involved in "Creating the texture, locking the surface, and copying the bits into the buffer myself" please? The documentation is rather vague on this subject...

*phew* All the bit shifting and masking copies the bits into the surface correctly. Play about with it on paper if you don''t understand.

That code assumes the input is 32-bit BGRA data."g_texMgr.m_dwTextureBytes" is the number of bytes-per-pixel the texture format is in (often D3DFMT_A8R8G8B8, but my code determines the best possible format to use that is compatible with the render target and device.)