Peculiar Problems Pertaining to Placement

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
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Peculiar Problems Pertaining to Placement

Post by Robomaniac »

I'm having weird problems. In a header file (defs.h) i have the device, driver, scene manager, and the gui environment defined as follows :

/////////////Irrlicht Definitions
IrrlichtDevice* device = 0;
video::IVideoDriver* driver = 0;
scene::ISceneManager* smgr = 0;
gui::IGUIEnvironment* guienv = 0;

The header is above anything except for the irrlicht, windows, stdio, and string headers.

Finally, in main, i define the three variables (device is declared in a header with a drawWindow function.)

driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();

I compile and i get errors such as :

conflicting types for `int driver'
previous declaration as `irr::video::IVideoDriver*driver'
invalid conversion from `irr::video::IVideoDriver*' to `int'
ISO C++ forbids declaration of `smgr' with no type
conflicting types for `int smgr'
etc
etc

I am using dev c++ and the current engine version.

edit : also, if i move the declarations into main (ex. video::IVideoDriver* driver = ...); I get a windows error that says. OpAlphaStorm.exe(my prog) has generated errors and will be closed by windows ( :evil: ).

Thanks in advance

~~ The Robomaniac
hearsedriver
Posts: 81
Joined: Fri Aug 22, 2003 12:06 pm
Location: Germany
Contact:

Post by hearsedriver »

Never place any definitions into a header file. This will result in multiple definitions, which is illegal, as soon as the header is included in more than one .cpp file. Define your variables in one .cpp file instead, and use the header to declare the variables as "extern" (e.g. "extern video::IVideoDriver* driver").

Cheers.
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

thanks, but errors are still there

~~The Robomaniac
hearsedriver
Posts: 81
Joined: Fri Aug 22, 2003 12:06 pm
Location: Germany
Contact:

Post by hearsedriver »

Take a close look at the error messages, they should give you some hints, e.g. "conflicting types for `int driver'" suggests that you might be using a variable with the name "driver" with different types (int and video::IVideoDriver*) in the same scope.

Cheers.
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

I'm getting more errors in all my other programs too. I debugged, and found that i'm getting access violation errors from windows. I'm using dev c++. When testing with the new (and improved v. 0.4 :shock: :shock: :shock: ), i'm using the collision tut. with file name modifications, but that's it. Thanks in advance.

~~ The Robomaniac

PS>> You ROCK Niko. Keep up the good work

PPS>> Debugging shows that i get the error at this line

scene::ITriangleSelector* selector = 0;

it's right before the if (q3node) block
hearsedriver
Posts: 81
Joined: Fri Aug 22, 2003 12:06 pm
Location: Germany
Contact:

Post by hearsedriver »

The line
scene::ITriangleSelector* selector = 0;
most likely will not result in an access violation, because it's a simple definition. Often, the editor highlights the line AFTER the line where the actual error occured, at least I experience this with Visual Studio every day. Examine the variables that you use in the scope where the debugger halts the program. Any nullpointers?
If you are using the collision example, check out whether the original binary compiled by Niko (e.g. /bin/VisualStudio for Windows) works for you. If so, your filenames might be wrong, or your input files damaged - does Irrlicht show any error messages in the console window? If Nikos binarys don't work either, you might just have spotted a bug in Irrlicht.

Cheers.
matthias gall, lead programmer at sechsta sinn - email matthias@sechsta-sinn.de
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Did what you said. The binaries run fine. Re-Debugged and debugger stopped at this line :

if (q3levelmesh)
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0));

Here is my code from main to there

MyEventReceiver receiver;

IrrlichtDevice *device =
createDevice(video::DT_OPENGL,
core::dimension2d<s32>(640, 480), 16, false, false, &receiver);

video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();


device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");


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

if (q3levelmesh)
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0));

I downloaded 0.4 and no errors show in the console of my compiled, but in the binary they show errors pertaining to sounds and textures in the level. Thanks for all your help.

~~ The robomaniac
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Hm, that's strange. I would say the engine is not able to find the file. But if you say there are no 'File not found' error messages in the console.. Are you sure the .pk3 file is in the same directory where your .exe is? (If you are using VisualStudio, it should be in the directory where your project files are.)
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

All the files were in the right folder. The problem just also started three days ago, which is weird. I'll play around w/ my windows settings and see if anything will work their. Thanks for all your help.

~~ The Robomanaic
guest

Post by guest »

use the old version of Dev
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

huh? The older version of dev c++

~~ The Robomaniac
Post Reply