Jack Hoxley

Morning all,

Just made a dumb mistake with my code that cause a bit of frustration. I now know the cause, but it doesn't make sense and I don't see how to fix it

I had some simple code along the lines of:

ID3D10EffectTechnique *t = g_pEffect->GetTechniqueByName( "name" );
if( NULL == t )
{
// Technique called "name" doesn't exist - error!
}

But D3D10 plodded on straight through this trap and eventually crashed when creating a state block during rendering (note: this is a bad error - it just hangs the app, no failed return code). A bit of investigating showed that GetTechniqueByName() returns garbage instead of NULL like previous FX9 did.

There is no mention in the specs I have nor the documentation about how to check if a technique (or variable..) exists and no mention of special return codes to check for...

So, anyone come across this I'm hoping I'm just doing something stupid here - I can't understand why there wouldn't be a way of checking this sort of thing short of complete enumeration of the effect.

Any help is appreciated!

Cheers,
Jack




Re: Direct3D 10 ID3D10Effect::Get**() - what happens when handle isn't found??

Ralf Kornmann

In the D3D10 the effect framework every get method will always return a valid pointer and never NULL. But you have already recognized this. When I say valid pointer this means only that you can call methods without getting access violations or other exceptions. The object behind the pointer could still be invalid. Therefore you need to check this with a call to the IsValid method that every interface contains.






Re: Direct3D 10 ID3D10Effect::Get**() - what happens when handle isn't found??

Jack Hoxley

Thanks Ralf

I saw the IsValid() functions but the SDK documentation made out that it validates the HLSL code and it read more like it wasn't to do with validating *existence*. Me being in a hurry and unclear documentation I suppose - but ::IsValid() solves my problems.

Cheers,
Jack