Jump to content
  • Advertisement
Sign in to follow this  

D3DXCreateTextureFromFile always fails.

This topic is 4272 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 am trying to load a texture from a file that is in the right directory and I have tried different file types but my function is still returning an error of D3DERR_INVALIDDATA when I am debugging. When I tried to load the .exe without debugging it closes immediately, showing that mSprite->End( ) function failed. Here is the function... bool cSprite::load( char *Filename ) { HRESULT hResult; if( mAbyss == NULL ) return false; if( Filename == NULL ) return false; if( hResult = D3DXCreateTextureFromFile( mAbyss->getDevice( ), Filename, &mTexture ) ) { if( hResult == D3DERR_NOTAVAILABLE ) { MessageBox(NULL, "Function: cSprite.load( ), Error: D3DERR_NOTAVAILABLE.", "Error", MB_OK); } else if( hResult == D3DERR_OUTOFVIDEOMEMORY ) { MessageBox(NULL, "Function: cSprite.load( ), Error: D3DERR_OUTOFVIDEOMEMORY.", "Error", MB_OK); } else if ( hResult == D3DERR_INVALIDCALL ) { MessageBox(NULL, "Function: cSprite.load( ), Error: D3DERR_INVALIDCALL.", "Error", MB_OK); } else if ( hResult == D3DXERR_INVALIDDATA ) { MessageBox(NULL, "Function: cSprite.load( ), Error: D3DERR_INVALIDDATA.", "Error", MB_OK); } else if ( hResult == E_OUTOFMEMORY ) { MessageBox(NULL, "Function: cSprite.load( ), Error: E_OUTOFMEMORY.", "Error", MB_OK); } else { MessageBox(NULL, "Function: cSprite.load( ), Error: UNKNOWN_ERROR.", "Error", MB_OK); } } return true; } bool cSprite::end( ) { if( mSprite == NULL ) return false; if( FAILED( mSprite->End( ) ) ) return false; return true; } I'd appreciate any suggestions as to why it is erroring out.

Share this post


Link to post
Share on other sites
Advertisement
D3DERR_INVALIDDATA is usually caused by wrong pathname for the texture.

There is an easier way to get HRESULT error feedback. Check out this header.

#include <dxerr9.h>
#pragma comment ( lib, "dxerr.lib" )

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!