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:
@@ -1,7 +1,18 @@
|
||||
#include <string_view>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <dwmapi.h>
|
||||
#include <windows.h>
|
||||
#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<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()) {
|
||||
terminate();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user