Page 1 of 1

Irrlicht + IrrWizard n00b problems

Posted: Tue Feb 24, 2009 12:03 am
by hellshady00
Okay, after alot of other noob problems i finally managed to setup Irrlicht & the IrrWizard LITE framework and make a few minor changes.

Everything compiles fine, i only get 1 warning which is completely irrelevant atm.

The problem is that the program crashes immediately after creating the irrlicht device, even the very next statement is never ran.

Heres the only code that i can tell is relevant:

Code: Select all

void CGameManager::createDevice(wchar_t* windowCaption, irr::core::dimension2d<s32> windowRes, bool windowFullscreen) {
    std::cout<<"Creating graphics device...\n";
	//Device parameters -> renderer|screen size|colour depth|full window|shadows|vsync|input device
    m_pDevice =  irr::createDevice(EDT_OPENGL, windowRes, 16, windowFullscreen, true, false, 0);

// PROGRAM CRASHES HERE, COUT NEVER RUNS.
    std::cout<<"Setting window caption\n";
    m_pDevice->setWindowCaption(windowCaption);

    std::cout<<"Setting irrlicht device pointers:\n";
	m_pDriver = m_pDevice->getVideoDriver();
    m_pSceneManager = m_pDevice->getSceneManager();
	m_pGUIEnvironment = m_pDevice->getGUIEnvironment();
}
The last line of the output reads: GLSL not available, but i dont think that is what is causing the crash.

Just in case anyone is interested:
Doxygen -
http://shady.evilfuckerz.org

http://code.google.com/p/shady-open/downloads/ or
http://shady.evilfuckerz.org/files

SVN -
http://shady-open.googlecode.com/svn/trunk/ shady-open-read-only

That should cover it :)

Thanks in advance.

Posted: Tue Feb 24, 2009 1:50 am
by Acki
oh boy, I don't know where to start... :roll:

first of all, I didn't get it to work because I gave up searching for all errors you made... :lol:

but I'll tell you what I found so far:

1st: the implementation of OnEvent is wrong !!!
it must be:

Code: Select all

bool OnEvent(const SEvent& event);
2nd: you missed bracets in CGameManager::ChangeState !!!
it must be:

Code: Select all

void CGameManager::ChangeState(CGameState * pState)
{
	if (m_pGameState){ // <<<<<  missing bracet
        std::cout<<"m_pGameState->Clear\n";
		m_pGameState->Clear(this);
	} // <<<<<  missing bracet
	if ( pState != m_pGameState ) {
	    std::cout<<"Changing to new state...\n";
		m_pGameState = pState;
		m_pGameState->Init(this);
	}
}
ok, they was only silly errors... ;)

but now comes the bad things:
if you want to work with pointers, then you have to know how to work with them !!! :roll:

you're using 2 pointers (I saw so far): m_GameManager and CGameIntro
but you never create instances of them, so you're working with objects that doesn't exist !!!

I think you should create them in the CGame constructor:

Code: Select all

CGame::CGame(wchar_t* windowCaption, int x, int y, bool fullscreen) {
    // Here you would also initialize your other game engine tools, from m_GameManager

    // create new instances of the two classes !!!
    m_GameManager = new CGameManager;
    CGameIntro = new CGameIntroState;

    std::cout<<"m_GameManager->createDevice\n";
    m_GameManager->createDevice2(windowCaption, irr::core::dimension2d<s32>(x, y), fullscreen);
    m_GameManager->loadLevel(CGameIntro);
}
of course you need to release/delete them when you don't need them anymore (usually at program end)...


that's what I found so far...
I didn't want to search for more errors by now, because I think you messed up the whole code like this and it's a realy big bunch of code you have there... :lol:
hellshady00 wrote:If you can't find any irrlicht specific tutorials and you are just starting to learn C++ then you might want to check out cprogramming.com helped me alot.
maybe you should have a deeper look at it !?!?! :twisted:

Posted: Tue Feb 24, 2009 2:01 am
by hellshady00
Thanks...

I know there are lots of errors in the code, but why is it crashing HERE?

edit: well, i'll fix the things you mentioned and update the svn, have a look later if you get bored lol

-- btw, you said to have a deeper look at cprogramming.com, any section in particular? i always hated pointers :-p
but maybe there are other things im missing?

thanks again for finding those errors, might have taken me a while to find those myself :-p

Posted: Tue Feb 24, 2009 2:18 am
by Acki
hellshady00 wrote:but why is it crashing HERE?
Acki wrote:you're using 2 pointers (I saw so far): m_GameManager and CGameIntro
but you never create instances of them, so you're working with objects that doesn't exist !!!
hellshady00 wrote:i'll fix the things you mentioned and update the svn, have a look later if you get bored
I won't unless you make a new download... ;)
also, if your program uses/needs assets, then include them to the download, please (b.c. it will also cause a crash if the program doesn't find the needed assets and you don't check/handle this)...

Posted: Tue Feb 24, 2009 7:44 am
by hellshady00
Thanks again, turns out it really wasn't that bad :)

Everything runs perfectly now, though im sure i'll run into some minor things later on.

All the links are updated if you want to check it out.

Any other help you can give me would be great :D