Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef VIDEO_HPP_INCLUDED
00016 #define VIDEO_HPP_INCLUDED
00017
00018 #include "events.hpp"
00019 #include "exceptions.hpp"
00020 #include "lua_jailbreak_exception.hpp"
00021
00022 #include <boost/utility.hpp>
00023
00024 struct surface;
00025
00026
00027 #define FULL_SCREEN SDL_FULLSCREEN
00028 #define VIDEO_MEMORY SDL_HWSURFACE
00029 #define SYSTEM_MEMORY SDL_SWSURFACE
00030
00031 surface display_format_alpha(surface surf);
00032 surface get_video_surface();
00033 SDL_Rect screen_area();
00034
00035 bool non_interactive();
00036
00037
00038 void update_rect(size_t x, size_t y, size_t w, size_t h);
00039 void update_rect(const SDL_Rect& rect);
00040 void update_whole_screen();
00041
00042 class CVideo : private boost::noncopyable {
00043 public:
00044 enum FAKE_TYPES {
00045 NO_FAKE,
00046 FAKE,
00047 FAKE_TEST
00048 };
00049
00050 CVideo(FAKE_TYPES type = NO_FAKE);
00051 ~CVideo();
00052
00053
00054 int bppForMode( int x, int y, int flags);
00055 int modePossible( int x, int y, int bits_per_pixel, int flags, bool current_screen_optimal=false);
00056 int setMode( int x, int y, int bits_per_pixel, int flags );
00057
00058
00059 bool modeChanged();
00060
00061
00062 int getx() const;
00063 int gety() const;
00064
00065
00066 void blit_surface(int x, int y, surface surf, SDL_Rect* srcrect=NULL, SDL_Rect* clip_rect=NULL);
00067 void flip();
00068
00069 surface& getSurface();
00070
00071 bool isFullScreen() const;
00072
00073 struct error : public game::error
00074 {
00075 error() : game::error("Video initialization failed") {}
00076 };
00077
00078 class quit
00079 : public tlua_jailbreak_exception
00080 {
00081 public:
00082
00083 quit()
00084 : tlua_jailbreak_exception()
00085 {
00086 }
00087
00088 private:
00089
00090 IMPLEMENT_LUA_JAILBREAK_EXCEPTION(quit)
00091 };
00092
00093
00094 void setBpp( int bpp );
00095 int getBpp();
00096
00097 void make_fake();
00098
00099
00100
00101
00102
00103
00104
00105 void make_test_fake(const unsigned width = 1024,
00106 const unsigned height = 768, const unsigned bpp = 32);
00107 bool faked() const { return fake_screen_; }
00108
00109
00110
00111
00112 int set_help_string(const std::string& str);
00113 void clear_help_string(int handle);
00114 void clear_all_help_strings();
00115
00116
00117
00118
00119
00120
00121 void lock_updates(bool value);
00122 bool update_locked() const;
00123
00124 private:
00125
00126 void initSDL();
00127
00128 bool mode_changed_;
00129
00130 int bpp_;
00131
00132
00133 bool fake_screen_;
00134
00135
00136 int help_string_;
00137
00138 int updatesLocked_;
00139 };
00140
00141
00142 struct update_locker
00143 {
00144 update_locker(CVideo& v, bool lock=true) : video(v), unlock(lock) {
00145 if(lock) {
00146 video.lock_updates(true);
00147 }
00148 }
00149
00150 ~update_locker() {
00151 unlock_update();
00152 }
00153
00154 void unlock_update() {
00155 if(unlock) {
00156 video.lock_updates(false);
00157 unlock = false;
00158 }
00159 }
00160
00161 private:
00162 CVideo& video;
00163 bool unlock;
00164 };
00165
00166 class resize_monitor : public events::pump_monitor {
00167 void process(events::pump_info &info);
00168 };
00169
00170
00171
00172 struct resize_lock {
00173 resize_lock();
00174 ~resize_lock();
00175 };
00176
00177 #endif