PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

GetDisplay()

i've just moved from PF 0.7 to PF 0.8 and noticed that result of GetDisplay() now changes after each update. That's bad, because of this my entire resource manager now totaly screwed and i have no idea how to make another :(
Can it be fixed, or can i anyhow call GetDisplay() outside Game class?
Maybe I don't understand your resource manager, but why can't you pass a pointer to the display in your functions?
It's easy - just make it global
Code:

in Globals.h //include in any cpp of your project
extern Display * pDisplay;
extern Menu Mnu;//Not a game class using Display

//in Globals.cpp
Display * pDisplay;
Menu Mnu;

//in Menu.cpp:
void Menu::Draw()
{
pDisplay->DrawSomething();
}

//It's just my game class loop
void Pyromania::GameLoop()
{
pDisplay = GetDisplay();
Mnu.Draw();//Without passing a Display pointer
pDisplay->Update();
}


Use gobals in games - it is not so safety but much faster.