comparison engine/core/video/sdl/renderbackendsdl.cpp @ 61:18c2a21ac0ad

allow clients to set a custom window title and icon
author spq@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 16 Jul 2008 12:37:41 +0000
parents 90005975cdbb
children ad7969d9460b
comparison
equal deleted inserted replaced
60:1de7e6740a4a 61:18c2a21ac0ad
32 #include "util/math/fife_math.h" 32 #include "util/math/fife_math.h"
33 #include "util/log/logger.h" 33 #include "util/log/logger.h"
34 34
35 #include "renderbackendsdl.h" 35 #include "renderbackendsdl.h"
36 #include "sdlimage.h" 36 #include "sdlimage.h"
37 #include "SDL_image.h"
37 38
38 namespace FIFE { 39 namespace FIFE {
39 static Logger _log(LM_VIDEO); 40 static Logger _log(LM_VIDEO);
40 41
41 RenderBackendSDL::RenderBackendSDL() : RenderBackend() { 42 RenderBackendSDL::RenderBackendSDL() : RenderBackend() {
56 throw SDLException(SDL_GetError()); 57 throw SDLException(SDL_GetError());
57 58
58 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); // temporary hack 59 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); // temporary hack
59 } 60 }
60 61
61 Image* RenderBackendSDL::createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fs) { 62 Image* RenderBackendSDL::createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fs, const std::string& title, const std::string& icon) {
62 Uint32 flags = 0; 63 Uint32 flags = 0;
63 if (fs) { 64 if (fs) {
64 flags |= SDL_FULLSCREEN; 65 flags |= SDL_FULLSCREEN;
66 }
67
68 if(icon != "") {
69 SDL_Surface *img = IMG_Load(icon.c_str());
70 if(img != NULL) {
71 SDL_WM_SetIcon(img, 0);
72 }
65 } 73 }
66 74
67 SDL_Surface* screen = NULL; 75 SDL_Surface* screen = NULL;
68 76
69 if( 0 == bitsPerPixel ) { 77 if( 0 == bitsPerPixel ) {
98 } 106 }
99 FL_LOG(_log, LMsg("RenderBackendSDL") 107 FL_LOG(_log, LMsg("RenderBackendSDL")
100 << "Videomode " << width << "x" << height 108 << "Videomode " << width << "x" << height
101 << " at " << int(screen->format->BitsPerPixel) << " bpp"); 109 << " at " << int(screen->format->BitsPerPixel) << " bpp");
102 110
103 SDL_WM_SetCaption("FIFE", NULL); 111 SDL_WM_SetCaption(title.c_str(), NULL);
104 112
105 if (!screen) { 113 if (!screen) {
106 throw SDLException(SDL_GetError()); 114 throw SDLException(SDL_GetError());
107 } 115 }
108 116