Mercurial > fife-parpg
comparison engine/core/video/opengl/renderbackendopengl.cpp @ 642:6e2151325017
* Added the ability to query the current running screen mode
* Added a method to detect the closest supported screen mode (not complete yet). If no matching screen modes are detected an exception is thrown.
* Small change to the way the screen is initialized. The screen mode now MUST be in the supported screen mode list before the screen will initialize.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 08 Oct 2010 21:22:02 +0000 |
parents | 855ad500f991 |
children | 01acc9fc35ea |
comparison
equal
deleted
inserted
replaced
641:52708806f35c | 642:6e2151325017 |
---|---|
26 // 3rd party library includes | 26 // 3rd party library includes |
27 #include <SDL.h> | 27 #include <SDL.h> |
28 | 28 |
29 // FIFE includes | 29 // FIFE includes |
30 #include "util/base/exception.h" | 30 #include "util/base/exception.h" |
31 #include "util/log/logger.h" | |
32 #include "video/devicecaps.h" | |
31 | 33 |
32 #include "fife_opengl.h" | 34 #include "fife_opengl.h" |
33 #include "glimage.h" | 35 #include "glimage.h" |
34 #include "renderbackendopengl.h" | 36 #include "renderbackendopengl.h" |
35 #include "SDL_image.h" | 37 #include "SDL_image.h" |
36 | 38 |
37 namespace FIFE { | 39 namespace FIFE { |
40 static Logger _log(LM_VIDEO); | |
38 | 41 |
39 RenderBackendOpenGL::RenderBackendOpenGL(const SDL_Color& colorkey) : RenderBackend(colorkey) { | 42 RenderBackendOpenGL::RenderBackendOpenGL(const SDL_Color& colorkey) : RenderBackend(colorkey) { |
40 // Get the pixelformat we want. | 43 // Get the pixelformat we want. |
41 SDL_Surface* testsurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, 1, 1, 32, | 44 SDL_Surface* testsurface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, 1, 1, 32, |
42 RMASK, GMASK, BMASK ,AMASK); | 45 RMASK, GMASK, BMASK ,AMASK); |
70 void RenderBackendOpenGL::clearBackBuffer() { | 73 void RenderBackendOpenGL::clearBackBuffer() { |
71 GLDisable flag(GL_SCISSOR_TEST); | 74 GLDisable flag(GL_SCISSOR_TEST); |
72 glClear(GL_COLOR_BUFFER_BIT); | 75 glClear(GL_COLOR_BUFFER_BIT); |
73 } | 76 } |
74 | 77 |
75 Image* RenderBackendOpenGL::createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fs, const std::string& title, const std::string& icon) { | 78 Image* RenderBackendOpenGL::createMainScreen(const ScreenMode& mode, const std::string& title, const std::string& icon){ |
79 unsigned int width = mode.getWidth(); | |
80 unsigned int height = mode.getHeight(); | |
81 unsigned char bitsPerPixel = mode.getBPP(); | |
82 bool fs = mode.isFullScreen(); | |
83 Uint32 flags = mode.getSDLFlags(); | |
84 | |
76 delete m_screen; | 85 delete m_screen; |
77 m_screen = 0; | 86 m_screen = 0; |
78 | |
79 Uint32 flags = SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL; | |
80 if ( fs ) { | |
81 flags |= SDL_FULLSCREEN; | |
82 } | |
83 | 87 |
84 if(icon != "") { | 88 if(icon != "") { |
85 SDL_Surface *img = IMG_Load(icon.c_str()); | 89 SDL_Surface *img = IMG_Load(icon.c_str()); |
86 if(img != NULL) { | 90 if(img != NULL) { |
87 SDL_WM_SetIcon(img, 0); | 91 SDL_WM_SetIcon(img, 0); |
112 if ( !SDL_VideoModeOK(width, height, bitsPerPixel, flags) ) { | 116 if ( !SDL_VideoModeOK(width, height, bitsPerPixel, flags) ) { |
113 throw SDLException("Videomode not available"); | 117 throw SDLException("Videomode not available"); |
114 } | 118 } |
115 screen = SDL_SetVideoMode(width, height, bitsPerPixel, flags); | 119 screen = SDL_SetVideoMode(width, height, bitsPerPixel, flags); |
116 } | 120 } |
121 | |
122 FL_LOG(_log, LMsg("RenderBackendOpenGL") | |
123 << "Videomode " << width << "x" << height | |
124 << " at " << int(bitsPerPixel) << " bpp"); | |
117 | 125 |
118 SDL_WM_SetCaption(title.c_str(), 0); | 126 SDL_WM_SetCaption(title.c_str(), 0); |
119 | 127 |
120 if (!screen) { | 128 if (!screen) { |
121 throw SDLException(SDL_GetError()); | 129 throw SDLException(SDL_GetError()); |