D3DXCreateEffectFromFile error?

Started by
1 comment, last by Evil Steve 12 years, 3 months ago
For some reason I keep getting an error when I try to load an fx file in my Effect class,here is the loader function



HRESULT CFXFileEntity::Load(std::string path)
{
HRESULT hr;

if (FAILED(hr=D3DXCreateEffectFromFile(m_d3dDevice,path.c_str(),NULL,NULL,0,NULL,&anEffect,NULL)))
return hr;

if (FAILED(hr=anEffect->FindNextValidTechnique(NULL,&hTech)))
return hr;
}


it doesn't return any hr value(???) and it crashes at this line:

if (FAILED(hr=D3DXCreateEffectFromFile(m_d3dDevice,path.c_str(),NULL,NULL,0,NULL,&anEffect,NULL)))
I've tried different simple fx files,both from RenderMonkey and from FX Composer and it always crashes,debug says the error code is


Unhandled exception at 0x546d1ea8 in GAME.exe: 0xC0000005: Access violation reading location 0xcccccccc.[/quote]

what could be causing this?
Advertisement
I'm guessing m_d3dDevice is equal to 0xcccccccc because CreateDevice() failed.

Enabling the debug runtimes in the control panel that came with the SDK should tell you exactly what's wrong.
This is why you always initialise your variables. As Adam_42 said, your m_d3dDevice pointer is invalid (Never intitialised). I don't think even the debug runtimes would catch that particular error since it's a hard crash.

The other possibility is that anEffect is the first member of the class and your CFXFileEntity class instance isn't initialised, such as in:

CFXFileEntity* foo;
foo->Load("Thingmy");

This topic is closed to new replies.

Advertisement