Page 1 of 1

Unhandled Exception on CreateDevice [SOLVED]

Posted: Tue May 05, 2009 2:21 pm
by Avidan84
Hey guys, im a newb at irrlicht and i am trying to start a whole new project, i am following the hell world tutorial, and it is all set up fine but when i try to run it, it will get to createDevice(); and when it calls that function i get a unhandled exception error.

Code: Select all

device =
	#ifdef _IRR_OSX_PLATFORM_
		// Mac OS X
		createDevice( video::EDT_OPENGL, dimension2d<s32>(PixelsHorizontal, PixelsVertical), 16, false, false, false, 0);
	#else
		// Windows
		irr::createDevice( irr::video::EDT_SOFTWARE, irr::core::dimension2d<irr::s32>(PixelsHorizontal, PixelsVertical), 16, false, false, false, 0);
	#endif
device is set up as a member variable earlier on, i am pretty sure i have everything set up, libs linked and dll included.
Any ideas?
Please i need help ASAP :(

Re: Unhandled Exception on CreateDevice

Posted: Tue May 05, 2009 2:42 pm
by CuteAlien
Avidan84 wrote:i am following the hell world tutorial
Yeah, that's hell on earth ;-)
Avidan84 wrote: Any ideas?
Yes. Post more code. Obviously createDevice works for most people as no one could do anything otherwise with the engine. So the problem is most likely not in this line. And as we don't see the rest we will have a hard time helping you otherwise ...

Btw. does the hello world example which is in the examples folder work?

Posted: Tue May 05, 2009 2:53 pm
by Avidan84
Yes i can compile from the examples

Code: Select all

#ifndef IRRLICHT_SETUP_H
#define IRRLICHT_SETUP_H

#include "../Includes/CPPIncludes.h"
#include "../Includes/IrrlichtEngine.h"

namespace Castor
{
	class IrrlichtSetup
	{
	public:
		IrrlichtSetup();
		~IrrlichtSetup();

		// Sets up the initial Irrlicht engine
		int		SetupDevice(int PixelsHorizontal, int PixelsVertical);
		void	SetWindowTitle(std::string windowTitle);


	private:
		irr::IrrlichtDevice *device;
	};
}

#endif

//CPP FILE HERE

#include "IrrlichtSetup.h"

int Castor::IrrlichtSetup::SetupDevice(int PixelsHorizontal, int PixelsVertical)
{
	device =
	#ifdef _IRR_OSX_PLATFORM_
		// Mac OS X
		createDevice( video::EDT_OPENGL, dimension2d<s32>(PixelsHorizontal, PixelsVertical), 16, false, false, false, 0);
	#else
		// Windows
		irr::createDevice( irr::video::EDT_SOFTWARE, irr::core::dimension2d<irr::s32>(PixelsHorizontal, PixelsVertical), 16, false, false, false, 0);
	#endif

	if (!device)
		{return 1;}
	else
		{return 0;}
}


[/code]

Posted: Tue May 05, 2009 2:54 pm
by Avidan84

Code: Select all

#include "Includes/IrrlichtEngine.h"
#include "IrrlichtSetup/IrrlichtSetup.h"
#include "Includes/CPPIncludes.h"

int main( )
{
	int screenWidth = 1024;
	int screenHeight = 768;

	Castor::IrrlichtSetup *setup = new Castor::IrrlichtSetup();

	int result = setup->SetupDevice(screenWidth, screenHeight);



	return 0;
}


and in IrrlichtEngine  is

#ifndef IRRLICHT_ENGINE_H
#define IRRLICHT_ENGINE_H

#include <irrlicht.h>

#ifdef _IRR_WINDOWS_
	#pragma comment(lib, "Irrlicht.lib")
	#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
#endif


Posted: Tue May 05, 2009 3:18 pm
by CuteAlien
Hm, that looks ok. You say you can compile the example, but your code also does compile, you have a crash at runtime, right?

Maybe you accidentally mix Irrlicht versions? Like some old dll which is still in the systems folder?

Posted: Tue May 05, 2009 3:40 pm
by Avidan84
Yeah it was a dll problem, solved now.
Thank you very much and i look forward to using this engine.