[DX9] D3DXCreateTextureFromFileInMemoryEx question

This topic is 2316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello, I load a file which contains several dds images.

Does the D3DXCreateTextureFromFileInMemoryEx argument LPCVOID pSrcData start before or after the header? It is a DXT3 compressed dds image from memory.

I figure since so much of the arguments could be found in the header then my assumption that the header is not needed for this function is correct.

msdn:
 HRESULT D3DXCreateTextureFromFileInMemoryEx( __in LPDIRECT3DDEVICE9 pDevice, __in LPCVOID pSrcData, __in UINT SrcDataSize, __in UINT Width, __in UINT Height, __in UINT MipLevels, __in DWORD Usage, __in D3DFORMAT Format, __in D3DPOOL Pool, __in DWORD Filter, __in DWORD MipFilter, __in D3DCOLOR ColorKey, __inout D3DXIMAGE_INFO *pSrcInfo, __out PALETTEENTRY *pPalette, __out LPDIRECT3DTEXTURE9 *ppTexture ); 

pSrcData [in]
Pointer to the file in memory from which to create the texture.

Share on other sites
The function does require file header data as well.

The rest of the input parameters describe the desired destination texture properties, which may or may not be same as in the original image.Furthermore, the function works with many other formats in addition to DDS, that may not have the same file contents organization.

Share on other sites
That sucks :/ guess I have to CreateTexture and copy layer info with Rectlocking. Or maybe I can just remake a header and append the dds pixel data?

Share on other sites
The function doesn't care whether or not the original data is actually read from file or somewhere else, so you could provide your own header and concatenate it with the rest of the data before feeding the memory to it.

More often than not, however, content files in packages (which, I assume, is your scenario here) are actually of varying dimensions and formats. The DDS header isn't exactly huge, and leaving it with each file in memory would make your life easier in the long run.