UGDK
|
00001 #ifndef UGDK_GRAPHIC_VIDEOMANAGER_H_ 00002 #define UGDK_GRAPHIC_VIDEOMANAGER_H_ 00003 00004 #include <string> 00005 #include <map> 00006 #include <list> 00007 #include <stack> 00008 #include <ugdk/base/types.h> 00009 #include <ugdk/math/vector2D.h> 00010 #include <ugdk/math/frame.h> 00011 #include <ugdk/action.h> 00012 #include <ugdk/graphic.h> 00013 #include <ugdk/graphic/modifier.h> 00014 00015 using std::string; 00016 using std::map; 00017 00018 #define VIDEO_MANAGER() (ugdk::Engine::reference()->video_manager()) 00019 00020 namespace ugdk { 00021 namespace graphic { 00022 00023 class VideoManager { 00024 public: 00025 static const int COLOR_DEPTH = 32; 00026 00027 VideoManager() : settings_(false, false, false), light_buffer_(NULL), light_texture_(NULL) {} 00028 ~VideoManager() {} 00029 00030 bool Initialize(const std::string& title, const Vector2D& size, bool fullscreen, const std::string& icon); 00031 bool Release(); 00032 void Render(const std::list<action::Scene*>&); 00033 00034 // Configuration 00035 bool ChangeResolution(const Vector2D& size, bool fullscreen); 00036 void SetVSync(const bool active); 00037 void SetLightSystem(const bool active) { settings_.light_system = active; } 00038 00039 // Getters 00040 Vector2D video_size() const { return video_size_; } 00041 bool fullscreen() const { return settings_.fullscreen; } 00042 const std::string& title() const { return title_; } 00043 const Texture* light_texture() const { return light_texture_; } 00044 Frame virtual_bounds() const { return virtual_bounds_; } 00045 00046 // Modifier stack 00047 void PushAndApplyModifier(const Modifier*); 00048 void PushAndApplyModifier(const Modifier& apply) { PushAndApplyModifier(&apply); } 00049 bool PopModifier(); 00050 const Modifier& CurrentModifier() const; 00051 00052 private: 00053 Vector2D video_size_; 00054 Frame virtual_bounds_; 00055 std::string title_; 00056 00057 struct Settings { 00058 bool fullscreen; 00059 bool vsync; 00060 bool light_system; 00061 00062 Settings(bool fs, bool vs, bool light) : fullscreen(fs), vsync(vs), light_system(light) {} 00063 } settings_; 00064 00065 std::stack<Modifier> modifiers_; 00066 00067 Texture* light_buffer_; 00068 Texture* light_texture_; 00069 00070 void InitializeLight(); 00071 00072 void mergeLights(const std::list<action::Scene*>& scene_list); 00073 void BlendLightIntoBuffer(); 00074 00075 void ClearModiferStack(); 00076 00077 }; 00078 00079 } // namespace graphic 00080 } // namespace ugdk 00081 00082 #endif