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.
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Tue Mar 18, 2008 12:55 pm
Hello,
here is what I did: I created a new project. I added a TImage object (drawDest) to the mainform. My Form-Class looks like this:
Header:
Code: Select all
class TForm1 : public TForm
{
__published: // Von der IDE verwaltete Komponenten
TImage *drawDest;
private: // Benutzer-Deklarationen
public: // Benutzer-Deklarationen
__fastcall TForm1(TComponent* Owner);
irr::IrrlichtDevice *device;
irr::video::IVideoDriver *driver;
irr::scene::ISceneManager *smgr;
irr::gui::IGUIEnvironment *guienv;
};
Sourcefile:
Code: Select all
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
irr::SIrrlichtCreationParameters param;
param.WindowId = drawDest->Canvas->Handle;
param.DriverType = irr::video::EDT_SOFTWARE;
device = irr::createDeviceEx(param);
driver = device->getVideoDriver();
smgr = device->getSceneManager();
}
When I compile and run all this I simply get the error message: EAccessViolation
The last two lines are the ones which cause the crash, but I have no idea why. Can somebody help me?
Best regards,
Efrint
JP
Posts: 4526 Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:
Post
by JP » Tue Mar 18, 2008 1:09 pm
Did you consider checking if device is a valid pointer before using it? Presumably the device creation has failed and so when you do device->getVideoDriver() you've got a null pointer.
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Tue Mar 18, 2008 2:23 pm
No it didn't come to my mind to check if the device was created successfully. You are right. The creation fails. Any idea why?
JP
Posts: 4526 Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:
Post
by JP » Tue Mar 18, 2008 2:39 pm
What does the console say? If you actually get that printed out anyway...
Presumably it fails from bad parameters passed to it or something
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Tue Mar 18, 2008 3:21 pm
ok. It seems to be the handle.
When I write:
instead of:
Code: Select all
param.WindowId = renderDest->Canvas->Handle;
it works. (but now Irrlicht uses the whole window) Is it possible that Irrlicht can only draw into the whole window, but not in the canvas of an image?
EDIT: I replaced the canvas with a TPanel object and now it works...at least at the moment