UGDK  0.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
videomanager.h
Go to the documentation of this file.
1 #ifndef UGDK_GRAPHIC_VIDEOMANAGER_H_
2 #define UGDK_GRAPHIC_VIDEOMANAGER_H_
3 
4 #include <string>
5 #include <map>
6 #include <list>
7 #include <stack>
8 #include <ugdk/base/types.h>
9 #include <ugdk/math/vector2D.h>
10 #include <ugdk/math/frame.h>
11 #include <ugdk/action.h>
12 #include <ugdk/graphic.h>
13 #include <ugdk/graphic/modifier.h>
14 
15 using std::string;
16 using std::map;
17 
18 #define VIDEO_MANAGER() (ugdk::Engine::reference()->video_manager())
19 
20 namespace ugdk {
21 namespace graphic {
22 
23 class VideoManager {
24  public:
25  static const int COLOR_DEPTH = 32;
26 
27  VideoManager() : settings_(false, false, false), light_buffer_(NULL), light_texture_(NULL) {}
29 
30  bool Initialize(const std::string& title, const Vector2D& size, bool fullscreen, const std::string& icon);
31  bool Release();
32  void Render(const std::list<action::Scene*>&);
33 
34  // Configuration
35  bool ChangeResolution(const Vector2D& size, bool fullscreen);
36  void SetVSync(const bool active);
37  void SetLightSystem(const bool active) { settings_.light_system = active; }
38 
39  // Getters
40  Vector2D video_size() const { return video_size_; }
41  bool fullscreen() const { return settings_.fullscreen; }
42  const std::string& title() const { return title_; }
43  const Texture* light_texture() const { return light_texture_; }
44  Frame virtual_bounds() const { return virtual_bounds_; }
45 
46  // Modifier stack
47  void PushAndApplyModifier(const Modifier*);
48  void PushAndApplyModifier(const Modifier& apply) { PushAndApplyModifier(&apply); }
49  bool PopModifier();
50  const Modifier& CurrentModifier() const;
51 
52  private:
53  Vector2D video_size_;
54  Frame virtual_bounds_;
55  std::string title_;
56 
57  struct Settings {
58  bool fullscreen;
59  bool vsync;
60  bool light_system;
61 
62  Settings(bool fs, bool vs, bool light) : fullscreen(fs), vsync(vs), light_system(light) {}
63  } settings_;
64 
65  std::stack<Modifier> modifiers_;
66 
67  Texture* light_buffer_;
68  Texture* light_texture_;
69 
70  void InitializeLight();
71 
72  void mergeLights(const std::list<action::Scene*>& scene_list);
73  void BlendLightIntoBuffer();
74 
75  void ClearModiferStack();
76 
77 };
78 
79 } // namespace graphic
80 } // namespace ugdk
81 
82 #endif