i'm completely newbie both to programming and Irrlicht, so maybe this is a stupid and simple C++ related question
i'm trying to make a little game with the main file ".cpp" and a header files ".h", to make it more readable. however, i'm having a little problem.
so far, what i did...
File main.cpp
Code: Select all
#include "title.h"
int main(){
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(800, 600), 16, false, false, false, 0);
if (!device){
return 1;
}
device->setWindowCaption(L"Test Game");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
Title();
}
Code: Select all
#ifndef TITLE_H_INCLUDED
#define TITLE_H_INCLUDED
#include <Irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int Title(){
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
return 0;
}
#endif // TITLE_H_INCLUDED
as you can see, the main.cpp starts the basics of the engine, and then makes a call to the function Title, from title.h.
the error i get says that smgr, guienv, and driver "is not declared on this scope". well, i know that, as it's declared only on funcion main. as i can't declare it as global (or can i?) do i have do create these pointers in every function that will make use of Irrlicht??
thanks in advance