window keeps exiting - first tutorial
-
- Posts: 3
- Joined: Mon Jun 29, 2009 10:44 pm
window keeps exiting - first tutorial
I got my code to compile and everything, but when I click on the exe files it opens and exits the window pretty fast. I have tried cin.get() or system(pause), but I still have the same problem. Any help will be appreciated.
Thanks,
Ricardo
Thanks,
Ricardo
-
- Posts: 3
- Joined: Mon Jun 29, 2009 10:44 pm
I dont get it. It is exactly the same code as the tutorial webpage:
I do not know why does it keep exiting! =s
This is the code:
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
int main()
{
cin.get();
IrrlichtDevice *device =
#ifdef _IRR_OSX_PLATFORM_
createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#else
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#endif
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)
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;
}
I do not know why does it keep exiting! =s
This is the code:
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
int main()
{
cin.get();
IrrlichtDevice *device =
#ifdef _IRR_OSX_PLATFORM_
createDevice( video::EDT_OPENGL, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#else
createDevice( video::EDT_SOFTWARE, dimension2d<s32>(640, 480), 16,
false, false, false, 0);
#endif
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)
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;
}
Are you sure it really starts the application? Check the build-messages, are there any errors?
Otherwise you might want to step through it with the debugger (set a breakpoint in the first line).
Otherwise you might want to step through it with the debugger (set a breakpoint in the first line).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 3
- Joined: Mon Jun 29, 2009 10:44 pm
are you sure this path is valid: "../../media/sydney.md2" ?!?!?
do you realy have the media files there !?!?!
do you realy have the media files there !?!?!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Posts: 102
- Joined: Sat Jan 17, 2009 4:33 am
- Location: Pune
- Contact:
Well, if it actually quits in the application then most likely for the reason Acki mentioned - it doesn't find the media files.
But just set a breakpoint in the first line, start in debug and step through. If you are using an IDE (and I suppose so) than that is easy to do. If you tell us which IDE we might even be able to tell you exactly how to do that.
But just set a breakpoint in the first line, start in debug and step through. If you are using an IDE (and I suppose so) than that is easy to do. If you tell us which IDE we might even be able to tell you exactly how to do that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
yes, the missing media files are the most common error for this...
but what makes me curious is that he says that there is just the black console:
maybe try it without that cin.get() (what ever it is for in this code ???) and look what the console tells you...
but what makes me curious is that he says that there is just the black console:
but the console should tell what happened...richard3014@hotmail.com wrote:When I comment out this line:
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
The black window stays, but the other window console never appears.
maybe try it without that cin.get() (what ever it is for in this code ???) and look what the console tells you...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java