diff --git a/source/shared_lib/sources/platform/sdl/platform_util.cpp b/source/shared_lib/sources/platform/sdl/platform_util.cpp index 822288996..6fca10b98 100644 --- a/source/shared_lib/sources/platform/sdl/platform_util.cpp +++ b/source/shared_lib/sources/platform/sdl/platform_util.cpp @@ -28,6 +28,7 @@ #include "socket.h" #include #include +#include using namespace Shared::Util; using namespace std; @@ -536,37 +537,76 @@ void getFullscreenVideoModes(list *modeinfos) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - /* Get available fullscreen/hardware modes */ - SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_RESIZABLE); + SDL_PixelFormat format; + SDL_Rect **modes; + int loops(0); + int bpp(0); + std::map uniqueResList; - /* Check if there are any modes available */ - if (modes == (SDL_Rect**)0) { - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] no hardware modes available.\n",__FILE__,__FUNCTION__,__LINE__); + do + { + //format.BitsPerPixel seems to get zeroed out on my windows box + switch(loops) + { + case 0://32 bpp + format.BitsPerPixel = 32; + bpp = 32; + break; + case 1://24 bpp + format.BitsPerPixel = 24; + bpp = 24; + break; + case 2://16 bpp + format.BitsPerPixel = 16; + bpp = 16; + break; + } - const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo(); - modeinfos->push_back(ModeInfo(vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel)); - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h); - } - /* Check if our resolution is restricted */ - else if (modes == (SDL_Rect**)-1) { - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] all resolutions available.\n",__FILE__,__FUNCTION__,__LINE__); + /* Get available fullscreen/hardware modes */ + //SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_RESIZABLE); + SDL_Rect**modes = SDL_ListModes(&format, SDL_FULLSCREEN); - const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo(); - modeinfos->push_back(ModeInfo(vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel)); - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h); - } - else{ - /* Print valid modes */ - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] available Modes are:\n",__FILE__,__FUNCTION__,__LINE__); + /* Check if there are any modes available */ + if (modes == (SDL_Rect**)0) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] no hardware modes available.\n",__FILE__,__FUNCTION__,__LINE__); - int bestW = -1; - int bestH = -1; - for(int i=0; modes[i]; ++i) { - SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h,modes[i]->x); - modeinfos->push_back(ModeInfo(modes[i]->w,modes[i]->h,modes[i]->x)); - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,modes[i]->w,modes[i]->h); - } - } + const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo(); + string lookupKey = intToStr(vidInfo->current_w) + "_" + intToStr(vidInfo->current_h) + "_" + intToStr(vidInfo->vfmt->BitsPerPixel); + if(uniqueResList.find(lookupKey) == uniqueResList.end()) { + uniqueResList[lookupKey] = true; + modeinfos->push_back(ModeInfo(vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel)); + } + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h); + } + /* Check if our resolution is restricted */ + else if (modes == (SDL_Rect**)-1) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] all resolutions available.\n",__FILE__,__FUNCTION__,__LINE__); + + const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo(); + string lookupKey = intToStr(vidInfo->current_w) + "_" + intToStr(vidInfo->current_h) + "_" + intToStr(vidInfo->vfmt->BitsPerPixel); + if(uniqueResList.find(lookupKey) == uniqueResList.end()) { + uniqueResList[lookupKey] = true; + modeinfos->push_back(ModeInfo(vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel)); + } + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h); + } + else{ + /* Print valid modes */ + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] available Modes are:\n",__FILE__,__FUNCTION__,__LINE__); + + int bestW = -1; + int bestH = -1; + for(int i=0; modes[i]; ++i) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h,modes[i]->x); + string lookupKey = intToStr(modes[i]->w) + "_" + intToStr(modes[i]->h) + "_" + intToStr(modes[i]->x); + if(uniqueResList.find(lookupKey) == uniqueResList.end()) { + uniqueResList[lookupKey] = true; + modeinfos->push_back(ModeInfo(modes[i]->w,modes[i]->h,modes[i]->x)); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,modes[i]->w,modes[i]->h); + } + } + } + } while(++loops != 3); }