Problem with multiple source and header files
-
- Posts: 12
- Joined: Mon Mar 20, 2006 11:10 pm
- Contact:
Problem with multiple source and header files
Hi,
So Im working on the terrain tutorial, and I am now expanding it into a game. So I broke the camera code into another .cpp file, and included a header that has all of my includes in it. The program compiles just fine, but when I run the program, I get an unhandled exception error.
Could someone please take a look at my code? Its probably something stupidly simple.
Thanks in advance!
Project and Source code (VS .NET 2005)
So Im working on the terrain tutorial, and I am now expanding it into a game. So I broke the camera code into another .cpp file, and included a header that has all of my includes in it. The program compiles just fine, but when I run the program, I get an unhandled exception error.
Could someone please take a look at my code? Its probably something stupidly simple.
Thanks in advance!
Project and Source code (VS .NET 2005)
you have committed a simple error here:
You call the function "addUserControlledCamera()", this function use *smgr, for do this:
smgr are definited in the header "include.h" but not allocated whit the code:
so, you have to write this:
Code: Select all
IrrlichtDevice* device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(800, 600), 32, false, true, false);
// disable mouse cursor
device->getCursorControl()->setVisible(false);
addUserControlledCamera();
Code: Select all
smgr->addCameraSceneNodeFPS()
Code: Select all
"smgr = device->getSceneManager()"
Code: Select all
IrrlichtDevice* device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(800, 600), 32, false, true, false);
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
// disable mouse cursor
device->getCursorControl()->setVisible(false);
addUserControlledCamera();
excuse me for my bad english and for my ignorance...but I'm 14 and i come from Italy, where the study of english is a optional (-:
-
- Posts: 12
- Joined: Mon Mar 20, 2006 11:10 pm
- Contact:
-
- Posts: 12
- Joined: Mon Mar 20, 2006 11:10 pm
- Contact:
In my own opinion, it would be best if you started over. Create a new project and start small, for example just create the irrlicht device and have it open a window. Get that working then add a little more, this will help in debugging the code as well.
system-independent, adj.:
Works equally poorly on all systems.
-- unknown
Works equally poorly on all systems.
-- unknown
-
- Posts: 12
- Joined: Mon Mar 20, 2006 11:10 pm
- Contact:
Ok, so I re-coded the program, this time just with A basic scene.
My main is as follows:
Does anyone know how to fix this problem?
Any help would be greatly appreciated, I'm really stuck!
-Thanks!
My main is as follows:
With the file "include.h" I declared this:#include "include.h"
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);
while (device->run())
{
driver->beginScene(true, true, SColor(0, 200, 200, 200));
smgr->drawAll();
env->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Then I have the code for the terrain, which I know isn't finished yet:#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
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.#include "include.h"
#include "defines.h"
scene::ITerrainSceneNode *terrain = smgr->addTerrainSceneNode(WorldHeight);
Does anyone know how to fix this problem?
Any help would be greatly appreciated, I'm really stuck!
-Thanks!
Pass the required pointers(smgr, etc) into the function that calls
I think this should achieve what your needing (access to the scenemanager).
Code: Select all
scene::ITerrainSceneNode *terrain = smgr->addTerrainSceneNode(WorldHeight);
system-independent, adj.:
Works equally poorly on all systems.
-- unknown
Works equally poorly on all systems.
-- unknown
-
- Posts: 12
- Joined: Mon Mar 20, 2006 11:10 pm
- Contact:
-
- Posts: 12
- Joined: Mon Mar 20, 2006 11:10 pm
- Contact:
-
- Posts: 12
- Joined: Mon Mar 20, 2006 11:10 pm
- Contact:
Well people has answered your question but since you don't know the basics of c++ language this info is useless for you.NextDesign wrote:This is the beginner forum. And as it says on the front page: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.
You should learn the very basics like writing functions with parameters, passing parameters around, pointers... all that stuff. Maybe a dedicated c/c++ forum will be better for your needs.