Page 1 of 1

irrlicht window flashes and disappears

Posted: Thu Jan 17, 2008 6:27 am
by Silent Assassin
when i compile in visual studio 2005 the irrlicht window just flashes and then disappears? what could be the solution?

Posted: Thu Jan 17, 2008 7:01 am
by FuzzYspo0N
we cant guess. show some code, or some details :)

Posted: Thu Jan 17, 2008 7:59 am
by Silent Assassin
here's the sample code....



#include "irrlicht.h"
#include "iostream"

#pragma comment (lib, "Irrlicht.lib")

using namespace std;

using namespace irr;

using namespace core;

using namespace scene;

using namespace video;

using namespace io;

using namespace gui;

int main()
{
IrrlichtDevice *device = createDevice(EDT_SOFTWARE, dimension2d<s32>(640,480), 16, false, false, false, 0);

device->setWindowCaption(L"Irrlicht Engine Demo");

IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
}

Posted: Thu Jan 17, 2008 8:36 am
by hybrid
Well, what else should happen? You don't do much at all in main(), Irrlicht is quite fast with opening the window, so it will be at the end of your program very soon. At that point, the window is closed again, hence only a short flash.

Posted: Thu Jan 17, 2008 9:49 am
by Morgawr
It doesn't have the while loop where you "run" the program... what else could it do? :/

Posted: Thu Jan 17, 2008 9:51 am
by JP
Yeah it would be at least sensible to include some sort of render loop... Presumably you hacked this apart from a tutorial, but why did you hack out the rendering?

Re: irrlicht window flashes and disappears

Posted: Sun Jul 10, 2011 12:19 pm
by brick
Hi everyone, I'm working my way through the first tutorial, and I'm having the same problem. After I run the project the window just flashes. Here's the code:

#include "stdafx.h"
#include <irrlicht.h>

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

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

int main()
{
IrrlichtDevice *device = createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
false, false, false, 0);
if (!device) return 1;

device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");

IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();

guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);

IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
if (!mesh)
{
device->drop();
return 1;
}
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

if (node)
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
}

smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));

smgr->drawAll();
guienv->drawAll();

driver->endScene();
}

device->drop();

return 0;
}

Sorry if this has an obvious answer, I'm new at this.

Re: irrlicht window flashes and disappears

Posted: Sun Jul 10, 2011 12:32 pm
by Radikalizm
Your application is probably exiting here

Code: Select all

if (!mesh)
{
device->drop();
return 1;
}
I assume the mesh you're trying to load was not found
Try to set a breakpoint within this if-statement to check if this is the case

Also, it's ok to start a new thread for this, the original post for this thread was made about 3 years ago

Re: irrlicht window flashes and disappears

Posted: Sun Jul 10, 2011 1:07 pm
by brick
That's it, the mesh was at a different location, so I just had to change the path to make it load properly. Thanks a bunch.