Changeset View
Changeset View
Standalone View
Standalone View
source/lib/sysdep/os/win/wgfx.cpp
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | |||||
std::wstring wgfx_DriverInfo() | std::wstring wgfx_DriverInfo() | ||||
{ | { | ||||
VersionList versionList; | VersionList versionList; | ||||
if(AppendDriverVersionsFromRegistry(versionList) != INFO::OK) // (fails on Windows 7) | if(AppendDriverVersionsFromRegistry(versionList) != INFO::OK) // (fails on Windows 7) | ||||
AppendDriverVersionsFromKnownFiles(versionList); | AppendDriverVersionsFromKnownFiles(versionList); | ||||
return 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 |
Wildfire Games · Phabricator