feat: enable Windows dark mode for GLFW window

- Add DwmSetWindowAttribute call for immersive dark mode
- Include glfw3native.h after glfw3.h on Windows
This commit is contained in:
2026-05-05 22:52:24 +02:00
parent 40ae94788e
commit 7a81b30d32
+17
View File
@@ -1,7 +1,18 @@
#include <string_view> #include <string_view>
#ifdef _WIN32
#include <dwmapi.h>
#include <windows.h>
#endif
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE
#include "GLFW/glfw3.h" #include "GLFW/glfw3.h"
#ifdef _WIN32
#define GLFW_EXPOSE_NATIVE_WIN32
#include "GLFW/glfw3native.h"
#endif
#include "fmt/std.h" #include "fmt/std.h"
#include "glad/glad.h" #include "glad/glad.h"
@@ -58,6 +69,12 @@ context::context(std::string title, int width, int height) {
glfwMakeContextCurrent(m_window); glfwMakeContextCurrent(m_window);
#ifdef _WIN32
auto hwnd = glfwGetWin32Window(static_cast<GLFWwindow*>(m_window));
BOOL use_dark_mode = TRUE;
DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &use_dark_mode, sizeof(use_dark_mode));
#endif
if (!setup_gl()) { if (!setup_gl()) {
terminate(); terminate();
return; return;