D3DXCreateTextureFromFile always fails.
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.
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" )
There is an easier way to get HRESULT error feedback. Check out this header.
#include <dxerr9.h>
#pragma comment ( lib, "dxerr.lib" )
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement