From 9ad93c0ee9afea37777aebbe3052345f673d82eb Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Wed, 7 Aug 2019 18:05:49 +0200 Subject: [PATCH] filter-shader: Rename from Custom shader --- ...er-custom-shader.cpp => filter-shader.cpp} | 30 +++++++++++++++++-- ...er-custom-shader.hpp => filter-shader.hpp} | 0 2 files changed, 28 insertions(+), 2 deletions(-) rename source/filters/{filter-custom-shader.cpp => filter-shader.cpp} (89%) rename source/filters/{filter-custom-shader.hpp => filter-shader.hpp} (100%) diff --git a/source/filters/filter-custom-shader.cpp b/source/filters/filter-shader.cpp similarity index 89% rename from source/filters/filter-custom-shader.cpp rename to source/filters/filter-shader.cpp index c8ab805e..0ad931ad 100644 --- a/source/filters/filter-custom-shader.cpp +++ b/source/filters/filter-shader.cpp @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "filter-custom-shader.hpp" +#include "filter-shader.hpp" #include "strings.hpp" #include "utility.hpp" @@ -46,7 +46,11 @@ std::shared_ptr filter::shader::shader_factory:: return factory_instance; } -static void get_defaults(obs_data_t* data) {} +static void get_defaults(obs_data_t* data) +{ + obs_data_set_default_string(data, S_SHADER_FILE, obs_module_file("shaders/filter/example.effect")); + obs_data_set_default_string(data, S_SHADER_TECHNIQUE, "Draw"); +} filter::shader::shader_factory::shader_factory() { @@ -88,6 +92,28 @@ filter::shader::shader_factory::shader_factory() } return pr; }; + _source_info.get_width = [](void* ptr) { + try { + if (ptr) + return reinterpret_cast(ptr)->width(); + } catch (std::exception& ex) { + P_LOG_ERROR(" Failed to retrieve width, error: %s", ex.what()); + } catch (...) { + P_LOG_ERROR(" Failed to retrieve width."); + } + return uint32_t(0); + }; + _source_info.get_height = [](void* ptr) { + try { + if (ptr) + return reinterpret_cast(ptr)->height(); + } catch (std::exception& ex) { + P_LOG_ERROR(" Failed to retrieve height, error: %s", ex.what()); + } catch (...) { + P_LOG_ERROR(" Failed to retrieve height."); + } + return uint32_t(0); + }; _source_info.update = [](void* ptr, obs_data_t* data) { try { if (ptr) diff --git a/source/filters/filter-custom-shader.hpp b/source/filters/filter-shader.hpp similarity index 100% rename from source/filters/filter-custom-shader.hpp rename to source/filters/filter-shader.hpp