00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "sdlmm_config.h"
00022
00023 #include <SDL.h>
00024 #include "sdlmm_global.h"
00025 #include "sdlmm_display.h"
00026
00027
00028
00029
00030 namespace SDLmm {
00031
00032
00033 Display& Display::GetDisplay()
00034 {
00035 static Display d;
00036
00037
00038 if(!d.me) d.me = SDL_GetVideoSurface();
00039 return d;
00040 }
00041
00042 void Display::UpdateRect(Sint32 x, Sint32 y, Sint32 w, Sint32 h) {
00043 SDL_UpdateRect(me, x, y, w, h);
00044 }
00045
00046 void Display::UpdateRect(SDL_Rect& rect) {
00047 SDL_UpdateRect(me, rect.x, rect.y, rect.w, rect.h);
00048 }
00049
00050 void Display::UpdateRects(int numrects, SDL_Rect *rects) {
00051 SDL_UpdateRects(me, numrects, rects);
00052 }
00053
00054 void Display::SetCaption(const char *title, const char *icon) {
00055 SDL_WM_SetCaption(title, icon);
00056 }
00057
00058 void Display::SetCaption(const std::string& title,
00059 const std::string& icon) {
00060 SDL_WM_SetCaption(title.c_str(), icon.c_str());
00061 }
00062
00063 void Display::GetCaption(char **title, char **icon) {
00064 SDL_WM_GetCaption(title, icon);
00065 }
00066
00067 void Display::GetCaption(std::string &title, std::string &icon) {
00068 char *_title, *_icon;
00069 SDL_WM_GetCaption(&_title, &_icon);
00070 title = _title;
00071 icon = _icon;
00072 }
00073
00074 void Display::SetIcon(BaseSurface& icon, Uint8 *mask) {
00075 SDL_WM_SetIcon(icon.GetSurface(), mask);
00076 }
00077
00078 bool Display::Iconify() {
00079 return SDL_WM_IconifyWindow() != 0;
00080 }
00081
00082 bool Display::ToggleFullScreen() {
00083 return SDL_WM_ToggleFullScreen(me) != 0;
00084 }
00085
00086 SDL_GrabMode Display::GrabInput(SDL_GrabMode mode) {
00087 return SDL_WM_GrabInput(mode);
00088 }
00089
00090 bool Display::SetVideoMode(int w, int h, int bpp, Uint32 flags) {
00091 SDL_Surface *tmp = SDL_SetVideoMode(w, h, bpp, flags);
00092 if(!tmp) return false;
00093 me = tmp;
00094 return true;
00095 }
00096
00097
00098 int Display::VideoModeOK(int w, int h, int bpp, Uint32 flags) {
00099 return SDL_VideoModeOK(w, h, bpp, flags);
00100 }
00101
00102 SDL_Rect **Display::ListModes(SDL_PixelFormat *format, Uint32 flags) {
00103 return SDL_ListModes(format, flags);
00104 }
00105
00106 bool Display::Init() {
00107 Uint32 wasinit = SDL_WasInit(SDL_INIT_EVERYTHING);
00108 bool init_success(true);
00109 if(!wasinit) {
00110 init_success = SDL_Init(SDL_INIT_VIDEO) == 0;
00111 } else if(!(wasinit & SDL_INIT_VIDEO)) {
00112 init_success = SDL_InitSubSystem(SDL_INIT_VIDEO) == 0;
00113 }
00114 return init_success;
00115 }
00116
00117 void Display::Quit() {
00118 if(SDL_WasInit(SDL_INIT_VIDEO)) {
00119 SDL_QuitSubSystem(SDL_INIT_VIDEO);
00120 }
00121 }
00122 }
00123
00124