irrlicht window flashes and disappears

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
Silent Assassin
Posts: 15
Joined: Wed Jan 16, 2008 6:55 am

irrlicht window flashes and disappears

Post by Silent Assassin »

when i compile in visual studio 2005 the irrlicht window just flashes and then disappears? what could be the solution?
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

we cant guess. show some code, or some details :)
Silent Assassin
Posts: 15
Joined: Wed Jan 16, 2008 6:55 am

Post 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();
}
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
Morgawr
Posts: 95
Joined: Wed Sep 26, 2007 7:04 pm

Post by Morgawr »

It doesn't have the while loop where you "run" the program... what else could it do? :/
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post 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?
Image Image Image
brick
Posts: 36
Joined: Sun Jul 10, 2011 12:15 pm

Re: irrlicht window flashes and disappears

Post 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.
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: irrlicht window flashes and disappears

Post 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
brick
Posts: 36
Joined: Sun Jul 10, 2011 12:15 pm

Re: irrlicht window flashes and disappears

Post 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.
Post Reply