From 9b76e1c905a85f3e7fc60cbd62e336be3d96c885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Sat, 19 Oct 2024 10:56:51 +0200 Subject: [PATCH] added lua bindings for HDR display control --- .../ScriptingAPI-Documentation.md | 2 ++ WickedEngine/wiApplication_BindLua.cpp | 27 +++++++++++++++++++ WickedEngine/wiApplication_BindLua.h | 3 +++ WickedEngine/wiVersion.cpp | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Content/Documentation/ScriptingAPI-Documentation.md b/Content/Documentation/ScriptingAPI-Documentation.md index f8b300144..1d676e286 100644 --- a/Content/Documentation/ScriptingAPI-Documentation.md +++ b/Content/Documentation/ScriptingAPI-Documentation.md @@ -1640,6 +1640,8 @@ This is the main entry point and manages the lifetime of the application. - SetHeapAllocationCountDisplay(bool active) -- toggle display of heap allocation statistics if info display is enabled - SetVRAMUsageDisplay(bool active) -- toggle display of video memory usage if info display is enabled - SetColorGradingHelper(bool value) -- toggale color grading helper display in the top left corner +- IsHDRSupported() : bool -- returns whther HDR display output is supported on the current monitor +- SetHDR(bool) -- sets HDR display mode (if monitor supports it) - GetCanvas() : Canvas canvas -- returns a copy of the application's current canvas - SetCanvas(Canvas canvas) -- applies the specified canvas to the application - Exit() -- Closes the program diff --git a/WickedEngine/wiApplication_BindLua.cpp b/WickedEngine/wiApplication_BindLua.cpp index be90f33d8..446736210 100644 --- a/WickedEngine/wiApplication_BindLua.cpp +++ b/WickedEngine/wiApplication_BindLua.cpp @@ -27,6 +27,8 @@ namespace wi::lua lunamethod(Application_BindLua, SetHeapAllocationCountDisplay), lunamethod(Application_BindLua, SetVRAMUsageDisplay), lunamethod(Application_BindLua, SetColorGradingHelper), + lunamethod(Application_BindLua, IsHDRSupported), + lunamethod(Application_BindLua, SetHDR), lunamethod(Application_BindLua, GetCanvas), lunamethod(Application_BindLua, SetCanvas), lunamethod(Application_BindLua, Exit), @@ -383,6 +385,31 @@ namespace wi::lua return 0; } + int Application_BindLua::IsHDRSupported(lua_State* L) + { + wi::lua::SSetBool(L, wi::graphics::GetDevice()->IsSwapChainSupportsHDR(&component->swapChain)); + return 1; + } + int Application_BindLua::SetHDR(lua_State* L) + { + if (component == nullptr) + { + wi::lua::SError(L, "SetHDR() component is empty!"); + return 0; + } + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + component->allow_hdr = wi::lua::SGetBool(L, 1); + component->swapChain.desc.allow_hdr = component->allow_hdr; + bool success = wi::graphics::GetDevice()->CreateSwapChain(&component->swapChain.desc, nullptr, &component->swapChain); + assert(success); + } + else + wi::lua::SError(L, "SetHDR(bool active) not enough arguments!"); + return 0; + } + int Application_BindLua::GetCanvas(lua_State* L) { if (component == nullptr) diff --git a/WickedEngine/wiApplication_BindLua.h b/WickedEngine/wiApplication_BindLua.h index cc7890b20..1780cd429 100644 --- a/WickedEngine/wiApplication_BindLua.h +++ b/WickedEngine/wiApplication_BindLua.h @@ -57,6 +57,9 @@ namespace wi::lua int SetVRAMUsageDisplay(lua_State* L); int SetColorGradingHelper(lua_State* L); + int IsHDRSupported(lua_State* L); + int SetHDR(lua_State* L); + int GetCanvas(lua_State* L); int SetCanvas(lua_State* L); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 9d34a94de..3c059f56c 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 598; + const int revision = 599; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);