Neo  0.5.0
Developer Documentation
NeoGame.h
Go to the documentation of this file.
1 //========================================================================
2 // Copyright (c) 2003-2011 Anael Seghezzi <www.maratis3d.com>
3 // Copyright (c) 20014-2015 Yannick Pflanzer <www.neo-engine.de>
4 //
5 // This software is provided 'as-is', without any express or implied
6 // warranty. In no event will the authors be held liable for any damages
7 // arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it
11 // freely, subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented; you must not
14 // claim that you wrote the original software. If you use this software
15 // in a product, an acknowledgment in the product documentation would
16 // be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such, and must not
19 // be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source
22 // distribution.
23 //
24 //========================================================================
25 
26 
27 #ifndef _NEO_GAME_H
28 #define _NEO_GAME_H
29 
30 namespace Neo
31 {
32 
39 class NEO_ENGINE_EXPORT SubGame
40 {
41 public:
42  virtual void update(void) = 0;
43  virtual void draw(void) = 0;
44 
45  virtual void onBegin(void) = 0;
46  virtual void onEnd(void) = 0;
47 };
48 
49 class NEO_ENGINE_EXPORT NeoGame
50 {
51 private:
52 
53  long int m_lastFrame;
54  float m_frameDelta;
55  bool m_isRunning;
56 
57  bool m_postEffectsEnabled;
58  PostProcessor m_postProcessor;
59 
60  std::vector<SubGame*> m_subGames;
61 
62 public:
63 
64  NeoGame(void);
65  virtual ~NeoGame(void);
66 
67 public:
68 
69  inline float getFrameDelta() { return m_frameDelta; }
70 
71  // is running
72  inline bool isRunning(void){ return m_isRunning; }
73 
74  // post effects
75  inline bool hasPostEffects(void){ return m_postEffectsEnabled; }
76  inline void enablePostEffects() { m_postEffectsEnabled = true; }
77  inline void disablePostEffects() { m_postEffectsEnabled = false; }
78 
79  inline PostProcessor* getPostProcessor() { return &m_postProcessor; }
80 
81  // begin / end
82  void begin(void) { onBegin(); onBeginLevel(); onBeginScene(); m_isRunning = true; }
83  void end(void) { onEndScene(); onEndLevel(); onEnd(); m_isRunning = false; }
84 
85  // events
86  virtual void update(void);
87  virtual void draw(void);
88 
92  virtual void onBegin(void);
93 
97  virtual void onEnd(void);
98 
99  virtual void onBeginLevel(void) { }
100  virtual void onEndLevel(void){}
101 
102  virtual void onBeginScene(void);
103  virtual void onEndScene(void);
104 
112  {
113  if(g)
114  m_subGames.push_back(g);
115  }
116 };
117 }
118 #endif
void registerSubGame(SubGame *g)
Adds a SubGame to the list of registered games.
Definition: NeoGame.h:111
float getFrameDelta()
Definition: NeoGame.h:69
virtual void onBeginLevel(void)
Definition: NeoGame.h:99
Definition: NeoGame.h:49
virtual void onEndLevel(void)
Definition: NeoGame.h:100
void enablePostEffects()
Definition: NeoGame.h:76
PostProcessor * getPostProcessor()
Definition: NeoGame.h:79
bool isRunning(void)
Definition: NeoGame.h:72
void begin(void)
Definition: NeoGame.h:82
Definition: NeoGame.h:39
void disablePostEffects()
Definition: NeoGame.h:77
bool hasPostEffects(void)
Definition: NeoGame.h:75
The MPostProcessor class contains functionality used to render the current scene to a texture to allo...
Definition: PostProcessor.h:33
void end(void)
Definition: NeoGame.h:83
Definition: Color.h:29