Access Violation for run->()
Access Violation for run->()
Hi,
I have a CIrrlichtManager class that has a function initIrrlicht which creates a device with the same code (with OPENGL instead of software) in the hellworld tutorial, so that is not the problem. In my main.cpp I create an instance of my CIrrlichtManager class like so:
CIrrlichtManager irrlichtManager;
Then I call the initIrrlicht function like so:
irrlichtManager.initIrrlicht();
I then check to see if the device is null (to see if that was the problem, but it isnt).
Then I do this (the line where the program errors after debugging with msvc++ 2003)
while(irrlichtManager.device->run()) //Error line
{
irrlichtManager.driver->beginScene(true, true, Scolor(0,100,100,100));
irrlichtManager.smgr->drawAll();
irrlichtManager.guienv->drawAll();
irrlichtManager.driver->endScene();
}
It all compiles fine but when I run it, the program crashes and I when I debug it in MSVC++ 2003 it errors on the while loop for run->() with this error:
Unhandled exception at 0X003d004a in OninWars.exe: OxC0000005: Access violation writing location 0x0016f03d
Thanks for any help
I have a CIrrlichtManager class that has a function initIrrlicht which creates a device with the same code (with OPENGL instead of software) in the hellworld tutorial, so that is not the problem. In my main.cpp I create an instance of my CIrrlichtManager class like so:
CIrrlichtManager irrlichtManager;
Then I call the initIrrlicht function like so:
irrlichtManager.initIrrlicht();
I then check to see if the device is null (to see if that was the problem, but it isnt).
Then I do this (the line where the program errors after debugging with msvc++ 2003)
while(irrlichtManager.device->run()) //Error line
{
irrlichtManager.driver->beginScene(true, true, Scolor(0,100,100,100));
irrlichtManager.smgr->drawAll();
irrlichtManager.guienv->drawAll();
irrlichtManager.driver->endScene();
}
It all compiles fine but when I run it, the program crashes and I when I debug it in MSVC++ 2003 it errors on the while loop for run->() with this error:
Unhandled exception at 0X003d004a in OninWars.exe: OxC0000005: Access violation writing location 0x0016f03d
Thanks for any help
Can you post whole initIrrlicht() function, or even better whole class ?
And remeber to put it into
And remeber to put it into
Code: Select all
tags.
Tomasz Nowakowski
Openoko - www.openoko.pl
Openoko - www.openoko.pl
Sure,
Unfortunatley, I had to type that out instead of copy and paste because I'm on another computer, lol.
Code: Select all
void CIrrlichtManager::initIrrlicht()
{
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(800,600), 32, true, false, 0);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0, 30, 50, -1);
}
By calling like that:
You create a new pointer which is deleted as soon as program leaves functions body.
If you want to assign a new value to device, member of your class it should be:
Code: Select all
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(800,600), 32, true, false, 0);
If you want to assign a new value to device, member of your class it should be:
Code: Select all
device = createDevice(EDT_OPENGL, dimension2d<s32>(800,600), 32, true, false, 0);
Tomasz Nowakowski
Openoko - www.openoko.pl
Openoko - www.openoko.pl
You should make "device" a public variable of the CIrrlichtManager class by declaring it in the public section of the class definition.
Then you use as warui said
In the initilization function. You can do the same for the other stuff to like SceneManager and what not.
-Mindl
Code: Select all
public:
IrrlichtDevice *device;
Code: Select all
device = createDevice(EDT_OPENGL, dimension2d<s32>(800,600), 32, true, false, 0);
-Mindl