FILE* f = fopen( "texture.dds", "rb" );
fseek( f, 0, SEEK_END );
int size = ftell( f );
fseek( f, 0, SEEK_SET );
void* pData = 0;
fread( &pData, 1, size, f );
IDirect3DTexture9* pTex;
HRESULT hres = D3DXCreateTextureFromFileInMemory( Pipeline->get_device(), &pData, size, &pTex );
assert( hres == D3D_OK );
D3DXCreateTextureFromFileInMemory
I'm about to write my resource-loader for my engine now and was planning to implement it using an extra thread. since the Direct3D-api is the nemesis of multithreaded application, I was planning to load the raw texure-data into memory using a separate thread and then use D3DXCreateTextureFromFileInMemory in the main thread.
the problem is that D3DXCreateTextureFromFileInMemory returns
"D3DX: Unsupported file format".
the DDS is converted by the DirectX conversion tool - it works perfectly using D3DXCreateTexureFromFile so the file is not corrupt
Your code doesn't allocate any memory for the fread() to read into - call malloc() with the size returned from ftell().
Oh, and pass in "pData" to the D3DXCreate function, not &pData as you have written in your code...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement