D3DXCreateTextureFromFileInMemory

Started by
4 comments, last by Metus 18 years, 8 months ago
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".

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 );

Ethereal
Advertisement
how did you create the dds file?
the DDS is converted by the DirectX conversion tool - it works perfectly using D3DXCreateTexureFromFile so the file is not corrupt
Ethereal
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...
dang... i really hate reading from file. Thanks :)
Ethereal

This topic is closed to new replies.

Advertisement