Jump to content
  • Advertisement
Sign in to follow this  
Vorel512

D3DXCreateTextureFromResourceA fails with D3DXERR_INVALIDDATA in MFC DLL

This topic is 2538 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

Hi,

I have a 2D engine, and I would like to load my logo when the program starts.
And I have decided to do it from resources.

My probem is that I can not load the bitmap with D3DXCreateTextureFromResourceA (D3DXERR_INVALIDDATA).
I have tried to call the loading process from the "parent" program and from the dll itself. Neither was working.
Here is the corresponding code:

Resource.h

#define IDB_BITMAP1 108


.rc file

/////////////////////////////////////////////////////////////////////////////
// Hungarian resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_HUN)
#ifdef _WIN32
LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
#pragma code_page(1250)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP1 RT_RCDATA "C:\\*****\\Projects\\GAMEW\\Release\\csepp.bmp"
#endif // Hungarian resources
/////////////////////////////////////////////////////////////////////////////


in the DLL .cpp

HRESULT asd::CreateRes(LPDIRECT3DDEVICE9 d3ddev,char* loc)
{
HRESULT hr;
D3DXCreateSprite(d3ddev, &p_Sprite);
hr = D3DXCreateTextureFromResourceA(d3ddev,NULL,MAKEINTRESOURCEA(IDB_BITMAP1),&sBuffer);

if (hr == D3DERR_NOTAVAILABLE)
MessageBox(NULL,"notavail",NULL,NULL);
else if (hr == D3DERR_OUTOFVIDEOMEMORY)
MessageBox(NULL,"ovm",NULL,NULL);
else if (hr == D3DERR_INVALIDCALL)
MessageBox(NULL,"call",NULL,NULL);
else if (hr == D3DXERR_INVALIDDATA)
MessageBox(NULL,"data",NULL,NULL);
else if (hr == E_OUTOFMEMORY)
MessageBox(NULL,"em",NULL,NULL);
else
MessageBox(NULL,"other",NULL,NULL);
return hr;
}

Share this post


Link to post
Share on other sites
Advertisement
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!