Files
ReshadePluginsAddon/libs/OSDManager.cpp

34 lines
885 B
C++

#include "OSDManager.h"
static float g_timer = 0.0f;
static OSDUpdateFn g_onUpdate;
static OSDEndFn g_onEnd;
void ShowOSD(float duration, OSDUpdateFn onUpdate, OSDEndFn onEnd) {
g_timer = duration;
g_onUpdate = std::move(onUpdate);
g_onEnd = std::move(onEnd);
}
void UpdateOSD(reshade::api::effect_runtime* runtime, float deltaTime) {
if (g_timer <= 0.0f) return;
g_timer -= deltaTime;
if (g_onUpdate) g_onUpdate(runtime);
if (g_timer <= 0.0f) {
if (g_onEnd) g_onEnd(runtime);
g_onUpdate = nullptr;
g_onEnd = nullptr;
}
}
void ResetAllUniformVariables(reshade::api::effect_runtime* runtime, const char* effect_name) {
runtime->enumerate_uniform_variables(effect_name, [runtime](reshade::api::effect_runtime* rt, reshade::api::effect_uniform_variable OSDvar) {
runtime->reset_uniform_value(OSDvar);
});
}