Remove obsolete GetVideoMode platform-specifics, replaces by platform-agnostic SDL2`s APIs.
Before and after the commit we don't support multiple displays and HiDPI properly. Patch By: linkmauve Tested By: Angen, elexis, Stan Differential Revision: https://code.wildfiregames.com/D2476 This was SVN commit r23754.
This commit is contained in:
parent
f3a49014fb
commit
409c436ae2
@ -41,16 +41,6 @@ LIB_API std::wstring CardName();
|
||||
**/
|
||||
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
|
||||
|
@ -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;
|
||||
|
@ -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 @@ std::wstring wgfx_DriverInfo()
|
||||
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
|
||||
|
@ -170,7 +170,15 @@ bool CVideoMode::InitSDL()
|
||||
|
||||
// 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;
|
||||
|
@ -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 @@ private:
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user