From ff4a556f3f769ec96f8d830fa53dbccead7a23e5 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Wed, 7 Aug 2019 17:15:46 +0200 Subject: [PATCH] filter-custom-shader: Update to use new gfx::effect_source::effect_source --- source/filters/filter-custom-shader.cpp | 23 +++++++++++++++++++---- source/filters/filter-custom-shader.hpp | 5 +++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/source/filters/filter-custom-shader.cpp b/source/filters/filter-custom-shader.cpp index 9e78ae2..1d41de2 100644 --- a/source/filters/filter-custom-shader.cpp +++ b/source/filters/filter-custom-shader.cpp @@ -146,7 +146,12 @@ filter::shader::shader_factory::~shader_factory() {} filter::shader::shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : _self(self), _active(true), _width(0), _height(0) -{} +{ + _fx = std::make_shared(); + _rt = std::make_shared(GS_RGBA, GS_ZS_NONE); + + update(data); +} filter::shader::shader_instance::~shader_instance() {} @@ -160,9 +165,13 @@ uint32_t filter::shader::shader_instance::height() return _height; } -void filter::shader::shader_instance::properties(obs_properties_t* props) {} +void filter::shader::shader_instance::properties(obs_properties_t* props) { + _fx->properties(props); +} -void filter::shader::shader_instance::update(obs_data_t* data) {} +void filter::shader::shader_instance::update(obs_data_t* data) { + _fx->update(data); +} void filter::shader::shader_instance::activate() { @@ -182,6 +191,8 @@ void filter::shader::shader_instance::video_tick(float_t sec_since_last) _width = obs_source_get_base_width(target); _height = obs_source_get_base_height(target); } + + _fx->tick(sec_since_last); } void filter::shader::shader_instance::video_render(gs_effect_t* effect) @@ -199,5 +210,9 @@ void filter::shader::shader_instance::video_render(gs_effect_t* effect) return; } - obs_source_skip_video_filter(_self); + try { + _fx->render(); + } catch (...) { + obs_source_skip_video_filter(_self); + } } diff --git a/source/filters/filter-custom-shader.hpp b/source/filters/filter-custom-shader.hpp index 6c1c0ff..197a7d9 100644 --- a/source/filters/filter-custom-shader.hpp +++ b/source/filters/filter-custom-shader.hpp @@ -20,6 +20,8 @@ #pragma once #include "plugin.hpp" +#include "gfx/gfx-effect-source.hpp" +#include "obs/gs/gs-rendertarget.hpp" extern "C" { #include @@ -46,6 +48,9 @@ namespace filter { uint32_t _width, _height; + std::shared_ptr _rt; + std::shared_ptr _fx; + public: shader_instance(obs_data_t* data, obs_source_t* self); ~shader_instance();