video.hpp

Go to the documentation of this file.
00001 /* $Id: video.hpp 23842 2008-02-16 08:47:16Z mordante $ */
00002 /*
00003    Copyright (C) 2003 - 2008 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 #ifndef VIDEO_HPP_INCLUDED
00015 #define VIDEO_HPP_INCLUDED
00016 
00017 #include "events.hpp"
00018 #include "SDL.h"
00019 #include "sdl_utils.hpp"
00020 
00021 //possible flags when setting video modes
00022 #define FULL_SCREEN SDL_FULLSCREEN
00023 #define VIDEO_MEMORY SDL_HWSURFACE
00024 #define SYSTEM_MEMORY SDL_SWSURFACE
00025 
00026 surface display_format_alpha(surface surf);
00027 surface get_video_surface();
00028 SDL_Rect screen_area();
00029 
00030 bool non_interactive();
00031 
00032 //which areas of the screen will be updated when the buffer is flipped?
00033 void update_rect(size_t x, size_t y, size_t w, size_t h);
00034 void update_rect(const SDL_Rect& rect);
00035 void update_whole_screen();
00036 
00037 class CVideo {
00038      public:
00039     CVideo();
00040     CVideo(int x, int y, int bits_per_pixel, int flags);
00041     ~CVideo();
00042 
00043     int modePossible( int x, int y, int bits_per_pixel, int flags );
00044     int setMode( int x, int y, int bits_per_pixel, int flags );
00045 
00046     //did the mode change, since the last call to the modeChanged() method?
00047     bool modeChanged();
00048 
00049     int setGamma(float gamma);
00050 
00051     //functions to get the dimensions of the current video-mode
00052     int getx() const;
00053     int gety() const;
00054     int getBitsPerPixel();
00055     int getBytesPerPixel();
00056     int getRedMask();
00057     int getGreenMask();
00058     int getBlueMask();
00059 
00060     //functions to access the screen
00061     void lock();
00062     void unlock();
00063     int mustLock();
00064 
00065     //blits a surface with black as alpha
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( void );
00070 
00071     bool isFullScreen() const;
00072 
00073     struct error {};
00074 
00075     struct quit {};
00076 
00077     //functions to allow changing video modes when 16BPP is emulated
00078     void setBpp( int bpp );
00079     int getBpp();
00080 
00081     void make_fake();
00082     bool faked() const { return fake_screen; }
00083 
00084     //functions to set and clear 'help strings'. A 'help string' is like a tooltip, but it appears
00085     //at the bottom of the screen, so as to not be intrusive. Setting a help string sets what
00086     //is currently displayed there.
00087     int set_help_string(const std::string& str);
00088     void clear_help_string(int handle);
00089     void clear_all_help_strings();
00090 
00091     //function to stop the screen being redrawn. Anything that happens while
00092     //the update is locked will be hidden from the user's view.
00093     //note that this function is re-entrant, meaning that if lock_updates(true)
00094     //is called twice, lock_updates(false) must be called twice to unlock
00095     //updates.
00096     void lock_updates(bool value);
00097     bool update_locked() const;
00098 
00099 private:
00100 
00101     bool mode_changed_;
00102 
00103     int bpp;    // Store real bits per pixel
00104 
00105     //if there is no display at all, but we 'fake' it for clients
00106     bool fake_screen;
00107 
00108     //variables for help strings
00109     int help_string_;
00110 
00111     int updatesLocked_;
00112 };
00113 
00114 //an object which will lock the display for the duration of its lifetime.
00115 struct update_locker
00116 {
00117     update_locker(CVideo& v, bool lock=true) : video(v), unlock(lock) {
00118         if(lock) {
00119             video.lock_updates(true);
00120         }
00121     }
00122 
00123     ~update_locker() {
00124         unlock_update();
00125     }
00126 
00127     void unlock_update() {
00128         if(unlock) {
00129             video.lock_updates(false);
00130             unlock = false;
00131         }
00132     }
00133 
00134 private:
00135     CVideo& video;
00136     bool unlock;
00137 };
00138 
00139 class resize_monitor : public events::pump_monitor {
00140     void process(events::pump_info &info);
00141 };
00142 
00143 //an object which prevents resizing of the screen occuring during
00144 //its lifetime.
00145 struct resize_lock {
00146     resize_lock();
00147     ~resize_lock();
00148 };
00149 
00150 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs