Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Mini-framework AppState rendering problem  (Read 1382 times)

0 Members and 1 Guest are viewing this topic.

pighead10

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
    • Hog Pog
Mini-framework AppState rendering problem
« on: January 09, 2012, 08:07:53 pm »
I made a mini framework for sfml, based off a framework for a 3d rendering engine I have used. It uses "AppStates", which the program is constantly in one - for example, MenuState, GameState. These render a screen whenever one is entered.

In the rendering engine I used this came from, there were SceneManagers to organize the scenes and hold the data rendered in that SceneManager, including a camera which the 'viewport' would be set to. I am new to sfml and not familiar with the various features - is there anything like a SceneManager I could use to achieve the same affect, or would I have to create my own? (I'm assuming 'views' in SFML can be used to the same affect as the viewports - I haven't looked through that part much, please correct me if I am wrong).

Thanks in advance!
Immortui - Zombie puzzle game: http://immortui.hogpog.co.uk

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Mini-framework AppState rendering problem
« Reply #1 on: January 12, 2012, 05:39:05 pm »
Pretty sure you have to make your own..
But, atleast in XNA world, it was pretty easy..

Something like this, pseudo code.
Code: [Select]

class GameState
{
public:
virtual Update();
virtual Draw();
virtual Start();
virtual End();
};

class GameStateManager
{
public:
std::stack<GameState*> m_GameStatss;
void pushState(GameState* gs) { m_GameStates.push_back(gs); gs->Start(); }
void popState() { m_GameStates.last()->End(); m_GameStates.pop_back(); }
GameState* getCurrentState() { return m_GameStates.peek(); }
}

int main()
{
while(mainLoop)
{
 GameStateManager.getCurrentState()->Draw();
 GameStateManager.getCurrentState()->Update();
}


Then you could implent like "bool blockDrawing", "bool blockUpdate" so that if theMenuState is pushed over theGameState you can still update, but not draw, the theGameState in the background(Like multiplayer games).

 

anything