From 6f7c03fb28024a6d58a892de950ddd037a53167f Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Thu, 25 Nov 2021 06:23:09 +0100 Subject: [PATCH] obs/gs/effect-parameter: Add support for sRGB texture inputs --- source/obs/gs/gs-effect-parameter.cpp | 14 ++++++++------ source/obs/gs/gs-effect-parameter.hpp | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/obs/gs/gs-effect-parameter.cpp b/source/obs/gs/gs-effect-parameter.cpp index 16e4a022..8556d93a 100644 --- a/source/obs/gs/gs-effect-parameter.cpp +++ b/source/obs/gs/gs-effect-parameter.cpp @@ -647,18 +647,20 @@ void streamfx::obs::gs::effect_parameter::get_default_matrix(matrix4& v) } } -void streamfx::obs::gs::effect_parameter::set_texture(std::shared_ptr v) +void streamfx::obs::gs::effect_parameter::set_texture(std::shared_ptr v, bool srgb) { - if (get_type() != type::Texture) - throw std::bad_cast(); - gs_effect_set_texture(get(), v->get_object()); + set_texture(v->get_object(), srgb); } -void streamfx::obs::gs::effect_parameter::set_texture(gs_texture_t* v) +void streamfx::obs::gs::effect_parameter::set_texture(gs_texture_t* v, bool srgb) { if (get_type() != type::Texture) throw std::bad_cast(); - gs_effect_set_texture(get(), v); + if (!srgb) { + gs_effect_set_texture(get(), v); + } else { + gs_effect_set_texture_srgb(get(), v); + } } void streamfx::obs::gs::effect_parameter::set_sampler(std::shared_ptr v) diff --git a/source/obs/gs/gs-effect-parameter.hpp b/source/obs/gs/gs-effect-parameter.hpp index c5686461..df956755 100644 --- a/source/obs/gs/gs-effect-parameter.hpp +++ b/source/obs/gs/gs-effect-parameter.hpp @@ -189,8 +189,8 @@ namespace streamfx::obs::gs { void get_matrix(matrix4& v); void get_default_matrix(matrix4& v); - void set_texture(std::shared_ptr v); - void set_texture(gs_texture_t* v); + void set_texture(std::shared_ptr v, bool srgb = false); + void set_texture(gs_texture_t* v, bool srgb = false); void set_sampler(std::shared_ptr v); void set_sampler(gs_sampler_state* v);