WHY? Stupid problem... why is it doing this?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Rabid Mantis
Posts: 61
Joined: Sun May 08, 2005 11:30 am

WHY? Stupid problem... why is it doing this?

Post by Rabid Mantis »

I'm having a problem with a certain line whenever I try to load a model.

scene::IAnimatedMesh* m = Device->getSceneManager()->getMesh(filename);

If I have this line in main() it works. But if I for example put it in LoadModel() and call it from that exact same place, it gives me the System.NullReferenceException error.

I have Device declared as a global
IrrlichtDevice *Device = 0;
and then set it up at the beginning of main()
IrrlichtDevice *Device = createDevice(video::EDT_DIRECTX9,
core::dimension2d<s32>(1024, 768),
16, true, false, false, &receiver);


Does anyone know what could be happening? I've done this exact same thing in other programs without getting this problem.
MasterD
Posts: 153
Joined: Sun Feb 15, 2004 4:17 pm
Location: Lübeck, Germany
Contact:

Post by MasterD »

When you set your Device in Main with

IrrlichtDevice * Device ...

a new local Variable is being created which has nothing in commen with your global pointer (except for same variable types).

only use

Device = ...
YASS - Yet another Space Shooter
under Devolpment, see http://yass-engine.de
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

Or pass your Device to LoadModel as a parameter.
Toma
"This is not a bug, this is a feature!"
Rabid Mantis
Posts: 61
Joined: Sun May 08, 2005 11:30 am

Post by Rabid Mantis »

oh crap, you're right. how could I have missed that? :oops: i guess thats what i get for copy/pasting code without double checking it.

I am the village idiot.
Post Reply