Index: ps/trunk/source/lib/sysdep/gfx.h =================================================================== --- ps/trunk/source/lib/sysdep/gfx.h +++ ps/trunk/source/lib/sysdep/gfx.h @@ -41,16 +41,6 @@ **/ LIB_API std::wstring DriverInfo(); -/** - * (useful for choosing a new video mode) - * - * @param xres, yres (optional out) resolution [pixels] - * @param bpp (optional out) bits per pixel - * @param freq (optional out) vertical refresh rate [Hz] - * @return Status (if negative, outputs were left unchanged) - **/ -LIB_API Status GetVideoMode(int* xres, int* yres, int* bpp, int* freq); - } // namespace gfx #endif // #ifndef INCLUDED_GFX Index: ps/trunk/source/lib/sysdep/os/osx/osx.cpp =================================================================== --- ps/trunk/source/lib/sysdep/os/osx/osx.cpp +++ ps/trunk/source/lib/sysdep/os/osx/osx.cpp @@ -37,75 +37,6 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" -namespace gfx { - -Status GetVideoMode(int* xres, int* yres, int* bpp, int* freq) -{ - if(xres) - *xres = (int)CGDisplayPixelsWide(kCGDirectMainDisplay); - - if(yres) - *yres = (int)CGDisplayPixelsHigh(kCGDirectMainDisplay); - - if(bpp) - { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 - // CGDisplayBitsPerPixel was deprecated in OS X 10.6 - if (CGDisplayCopyDisplayMode != NULL) - { - CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay); - CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding(currentMode); - if (CFStringCompare(pixelEncoding, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) - *bpp = 32; - else if (CFStringCompare(pixelEncoding, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) - *bpp = 16; - else if (CFStringCompare(pixelEncoding, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) - *bpp = 8; - else // error - *bpp = 0; - - // We're responsible for this - CFRelease(pixelEncoding); - CGDisplayModeRelease(currentMode); - } - else - { -#endif // fallback to 10.5 API - CFDictionaryRef currentMode = CGDisplayCurrentMode(kCGDirectMainDisplay); - CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(currentMode, kCGDisplayBitsPerPixel); - CFNumberGetValue(num, kCFNumberIntType, bpp); -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 - } -#endif - } - - if(freq) - { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 - if (CGDisplayCopyDisplayMode != NULL) - { - CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(kCGDirectMainDisplay); - *freq = (int)CGDisplayModeGetRefreshRate(currentMode); - - // We're responsible for this - CGDisplayModeRelease(currentMode); - } - else - { -#endif // fallback to 10.5 API - CFDictionaryRef currentMode = CGDisplayCurrentMode(kCGDirectMainDisplay); - CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(currentMode, kCGDisplayRefreshRate); - CFNumberGetValue(num, kCFNumberIntType, freq); -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 - } -#endif - } - - return INFO::OK; -} - -} // namespace gfx - OsPath sys_ExecutablePathname() { OsPath path; Index: ps/trunk/source/lib/sysdep/os/win/wgfx.cpp =================================================================== --- ps/trunk/source/lib/sysdep/os/win/wgfx.cpp +++ ps/trunk/source/lib/sysdep/os/win/wgfx.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -143,34 +143,3 @@ AppendDriverVersionsFromKnownFiles(versionList); return versionList; } - - -//----------------------------------------------------------------------------- -// direct implementations of some gfx functions - -namespace gfx { - -Status GetVideoMode(int* xres, int* yres, int* bpp, int* freq) -{ - DEVMODE dm = { sizeof(dm) }; - - if(!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm)) - WARN_RETURN(ERR::FAIL); - - // EnumDisplaySettings is documented to set the values of the following: - const DWORD expectedFlags = DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL|DM_DISPLAYFREQUENCY|DM_DISPLAYFLAGS; - ENSURE((dm.dmFields & expectedFlags) == expectedFlags); - - if(xres) - *xres = (int)dm.dmPelsWidth; - if(yres) - *yres = (int)dm.dmPelsHeight; - if(bpp) - *bpp = (int)dm.dmBitsPerPel; - if(freq) - *freq = (int)dm.dmDisplayFrequency; - - return INFO::OK; -} - -} // namespace gfx Index: ps/trunk/source/ps/VideoMode.h =================================================================== --- ps/trunk/source/ps/VideoMode.h +++ ps/trunk/source/ps/VideoMode.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -100,7 +100,8 @@ SDL_Window* m_Window; - // Initial desktop settings + // Initial desktop settings. + // Frequency is in Hz, and BPP means bits per pixels (not bytes per pixels). int m_PreferredW; int m_PreferredH; int m_PreferredBPP; Index: ps/trunk/source/ps/VideoMode.cpp =================================================================== --- ps/trunk/source/ps/VideoMode.cpp +++ ps/trunk/source/ps/VideoMode.cpp @@ -170,7 +170,15 @@ // preferred video mode = current desktop settings // (command line params may override these) - gfx::GetVideoMode(&m_PreferredW, &m_PreferredH, &m_PreferredBPP, &m_PreferredFreq); + // TODO: handle multi-screen and HiDPI properly. + SDL_DisplayMode mode; + if (SDL_GetDesktopDisplayMode(0, &mode) == 0) + { + m_PreferredW = mode.w; + m_PreferredH = mode.h; + m_PreferredBPP = SDL_BITSPERPIXEL(mode.format); + m_PreferredFreq = mode.refresh_rate; + } int w = m_ConfigW; int h = m_ConfigH;