PDA

View Full Version : [c++] problema Irrlicht


sam333
17-07-2013, 22:30
Ciao a tutti ho provato a compilare questo codice che si trova nel primo tutorial

#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;


int main()
{
IrrlichtDevice *irrDevice = createDevice(EDT_SOFTWARE,
dimension2d<s32>(512, 384),
16,
false,
false,
0);

irrDevice->setWindowCaption(L"Dev-C++ and the Irrlicht Engine!");

IVideoDriver* irrDriver = irrDevice->getVideoDriver();
ISceneManager* irrSceneMgr = irrDevice->getSceneManager();
IGUIEnvironment* irrGUIEnv = irrDevice->getGUIEnvironment();

irrGUIEnv->addStaticText(
L"Hello World! This is the Irrlicht software engine!",
rect<int>(10,10,200,30), true, true, 0, -1);

while(irrDevice->run())
{
irrDriver->beginScene(true, true, SColor(0,192,192,192));

irrSceneMgr->drawAll();
irrGUIEnv->drawAll();

irrDriver->endScene();
}

irrDevice->drop();

return(0);
}



Ma mi da questo errore:

|18|error: invalid initialization of reference of type 'const irr::core::dimension2d<unsigned int>&' from expression of type 'irr::core::dimension2d<int>'|

e pure questo:


|error: in passing argument 2 of 'irr::IrrlichtDevice* irr::createDevice(irr::video::E_DRIVER_TYPE, const irr::core::dimension2d<unsigned int>&, irr::u32, bool, bool, bool, irr::IEventReceiver*)'|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|



Sapete per caso come potrei risolvere questo problema?...:help:

vendettaaaaa
18-07-2013, 08:36
Ciao a tutti ho provato a compilare questo codice che si trova nel primo tutorial

#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;


int main()
{
IrrlichtDevice *irrDevice = createDevice(EDT_SOFTWARE,
dimension2d<s32>(512, 384),
16,
false,
false,
0);

irrDevice->setWindowCaption(L"Dev-C++ and the Irrlicht Engine!");

IVideoDriver* irrDriver = irrDevice->getVideoDriver();
ISceneManager* irrSceneMgr = irrDevice->getSceneManager();
IGUIEnvironment* irrGUIEnv = irrDevice->getGUIEnvironment();

irrGUIEnv->addStaticText(
L"Hello World! This is the Irrlicht software engine!",
rect<int>(10,10,200,30), true, true, 0, -1);

while(irrDevice->run())
{
irrDriver->beginScene(true, true, SColor(0,192,192,192));

irrSceneMgr->drawAll();
irrGUIEnv->drawAll();

irrDriver->endScene();
}

irrDevice->drop();

return(0);
}



Ma mi da questo errore:

|18|error: invalid initialization of reference of type 'const irr::core::dimension2d<unsigned int>&' from expression of type 'irr::core::dimension2d<int>'|

e pure questo:


|error: in passing argument 2 of 'irr::IrrlichtDevice* irr::createDevice(irr::video::E_DRIVER_TYPE, const irr::core::dimension2d<unsigned int>&, irr::u32, bool, bool, bool, irr::IEventReceiver*)'|
||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|



Sapete per caso come potrei risolvere questo problema?...:help:
Il primo errore è auto esplicativo: dimension2d<unsigned int> e dimension2d<int> sono tipi diversi.

sam333
18-07-2013, 13:13
quindi pasta che levo unsigned?e per il secondo non sai?...

vendettaaaaa
18-07-2013, 13:17
quindi pasta che levo unsigned?e per il secondo non sai?...
Il compilatore ti ha dato due errori ma nel codice ce n'è uno solo. Il secondo infatti ti dice che c'è un errore nel secondo argomento della funzione, che è proprio la const reference a dimension2d<uint>.

Cmq sì, risolveresti togliendo unsigned (o mettendolo alla variabile che passi alla funzione). Devi valutare tu in base a cosa significa quel tipo.

sam333
18-07-2013, 20:04
Il compilatore ti ha dato due errori ma nel codice ce n'è uno solo. Il secondo infatti ti dice che c'è un errore nel secondo argomento della funzione, che è proprio la const reference a dimension2d<uint>.

Cmq sì, risolveresti togliendo unsigned (o mettendolo alla variabile che passi alla funzione). Devi valutare tu in base a cosa significa quel tipo.

io unsigned non lo trovo.....
il codice non è il mio è del tutorial dentro alla libreria..

vendettaaaaa
18-07-2013, 21:25
io unsigned non lo trovo.....
il codice non è il mio è del tutorial dentro alla libreria..
Credo che dovresti sostituire s32 con u32 nella prima funzione che chiami dal main:
IrrlichtDevice *irrDevice = createDevice(EDT_SOFTWARE,
dimension2d<s32>(512, 384),
16,
false,
false,
0);

La funzione della libreria vuole unsigned int, se non ho capito male, quindi la devi chiamare passandogli una dimension2d<u32> anzichè dimension2d<s32>.