Page 1 of 1

[SOLVED]createDevice ?

Posted: Fri Apr 21, 2006 8:40 pm
by dr34mr
yet another (probably simple) problem. for the quake3 map test creating device looked like this:
IrrlichtDevice* device=createDevice(video::EDT_SOFTWARE,core::dimension2d<s32>(640,480));

as in the movement tutorial it looks like this:
device=createDevice(video::EDT_SOFTWARE,core::dimension2d<s32>(640,480),16,false,false,false,&rec);

now i know ofcourse about the default parameter values in methods, therefor i know that the difference between these two are obvious and both should work. yet the first one works ok, while the second - doesn't. why?

in the second case i get a linker error:
[Linker error] undefined reference to `_imp___ZN3irr12createDeviceENS_5video13E_DRIVER_TYPEERKNS_4core11dimension2dIiEEjbbbPNS_14IEventReceiverEPKc'

Posted: Fri Apr 21, 2006 8:48 pm
by afecelis
the second one is using a receiver so if you haven't declared one you'll get errors. It's the:

Code: Select all

,&rec);
part

just try:

Code: Select all

createDevice(video::EDT_OPENGL, core::dimension2d<s32>(800, 600),32, false, true, false,0);
or using the renderer of your choice (software in this case)

Posted: Fri Apr 21, 2006 8:52 pm
by dr34mr
the thing is i did write a class for a receiver and declared a variable of it's type. that's why i don't know where the problem comes from ;)

EDIT:
i've tried *exactly* what you wrote, but it didn't work. as well as trying out other renderers and any other variation that came to my mind ;). still nothing.

Posted: Fri Apr 21, 2006 8:59 pm
by afecelis
what are you using the receiver for? We'd need to see some more code to see what you're missing. In the case of using a receiver to set esc to quit it is common to make a mistake when you draw everything:

Code: Select all

int lastFPS = -1;
	while(device->run()&&!quit)
{
	driver->beginScene(true, true, video::SColor(0,0,0,0));
	smgr->drawAll();
        driver->endScene();
//etc etc etc
in this case, "quit" was my bool variable

Posted: Fri Apr 21, 2006 9:13 pm
by dr34mr
i think that in the case you've mentioned it would still compile, while it doesn't :?
anyway, here's the whole code:
#include <irrlicht.h>
#include <stdio.h>
#include <wchar.h>

using namespace irr;

#pragma comment(lib,"libIrrlicht.a")

scene::ISceneNode* node=0;
IrrlichtDevice* device=0;

class MyEventReceiver:public IEventReceiver{
public:
virtual bool OnEvent(SEvent event){
if(node!=0 && event.EventType==irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown){
switch(event.KeyInput.Key){
case KEY_KEY_W:
case KEY_KEY_S:{
core::vector3df v=node->getPosition();
v.Y+=(event.KeyInput.Key==KEY_KEY_W?2.0f:-2.0f);
node->setPosition(v);}
return true;
}
}
return false;
}
};

int main(){
MyEventReceiver receiver;
device=createDevice(video::EDT_OPENGL,core::dimension2d<s32>(800,600),32,false,true,false,0);
video::IVideoDriver* driver=device->getVideoDriver();
scene::ISceneManager* smgr=device->getSceneManager();

node=smgr->addTestSceneNode();
node->setPosition(core::vector3df(0,0,30));
node->setMaterialTexture(0,driver->getTexture("c:\\Irrlicht 1.0\\irrlicht-1.0\\media\\wall.bmp"));

scene::ISceneNode* n=smgr->addTestSceneNode();
n->setMaterialTexture(0,driver->getTexture("c:\\Irrlicht 1.0\\irrlicht-1.0\\media\\t35lsml.jpg"));

scene::ISceneNodeAnimator* anim=smgr->createFlyCircleAnimator(core::vector3df(0,0,30),20.0f);
n->addAnimator(anim);
anim->drop();
scene::IAnimatedMeshSceneNode* anms = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/sydney.md2"));
if (n){
anim = smgr->createFlyStraightAnimator(core::vector3df(100,0,60),core::vector3df(-100,0,60), 10000, true);
anms->addAnimator(anim);
anim->drop();
anms->setMaterialFlag(video::EMF_LIGHTING,false);
anms->setFrameLoop(320,360);
anms->setAnimationSpeed(30);
anms->setRotation(core::vector3df(0,180.0f,0));
anms->setMaterialTexture(0,driver->getTexture("c:\\Irrlicht 1.0\\irrlicht-1.0\\media\\sydney.BMP"));
}

smgr->addCameraSceneNodeFPS(0,100.0f,100.0f);
device->getCursorControl()->setVisible(false);

int lastFPS=-1;
while(device->run()){
driver->beginScene(true,true,video::SColor(255,90,90,156));
smgr->drawAll();
driver->endScene();
int fps=driver->getFPS();
if(lastFPS!=fps){
wchar_t tmp[1024];
swprintf(tmp,1024,L"Movement Example - Irrlicht Engine (%s)(fps:%d)",driver->getName(),fps);
device->setWindowCaption(tmp);
lastFPS=fps;
}
}
device->drop();
return 0;
}

Posted: Fri Apr 21, 2006 10:19 pm
by afecelis
you're trying to do WASD navigation keys? you don't need a receiver for that You can do it with a keymap, try this:

Code: Select all

//wasd navigation
	SKeyMap keyMap[8];

	keyMap[1].Action = EKA_MOVE_FORWARD;
	keyMap[1].KeyCode = KEY_KEY_W;

	keyMap[3].Action = EKA_MOVE_BACKWARD;
	keyMap[3].KeyCode = KEY_KEY_S;

	keyMap[5].Action = EKA_STRAFE_LEFT;
	keyMap[5].KeyCode = KEY_KEY_A;

	keyMap[7].Action = EKA_STRAFE_RIGHT;
	keyMap[7].KeyCode = KEY_KEY_D;
and then, in your camera:

Code: Select all

scene::ICameraSceneNode* camera = 0; 
	camera = smgr->addCameraSceneNodeFPS(0,80.0f,300.0f,-1, keyMap, 8); 
remember to remove all your receiver code first.

Posted: Sat Apr 22, 2006 9:13 am
by dr34mr
can i add a keyMap to a mesh? 'cause that's what i'm tryin' to do. i don't exactly need to move the camera, the main goal is to control the mesh.

and anyway i think, the main problem was forgotten ;). the program won't even *compile* - all i get is a linker error. all the tips you gave me were ok, but it still doesn't solve the problem, 'cause even if i create my device *without* the receiver and leave the control coding for later, it still won't compile, and i have no idea, where did i make the mistake.

Posted: Sat Apr 22, 2006 10:03 am
by dr34mr
damn it, i've got a more serious problem i think. here's a piece of code, that does absolutely nothing, besides creating device, scene, and not drawing anything, just waiting to be closed:
#include <irrlicht.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#pragma comment(lib,"libIrrlicht.a")

int main(){
IrrlichtDevice* device=createDevice(EDT_OPENGL,dimension2d<s32>(640,480));
if(device==0) return 1;
IVideoDriver* driver=device->getVideoDriver();
ISceneManager* smgr=device->getSceneManager();
while(device->run()){
driver->beginScene(true,true,SColor(255,90,90,156));
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}

that code doesn't compile either, givin' me the same linker error, i've mentioned before. anybody got any idea, what's wrong? is it something with the code, i'm missin', or maybe something wrong with my copy of irrlicht?
to be sure, here's a piece of code from the quake 3 map tut, that compiles, and works on any of given renderers:
#include <irrlicht.h>
using namespace irr;
#include <iostream>
using namespace std;

#pragma comment(lib,"libIrrlicht.a")

int main(){
video::E_DRIVER_TYPE driverType=video::EDT_SOFTWARE;

cout << "Please select driver:" << endl;
cout << "(a) OpenGL" << endl;
cout << "(b) Direct3d9" << endl;
cout << "(c) Software" << endl;
cout << "(otherKey) exit" << endl;
char i;
cin >> i;

switch(i){
case 'a':
driverType=video::EDT_OPENGL;
break;
case 'b':
driverType=video::EDT_DIRECT3D9;
break;
case 'c':
driverType=video::EDT_SOFTWARE;
default: return 1;
}

IrrlichtDevice* device=createDevice(driverType,core::dimension2d<s32>(640,480));
if(device==0){
return 1;
}
video::IVideoDriver* driver=device->getVideoDriver();
scene::ISceneManager* smgr=device->getSceneManager();

device->getFileSystem()->addZipFileArchive("c:\\Irrlicht 1.0\\irrlicht-1.0\\media\\map-20kdm2.pk3");

scene::IAnimatedMesh* mesh=smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node=0;

if(mesh) node=smgr->addOctTreeSceneNode(mesh->getMesh(0));
if(node) node->setPosition(core::vector3df(-1300,-144,-1249));

smgr->addCameraSceneNodeFPS();
device->getCursorControl()->setVisible(false);

int lastFPS=-1;

while(device->run()){
driver->beginScene(true,true,video::SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();

int fps=driver->getFPS();
if(lastFPS!=fps){
core::stringw str=L"Irrliht Engine - Quake 3 Map Example [";
str+=driver->getName();
str+="] FPS:";
str+=fps;
device->setWindowCaption(str.c_str());
lastFPS=fps;
}
}
device->drop();
return 0;
}

the fact, that this one works perfectly well makes me sure, that i missed sumthin' in the first one. although i have no idea what. please help

Posted: Sat Apr 22, 2006 10:08 am
by gfxstyler
dreamer, do you use the original irrlicht library? or did you already try to recompile the dx-supported one? maybe you compiled it wrong.

to see if things work alright, you should always compile an irrlicht example (found in Irrlicht/examples/ ) and see if that works.


good luck :)

Posted: Sat Apr 22, 2006 10:10 am
by dr34mr
NEVER MIND!!! :lol: i got it. i'm so stupid i should shoot my self in the f*ckin' head before i hurt somebody. i didn't set up the project properly (the include directory, parameters)...
sory for bother.
damn i think i'll start knit instead of programmin :lol:

Posted: Sat Apr 29, 2006 5:17 am
by typhen
dreamer, can you please elaborate on the solution? I'm having what seems to be the same problem (i'm just starting to switch to gcc).

To build I invoke this:

gcc -I"c:/SDK/irrlicht-1.0/include" -L"c:/SDK/irrlicht-1.0/lib/Win32-gcc/" -l"Irrlicht" main.cpp

and it returns this:

D:\DOCUME~1\typhen\LOCALS~1\Temp/ccwxaaaa.o:main.cpp:(.text+0x84): undefined reference to `_imp___ZN3irr12createDeviceENS_5video13E_DRIVER_TYPEERKNS_4core11dimension2dIiEEjbbbPNS_14IEventReceiverEPKc'
collect2: ld returned 1 exit status

Posted: Sat Apr 29, 2006 7:12 am
by hybrid
Don't use qutoes around lib names. Only paths may have quotes. So use -lIrrlicht (this is a small L directly followed by Irrlicht).