From 7a81b30d32db26936fcf30832b3871d2f56844e1 Mon Sep 17 00:00:00 2001 From: portersky <24420859+portersky@users.noreply.github.com> Date: Tue, 5 May 2026 22:52:24 +0200 Subject: [PATCH] feat: enable Windows dark mode for GLFW window - Add DwmSetWindowAttribute call for immersive dark mode - Include glfw3native.h after glfw3.h on Windows --- cbt/opengl/context.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cbt/opengl/context.cpp b/cbt/opengl/context.cpp index 47c692e..770aa7c 100644 --- a/cbt/opengl/context.cpp +++ b/cbt/opengl/context.cpp @@ -1,7 +1,18 @@ #include +#ifdef _WIN32 +#include +#include +#endif + #define GLFW_INCLUDE_NONE #include "GLFW/glfw3.h" + +#ifdef _WIN32 +#define GLFW_EXPOSE_NATIVE_WIN32 +#include "GLFW/glfw3native.h" +#endif + #include "fmt/std.h" #include "glad/glad.h" @@ -58,6 +69,12 @@ context::context(std::string title, int width, int height) { glfwMakeContextCurrent(m_window); +#ifdef _WIN32 + auto hwnd = glfwGetWin32Window(static_cast(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()) { terminate(); return;