comparison engine/core/video/opengl/renderbackendopengl.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 129d3dafd3a5
children 66db8ce5dfa2
comparison
equal deleted inserted replaced
60:1de7e6740a4a 61:18c2a21ac0ad
30 #include "util/base/exception.h" 30 #include "util/base/exception.h"
31 31
32 #include "fife_opengl.h" 32 #include "fife_opengl.h"
33 #include "glimage.h" 33 #include "glimage.h"
34 #include "renderbackendopengl.h" 34 #include "renderbackendopengl.h"
35 #include "SDL_image.h"
35 36
36 namespace FIFE { 37 namespace FIFE {
37 38
38 RenderBackendOpenGL::RenderBackendOpenGL() : RenderBackend() { 39 RenderBackendOpenGL::RenderBackendOpenGL() : RenderBackend() {
39 // Get the pixelformat we want. 40 // Get the pixelformat we want.
60 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); 61 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
61 62
62 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); // temporary hack 63 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); // temporary hack
63 } 64 }
64 65
65 Image* RenderBackendOpenGL::createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fs) { 66 Image* RenderBackendOpenGL::createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fs, const std::string& title, const std::string& icon) {
66 delete m_screen; 67 delete m_screen;
67 m_screen = 0; 68 m_screen = 0;
68 69
69 Uint32 flags = SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL; 70 Uint32 flags = SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL;
70 if ( fs ) { 71 if ( fs ) {
71 flags |= SDL_FULLSCREEN; 72 flags |= SDL_FULLSCREEN;
73 }
74
75 if(icon != "") {
76 SDL_Surface *img = IMG_Load(icon.c_str());
77 if(img != NULL) {
78 SDL_WM_SetIcon(img, 0);
79 }
72 } 80 }
73 81
74 SDL_Surface* screen = NULL; 82 SDL_Surface* screen = NULL;
75 83
76 if( 0 == bitsPerPixel ) { 84 if( 0 == bitsPerPixel ) {
96 throw SDLException("Videomode not available"); 104 throw SDLException("Videomode not available");
97 } 105 }
98 screen = SDL_SetVideoMode(width, height, bitsPerPixel, flags); 106 screen = SDL_SetVideoMode(width, height, bitsPerPixel, flags);
99 } 107 }
100 108
101 SDL_WM_SetCaption("FIFE", 0); 109 SDL_WM_SetCaption(title.c_str(), 0);
102 110
103 if (!screen) { 111 if (!screen) {
104 throw SDLException(SDL_GetError()); 112 throw SDLException(SDL_GetError());
105 } 113 }
106 114