Hello world runs but no "sydney" model shows up.

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
enjoysmath
Posts: 2
Joined: Fri Apr 06, 2018 11:07 pm

Hello world runs but no "sydney" model shows up.

Post by enjoysmath »

Code: Select all

// ConsoleApplication3.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.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()
{
    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, 500, 50), true);
 
    IAnimatedMesh* mesh = smgr->getMesh("C:/irrlicht-1.8.4/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("C:/irrlicht-1.8.4/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));
        guienv->drawAll();
 
        driver->endScene();
    }
 
    device->drop();
    return 0;
}
There's the code. It hits all the branches needed to load the model and doesn't err. However the result is a blank, colored window with a label.

Not sure how to proceed....
enjoysmath
Posts: 2
Joined: Fri Apr 06, 2018 11:07 pm

Re: Hello world runs but no "sydney" model shows up.

Post by enjoysmath »

Solved.

Forgot the

smgr->drawAll();

in the while loop.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Hello world runs but no "sydney" model shows up.

Post by CuteAlien »

Ah, I love when problems fix themself :-) And welcome to Irrlicht!
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
Post Reply