Sign in to follow this  
Unity

D3DXCreateTextureFromFile always fails.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this