[solved] error on first tutorial (hello world)

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
chalkos
Posts: 4
Joined: Sat Oct 10, 2009 5:17 pm

[solved] error on first tutorial (hello world)

Post by chalkos »

I'm using VS2008 express and i have errors compiling the first tutorial.

my code (exactly as in the tutorial):

Code: Select all

#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()
{
	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;
}
When i build it:

Code: Select all

1>------ Build started: Project: testgame, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>c:\users\asus\documents\visual studio 2008\projects\testgame\testgame\main.cpp(21) : error C2664: 'irr::createDevice' : cannot convert parameter 2 from 'irr::core::dimension2d<T>' to 'const irr::core::dimension2d<T> &'
1>        with
1>        [
1>            T=irr::s32
1>        ]
1>        and
1>        [
1>            T=irr::u32
1>        ]
1>        Reason: cannot convert from 'irr::core::dimension2d<T>' to 'const irr::core::dimension2d<T>'
1>        with
1>        [
1>            T=irr::s32
1>        ]
1>        and
1>        [
1>            T=irr::u32
1>        ]
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>Build log was saved at "file://c:\Users\Asus\Documents\Visual Studio 2008\Projects\testgame\testgame\Debug\BuildLog.htm"
1>testgame - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
what would be the problem?

thanks in advance
Last edited by chalkos on Sat Oct 10, 2009 5:33 pm, edited 1 time in total.
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

dimension<s32> should be dimension<u32>
It seems the tutorials haven't been updated.
multum in parvo
chalkos
Posts: 4
Joined: Sat Oct 10, 2009 5:17 pm

Post by chalkos »

thanks for the fast answer. I even declared the dimension as as constant and got a great error saying that

Code: Select all

cannot convert from 'const irr::core::dimension2d<T>' to 'const irr::core::dimension2d<T>' 
which is pretty weird.
i'll change the tag. thanks
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It isn't all that weird if you read the entire message. It will probably say something like this on the lines that follow...

Code: Select all

        with 
        [ 
            T=irr::s32 
        ] 
        and 
        [ 
            T=irr::u32 
        ] 
If you do a little substitution, you'll get something like this, which makes much more sense...

Code: Select all

cannot convert from 'const irr::core::dimension2d<irr::s32>' to 'const irr::core::dimension2d<irr::u32>' 
Travis
Post Reply