Skip to content

Commit

Permalink
uwp again
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Feb 2, 2024
1 parent b122279 commit 5ccd557
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/hello_imgui/internal/main_screen_resolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,36 @@ ImVec2 MainScreenResolution_Vec2()

#if defined(_WIN32)
#undef APIENTRY
#include <array>
#ifdef WINAPI_FAMILY
#include <winapifamily.h>
#endif

#if WINAPI_FAMILY == WINAPI_FAMILY_APP
#include <winrt/Windows.Graphics.Display.h>
#endif

#ifdef _WIN32
#include <windows.h>
#endif

std::array<int, 2> MainScreenResolution()
{
return {
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN)
};
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
// UWP build
auto displayInfo = winrt::Windows::Graphics::Display::DisplayInformation::GetForCurrentView();
auto resolution = displayInfo.ScreenWidthInRawPixels();
auto resolutionHeight = displayInfo.ScreenHeightInRawPixels();
return { static_cast<int>(resolution), static_cast<int>(resolutionHeight) };
#else
// Non-UWP build
return {
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN)
};
#endif
}

#elif defined(__ANDROID__)
std::array<int, 2> MainScreenResolution()
{
Expand Down

0 comments on commit 5ccd557

Please sign in to comment.