We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version/Branch of Dear ImGui:
Dear ImGui 1.76 (17600) -------------------------------- define: __cplusplus=199711 define: _WIN32 define: _WIN64 define: _MSC_VER=1925 -------------------------------- io.BackendPlatformName: imgui_impl_win32 io.BackendRendererName: imgui_impl_dx11
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_win32 + imgui_impl_dx11 Compiler: Microsoft Visual Studio 16.5.4 Operating System: Windows 10
My Issue/Question:
In version 1.75 ImGui didn't have a dependency on GDI+. So I happily used it with #define NOGDI defined in pch.h.
#define NOGDI
pch.h
In version 1.76 ImGui_ImplWin32_GetDpiScaleForMonitor function was added. That brought dependency on GDI+ function GetDeviceCaps. Here is guilty code:
ImGui_ImplWin32_GetDpiScaleForMonitor
GetDeviceCaps
#ifdef _MSC_VER #pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps() #endif float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor) { UINT xdpi = 96, ydpi = 96; if (IsWindows8Point1OrGreater()) { static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor")) GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi); } else { const HDC dc = ::GetDC(NULL); xdpi = ::GetDeviceCaps(dc, LOGPIXELSX); ydpi = ::GetDeviceCaps(dc, LOGPIXELSY); ::ReleaseDC(NULL, dc); } IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert! return xdpi / 96.0f; } float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd) { HMONITOR monitor = ::MonitorFromWindow((HWND)hwnd, MONITOR_DEFAULTTONEAREST); return ImGui_ImplWin32_GetDpiScaleForMonitor(monitor); }
It seems to be an overkill to depend on GDI+ for just one function, which is used only on systems older than Windows 8!
Possible solution is to have this dependency under #ifndef NOGDI:
#ifndef NOGDI
#ifndef NOGDI else { const HDC dc = ::GetDC(NULL); xdpi = ::GetDeviceCaps(dc, LOGPIXELSX); ydpi = ::GetDeviceCaps(dc, LOGPIXELSY); ::ReleaseDC(NULL, dc); } #endif
If the client is opted out GDI+ and has its application running on Windows 7 or older, it's safe to assume GetDeviceCaps returned 96, I guess.
Standalone, minimal, complete and verifiable example:
The text was updated successfully, but these errors were encountered:
Backends: Win32: Support for #define NOGDI, won't try to call GetDevi…
37f665b
…ceCaps(). (#3137, #2327)
Hello, I have merged the suggested changed along with the pragma line. Thank you! Ref #2327
Sorry, something went wrong.
No branches or pull requests
Version/Branch of Dear ImGui:
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_win32 + imgui_impl_dx11
Compiler: Microsoft Visual Studio 16.5.4
Operating System: Windows 10
My Issue/Question:
In version 1.75 ImGui didn't have a dependency on GDI+. So I happily used it with
#define NOGDI
defined inpch.h
.In version 1.76
ImGui_ImplWin32_GetDpiScaleForMonitor
function was added. That brought dependency on GDI+ functionGetDeviceCaps
. Here is guilty code:It seems to be an overkill to depend on GDI+ for just one function, which is used only on systems older than Windows 8!
Possible solution is to have this dependency under
#ifndef NOGDI
:If the client is opted out GDI+ and has its application running on Windows 7 or older, it's safe to assume
GetDeviceCaps
returned 96, I guess.Standalone, minimal, complete and verifiable example:
The text was updated successfully, but these errors were encountered: