From b1657b584d19123c7f861fa31983b5b3a597816a Mon Sep 17 00:00:00 2001 From: Emmanuel AYME Date: Sun, 4 Jan 2026 21:32:26 +0100 Subject: [PATCH] Add OSD shader manager --- includes/OSDManager.h | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 includes/OSDManager.h diff --git a/includes/OSDManager.h b/includes/OSDManager.h new file mode 100644 index 0000000..f2e2aea --- /dev/null +++ b/includes/OSDManager.h @@ -0,0 +1,49 @@ +#pragma once + +#include +#include + +using OSDUpdateFn = std::function; +using OSDEndFn = std::function; + +/** + * @brief Displays an On-Screen Display (OSD) for a specified duration. + * + * This function triggers an OSD that lasts for `duration` seconds. + * During the OSD display, the `onUpdate` callback will be called every frame + * with the current `reshade::api::effect_runtime` pointer, allowing shader updates + * or other visual effects. When the OSD duration ends, the `onEnd` callback + * is executed to perform any cleanup or final state updates. + * @param duration Duration in seconds for which the OSD should be visible. + * @param onUpdate Callback executed each frame while the OSD is visible. + * @param onEnd Callback executed once when the OSD ends or expires. + * @note This function only schedules the OSD. The actual frame updates occur + * during `UpdateOSD`, which must be called once per frame. + * @note Callbacks should be fast and non-blocking. + */ +void ShowOSD(float duration, OSDUpdateFn onUpdate, OSDEndFn onEnd); + + +/** + * @brief Updates the OSD system each frame and executes callbacks if needed. + * + * This function must be called once per frame, typically in `on_reshade_present`, + * to update any active OSDs, decrement their timers, and call the + * `onUpdate` and `onEnd` callbacks as necessary. + * @param runtime Pointer to the current `reshade::api::effect_runtime` object. + * @param deltaTime Time elapsed (in seconds) since the last frame. + * @note If no OSD is active, this function does nothing. + * @note Always call this function after processing hotkeys to ensure proper + * timing of OSDs. + */ +void UpdateOSD(reshade::api::effect_runtime* runtime, float deltaTime); + +/** + * @brief Reset all uniform variables enumerated. + * + * This function must be called once, typically in `on_reshade_begin_effects`, + * using an atomic compare-and-exchange operation + * @param runtime Pointer to the current `reshade::api::effect_runtime` object. + * @param effect_name File name of the effect file to enumerate uniform variables from (eg. myfile.fx) + */ +void ResetAllUniformVariables(reshade::api::effect_runtime* runtime, const char* effect_name);