filter-custom-shader: Update to use new gfx::effect_source::effect_source

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-08-07 17:15:46 +02:00
parent bde4e278bf
commit ff4a556f3f
2 changed files with 24 additions and 4 deletions

View file

@ -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<gfx::effect_source::effect_source>();
_rt = std::make_shared<gs::rendertarget>(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);
}
}

View file

@ -20,6 +20,8 @@
#pragma once
#include "plugin.hpp"
#include "gfx/gfx-effect-source.hpp"
#include "obs/gs/gs-rendertarget.hpp"
extern "C" {
#include <obs.h>
@ -46,6 +48,9 @@ namespace filter {
uint32_t _width, _height;
std::shared_ptr<gs::rendertarget> _rt;
std::shared_ptr<gfx::effect_source::effect_source> _fx;
public:
shader_instance(obs_data_t* data, obs_source_t* self);
~shader_instance();