# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1286398468 0 # Node ID f7863bfa92cd7c342e687e4bbc0bd6702e761620 # Parent 3094988564d584adf51b8dd2b6061b5c750548bf * Changed the way screen resolutions are detected * Added the ability to query the video driver name diff -r 3094988564d5 -r f7863bfa92cd engine/core/video/devicecaps.cpp --- a/engine/core/video/devicecaps.cpp Wed Oct 06 19:19:08 2010 +0000 +++ b/engine/core/video/devicecaps.cpp Wed Oct 06 20:54:28 2010 +0000 @@ -57,10 +57,13 @@ } void DeviceCaps::fillDeviceCaps() { + int bufferSize = 256; + char buffer[bufferSize]; + int numBPP = 1; int bpps[numBPP]; - int numResolutions = 15; + SDL_Rect **modes; //FLAGS #ifdef HAVE_OPENGL @@ -88,41 +91,34 @@ bpps[0] = 32; + for (int i = 0; i < numBPP; ++i){ + for (int j = 0; j < numFlags; ++j) { + modes = SDL_ListModes(NULL, flags[j]); - //RESOLUTIONS - int resolutions[15][2] = { - {640, 480}, - {800, 600}, - {1024, 768}, - {1152, 864}, - {1280, 768}, - {1280, 800}, - {1280, 960}, - {1280, 1024}, - {1366, 768}, - {1440, 900}, - {1600, 900}, - {1600, 1200}, - {1680, 1050}, - {1920, 1080}, - {1920, 1200} - }; + if (modes == (SDL_Rect**)-1) { + //All screen modes are available with the specified flags (a windowed mode most likely) + ScreenMode mode = ScreenMode(0, 0, bpps[i], flags[j]); + m_screenModes.push_back(mode); + continue; + } - int bpp; - - for (int i = 0; i < numBPP; i++){ - for (int j = 0; j < numFlags; j++) { - for (int k = 0; k < numResolutions; k++) { - bpp = SDL_VideoModeOK(resolutions[k][0], resolutions[k][1], bpps[i], flags[j]); + for (int k = 0; modes[k]; ++k) { + int bpp = SDL_VideoModeOK(modes[k]->w, modes[k]->h, bpps[i], flags[j]); if (bpp > 0) { -// std::cout << resolutions[k][0] << "x" << resolutions[k][1] << ":" << bpp << std::endl; - ScreenMode mode = ScreenMode(resolutions[k][0], resolutions[k][1], bpps[i], flags[j]); + ScreenMode mode = ScreenMode(modes[k]->w, modes[k]->h, bpps[i], flags[j]); m_screenModes.push_back(mode); } } } } + if(SDL_VideoDriverName(buffer, bufferSize) != NULL) { + m_driverName = std::string(buffer); + } + else { + m_driverName = "Unknown"; + } + } } //FIFE diff -r 3094988564d5 -r f7863bfa92cd engine/core/video/devicecaps.h --- a/engine/core/video/devicecaps.h Wed Oct 06 19:19:08 2010 +0000 +++ b/engine/core/video/devicecaps.h Wed Oct 06 20:54:28 2010 +0000 @@ -40,7 +40,9 @@ class ScreenMode { public: - /** Constructors. + /** Default Constructor + * @note You shouldn't construct these objects yourself. This default + * constructor was provided because swig complained that was none. */ ScreenMode(); ScreenMode(uint16_t width, uint16_t height, uint16_t bpp, uint32_t SDLFlags); @@ -51,14 +53,18 @@ ~ScreenMode() {}; /** Returns the width of the screen mode. + * @note If both width and height are 0 it means that ALL modes are available + * for use with the specified flags. Most likely this is a windowed mode. */ uint16_t getWidth() const { return m_width; }; /** Returns the height of the screen mode. + * @note If both width and height are 0 it means that ALL modes are available + * for use with the specified flags. Most likely this is a windowed mode. */ uint16_t getHeight() const { return m_height; }; - /** Returns the number of bits per pixel this mode supports. + /** Returns the number of bits per pixel this mode uses. */ uint16_t getBPP() const { return m_bpp; }; @@ -66,7 +72,7 @@ */ uint32_t getSDLFlags() const { return m_SDLFlags; }; - /** True if this is a fullscreen mode. Fals if it is a windowed mode. + /** True if this is a fullscreen mode. False if it is a windowed mode. */ bool isFullScreen() const { return (m_SDLFlags & SDL_FULLSCREEN) ? true : false;}; @@ -93,10 +99,12 @@ ~DeviceCaps(); void fillDeviceCaps(); - std::vector getSupportedScreenModes() const {return m_screenModes;} ; + std::vector getSupportedScreenModes() const { return m_screenModes; }; + std::string getDriverName() const { return m_driverName; }; private: std::vector m_screenModes; + std::string m_driverName; }; //DeviceCaps } diff -r 3094988564d5 -r f7863bfa92cd engine/core/video/video.i --- a/engine/core/video/video.i Wed Oct 06 19:19:08 2010 +0000 +++ b/engine/core/video/video.i Wed Oct 06 20:54:28 2010 +0000 @@ -231,9 +231,6 @@ class ScreenMode { public: - ScreenMode(); - ScreenMode(uint16_t width, uint16_t height, uint16_t bpp, uint32_t SDLFlags); - ScreenMode(const ScreenMode& rhs); ~ScreenMode(); uint16_t getWidth() const; @@ -251,5 +248,6 @@ void fillDeviceCaps(); std::vector getSupportedScreenModes() const; + std::string getDriverName() const; }; }