Advertisement Jump to content
Sign in to follow this  
Metus

D3DXCreateTextureFromFileInMemory

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
the DDS is converted by the DirectX conversion tool - it works perfectly using D3DXCreateTexureFromFile so the file is not corrupt

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Your code doesn't allocate any memory for the fread() to read into - call malloc() with the size returned from ftell().

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Oh, and pass in "pData" to the D3DXCreate function, not &pData as you have written in your code...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!