2017-11-06 11:36:01 +00:00
|
|
|
/*
|
|
|
|
* Modern effects for a modern Streamer
|
|
|
|
* Copyright (C) 2017 Michael Fabian Dirks
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2019-08-07 10:43:23 +00:00
|
|
|
|
2019-08-07 15:15:46 +00:00
|
|
|
#include "gfx/gfx-effect-source.hpp"
|
|
|
|
#include "obs/gs/gs-rendertarget.hpp"
|
2019-08-07 15:37:52 +00:00
|
|
|
#include "plugin.hpp"
|
2017-11-06 11:36:01 +00:00
|
|
|
|
2019-08-07 10:43:23 +00:00
|
|
|
extern "C" {
|
|
|
|
#include <obs.h>
|
|
|
|
}
|
|
|
|
|
2018-09-30 16:49:52 +00:00
|
|
|
namespace filter {
|
2019-08-07 10:43:23 +00:00
|
|
|
namespace shader {
|
|
|
|
class shader_factory {
|
|
|
|
obs_source_info _source_info;
|
|
|
|
|
|
|
|
public: // Singleton
|
|
|
|
static void initialize();
|
|
|
|
static void finalize();
|
|
|
|
static std::shared_ptr<shader_factory> get();
|
|
|
|
|
|
|
|
public:
|
|
|
|
shader_factory();
|
|
|
|
~shader_factory();
|
|
|
|
};
|
2017-11-06 11:36:01 +00:00
|
|
|
|
2019-08-07 10:43:23 +00:00
|
|
|
class shader_instance {
|
|
|
|
obs_source_t* _self;
|
|
|
|
bool _active;
|
2017-11-06 11:36:01 +00:00
|
|
|
|
2019-08-07 10:43:23 +00:00
|
|
|
uint32_t _width, _height;
|
2017-11-06 11:36:01 +00:00
|
|
|
|
2019-09-04 00:47:27 +00:00
|
|
|
bool _scale_locked;
|
|
|
|
float_t _wscale, _hscale;
|
|
|
|
uint32_t _swidth, _sheight;
|
|
|
|
|
2019-08-07 15:37:52 +00:00
|
|
|
std::shared_ptr<gs::rendertarget> _rt;
|
|
|
|
bool _rt_updated;
|
|
|
|
std::shared_ptr<gs::texture> _rt_tex;
|
|
|
|
|
2019-08-07 17:20:32 +00:00
|
|
|
std::shared_ptr<gs::rendertarget> _rt2;
|
|
|
|
bool _rt2_updated;
|
|
|
|
std::shared_ptr<gs::texture> _rt2_tex;
|
|
|
|
|
2019-08-07 15:15:46 +00:00
|
|
|
std::shared_ptr<gfx::effect_source::effect_source> _fx;
|
|
|
|
|
2019-08-07 10:43:23 +00:00
|
|
|
public:
|
|
|
|
shader_instance(obs_data_t* data, obs_source_t* self);
|
|
|
|
~shader_instance();
|
2017-11-06 11:36:01 +00:00
|
|
|
|
2019-08-07 10:43:23 +00:00
|
|
|
uint32_t width();
|
|
|
|
uint32_t height();
|
2018-04-09 11:28:13 +00:00
|
|
|
|
2019-08-07 10:43:23 +00:00
|
|
|
void properties(obs_properties_t* props);
|
2018-04-09 11:28:13 +00:00
|
|
|
|
2019-08-07 18:39:55 +00:00
|
|
|
void load(obs_data_t* data);
|
2019-08-07 10:43:23 +00:00
|
|
|
void update(obs_data_t* data);
|
2018-04-09 11:28:13 +00:00
|
|
|
|
2019-08-07 10:43:23 +00:00
|
|
|
void activate();
|
|
|
|
void deactivate();
|
2018-11-07 14:24:25 +00:00
|
|
|
|
2019-08-07 15:37:52 +00:00
|
|
|
bool valid_param(std::shared_ptr<gs::effect_parameter> param);
|
|
|
|
void override_param(std::shared_ptr<gs::effect> effect);
|
|
|
|
|
2019-08-07 18:39:55 +00:00
|
|
|
void enum_active_sources(obs_source_enum_proc_t, void*);
|
|
|
|
|
2019-08-07 10:43:23 +00:00
|
|
|
void video_tick(float_t sec_since_last);
|
|
|
|
void video_render(gs_effect_t* effect);
|
2017-11-06 11:36:01 +00:00
|
|
|
};
|
2019-08-07 10:43:23 +00:00
|
|
|
} // namespace shader
|
2018-11-07 14:24:25 +00:00
|
|
|
} // namespace filter
|