Help with an Unhandled exception

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
iam13013
Posts: 31
Joined: Sun Dec 04, 2005 11:06 pm

Help with an Unhandled exception

Post by iam13013 »

When I attempt to render my scene, it get this

Code: Select all

 error :Unhandled exception at 0x0042771f in irrGame.exe: 0xC0000005: Access violation reading location 0x00000001.
This is the code that I am using:

Code: Select all

//gameManager.h
#ifndef GAMEMANAGER_H
#define GAMEMANAGER_H

#include <iostream>
#include <irrlicht.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

class CGameManager : public IEventReceiver
{
public:
	CGameManager();
	virtual ~CGameManager();
	void pause();
	IrrlichtDevice* getDevice();
	IVideoDriver* getDriver();
	ISceneManager* getSceneManager();
	IGUIEnvironment* getGUIEnvironment();
	virtual bool OnEvent(SEvent event);
    bool CreateDevice(int width, int height, int bitDepth);
	void update();
	

protected:

private:
	//Device parameters -> renderer|screen size|colour depth|full window|shadows|vsync|input device
	IrrlichtDevice* device;  
	IVideoDriver* driver;
	ISceneManager* smgr;
    IGUIEnvironment* guiEnv;

};

#endif
and:

Code: Select all

//gameManager.cpp
#include "GameManager.h"

//! Default constructor
CGameManager::CGameManager()
{
	std::cout << "-- Game Manager created!\n";
}

//! Default destructor
CGameManager::~CGameManager()
{
}

void CGameManager::pause()
{
	int pNum;
	std::cin >> pNum;
}

bool CGameManager::CreateDevice(int width, int height ,int bitDepth)
{
	//Device parameters -> renderer|screen size|colour depth|full window|shadows|vsync|input device
	device = createDevice(EDT_DIRECT3D9, dimension2d<s32>(width, height), bitDepth, false, false, true, this);
    if (device == NULL)
        device = createDevice(EDT_OPENGL, dimension2d<s32>(width, height), bitDepth, false, false, true, this);
	
	
	
	driver = device->getVideoDriver();
                smgr = device->getSceneManager();
	guiEnv = device->getGUIEnvironment();

	return 1;
}

bool CGameManager::OnEvent(SEvent event)
{
	if (!driver)
		return false;

	return true;
}

IrrlichtDevice* CGameManager::getDevice()
{
	return device;
}


IVideoDriver* CGameManager::getDriver()
{
	return driver;
}


ISceneManager* CGameManager::getSceneManager()
{
	return smgr;
}


IGUIEnvironment* CGameManager::getGUIEnvironment()
{
	return guiEnv;
}

void CGameManager::update()
{
//this is where the error occurs
	driver->beginScene(true, true, video::SColor(0,100,100,100));
	smgr->drawAll();	
	guiEnv->drawAll();
    driver->endScene();
}
The error occurs in CGameManager::update() at driver->beginScene(true, true, video::SColor(0,100,100,100));

I have stepped through it, and the device, driver, smgr, and guiEnv are all created, so I don't quite understand why I am getting this error....Please help, thanks in advance....
r-type
Posts: 41
Joined: Sun Feb 12, 2006 1:54 am

Post by r-type »

please show us your implementation of this class. Are you calling update before createdevice somewhere?
Post Reply