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.
disanti
Posts: 367 Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:
Post
by disanti » Sun Jan 18, 2004 7:09 pm
Error:
C:\irrlicht\examples\Pong\text.cpp(23) : error C2065: 'device' : undeclared identifier
Code in text.cpp:
Code: Select all
void counter(int number, int x, int y, char directory[255])
{
video::ITexture* numbers = driver->getTexture(directory);
}
In main.cpp:
Code: Select all
//MAIN
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpInstance, LPSTR lpcmd, int nshowcmd)
{
//make the device
IrrlichtDevice *device =
createDevice(EDT_DIRECTX8, dimension2d<s32>(640, 480), 16, false, false, 0);
//set the window captions
device->setWindowCaption(L"Pong");
//make the drivers
ILogger* logger = device->getLogger();
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
etc...
How can I get the device and all that other junk into text.cpp so I can make a basic counter?
________
The Creativity Movement (Formerly Known As The World Church Of The Creator) Advi
Last edited by
disanti on Tue Feb 22, 2011 7:54 am, edited 1 time in total.
DarkVisions
Posts: 4 Joined: Sat Nov 15, 2003 12:40 pm
Post
by DarkVisions » Sun Jan 18, 2004 8:22 pm
You could either pass a pointer to the device into your counter function, or make the device a global variable.
Anthony (hammon)
disanti
Posts: 367 Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:
Post
by disanti » Sun Jan 18, 2004 9:20 pm
How??
I tried:
Code: Select all
//make the device
IrrlichtDevice *device;
//make the drivers
ILogger *logger;
IVideoDriver *driver;
ISceneManager *smgr;
IGUIEnvironment *guienv;
//MAIN
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpInstance, LPSTR lpcmd, int nshowcmd)
{
device = createDevice(EDT_DIRECTX8, dimension2d<s32>(resX, resY), depth, false, false, 0);
//set the window captions
device->setWindowCaption(L"CPU Pong");
//make the drivers
logger = device->getLogger();
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
Then in text.cpp:
Code: Select all
void counter(int number, int x, int y)
{
char curdir[255];
getCurrentDir(curdir);
video::ITexture* numbers = *driver->getTexture(strcat(curdir,"media\\numbers.bmp"));
}
Now it gives me this:
C:\irrlicht\examples\Pong\text.cpp(22) : error C2065: 'driver' : undeclared identifier
C:\irrlicht\examples\Pong\text.cpp(22) : error C2227: left of '->getTexture' must point to class/struct/union
I'm very new to pointers.
________
Motorcycle tires
Last edited by
disanti on Tue Feb 22, 2011 7:54 am, edited 1 time in total.
saigumi
Posts: 921 Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:
Post
by saigumi » Sun Jan 18, 2004 10:15 pm
count() doesn't exist in the same scope as your main()
You will need to pass the device pointer to count.
Code: Select all
void counter(IrrlichtDevice *device, int number, int x, int y)
{
char curdir[255];
getCurrentDir(curdir);
video::ITexture* numbers = device->getVideoDriver()->getTexture(strcat(curdir,"media\\numbers.bmp"));
}
Then call it via
If you were using classes, you could have something like myclass::count() and myclass::main().
You can find out more at:
http://www.google.com/search?hl=en&lr=& ... e+tutorial
Crud, how do I do this again?
disanti
Posts: 367 Joined: Sat Jan 17, 2004 1:36 am
Location: California, US
Contact:
Post
by disanti » Sun Jan 18, 2004 10:43 pm
Thanks!
Now it works!
________
MEXICO HOTELS
Last edited by
disanti on Tue Feb 22, 2011 7:55 am, edited 1 time in total.