Problem with multiple source and header files

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.
cederron
Posts: 53
Joined: Thu Jul 13, 2006 11:35 pm

Post by cederron »

NextDesign wrote:Ok, so I re-coded the program, this time just with A basic scene.

My main is as follows:
#include "include.h"
#include include here your .h file where you have the code loading the terrain since you did not posted the name i dont know.

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

IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* env = device->getGUIEnvironment();

device->setWindowCaption(L"RPG - NextDesign");

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

smgr->addCameraSceneNodeFPS(0, 100.0f, 1200.0f);

LoadTerrain(smgr);

while (device->run())
{
driver->beginScene(true, true, SColor(0, 200, 200, 200));

smgr->drawAll();
env->drawAll();

driver->endScene();
}

device->drop();

return 0;
}
With the file "include.h" I declared this:
#ifndef INCLUDE_H
#define INCLUDE_H

#include < irrlicht.h >
#include < iostream >

using namespace irr;

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

#pragma comment (lib, "Irrlicht.lib")

#endif
Then I have the code for the terrain, which I know isn't finished yet:
#include "include.h"
#include "defines.h"

void LoadTerrain( ISceneManager *smgr )
{
scene::ITerrainSceneNode *terrain = smgr->addTerrainSceneNode(WorldHeight);
}
Now, the terrain file doesn't know what device, driver, smgr, and env are. But I can't move it over to "include.h" becuase the compiler complains about them already being defined.

Does anyone know how to fix this problem?

Any help would be greatly appreciated, I'm really stuck!

-Thanks!

Try this, but you can't expect people write the game for you! if you don't know the basics you will not be able to get any further.
NextDesign
Posts: 12
Joined: Mon Mar 20, 2006 11:10 pm
Contact:

Post by NextDesign »

Yes I know people won't make the game for me. I asked this question because I didn't know how to fix it.

Last question, In my header file what would I put in?

Code: Select all

void terrain(IrrlichtDevice *device, IVideoDriver *driver, ISceneManager *smgr);
?

Thanks.
Post Reply