gfx, gs: Fix commits 9f518764b6 & 2adfa5765c

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2018-03-20 12:50:17 +01:00
parent 22eb53a856
commit fe05dca51e
9 changed files with 74 additions and 103 deletions

View file

@ -346,7 +346,7 @@ void Filter::Blur::Instance::video_render(gs_effect_t *effect) {
uint32_t uint32_t
baseW = obs_source_get_base_width(target), baseW = obs_source_get_base_width(target),
baseH = obs_source_get_base_height(target); baseH = obs_source_get_base_height(target);
gs_effect_t* colorConversionEffect = g_effects.count("Color Conversion") ? g_effects.at("Color Conversion")->GetObject() : nullptr; gs_effect_t* colorConversionEffect = g_effects.count("Color Conversion") ? g_effects.at("Color Conversion")->get_object() : nullptr;
// Skip rendering if our target, parent or context is not valid. // Skip rendering if our target, parent or context is not valid.
if (!target || !parent || !m_source) { if (!target || !parent || !m_source) {
@ -504,7 +504,7 @@ void Filter::Blur::Instance::video_render(gs_effect_t *effect) {
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &black, 0, 0); gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &black, 0, 0);
// Render // Render
while (gs_effect_loop(m_effect->GetObject(), "Draw")) { while (gs_effect_loop(m_effect->get_object(), "Draw")) {
gs_draw_sprite(intermediate, 0, baseW, baseH); gs_draw_sprite(intermediate, 0, baseW, baseH);
} }
@ -566,24 +566,24 @@ void Filter::Blur::Instance::video_render(gs_effect_t *effect) {
bool Filter::Blur::Instance::apply_shared_param(gs_texture_t* input, float texelX, float texelY) { bool Filter::Blur::Instance::apply_shared_param(gs_texture_t* input, float texelX, float texelY) {
bool result = true; bool result = true;
result = result && gs_set_param_texture(m_effect->GetObject(), "u_image", input); result = result && gs_set_param_texture(m_effect->get_object(), "u_image", input);
vec2 imageSize; vec2 imageSize;
vec2_set(&imageSize, vec2_set(&imageSize,
(float)gs_texture_get_width(input), (float)gs_texture_get_width(input),
(float)gs_texture_get_height(input)); (float)gs_texture_get_height(input));
result = result && gs_set_param_float2(m_effect->GetObject(), "u_imageSize", &imageSize); result = result && gs_set_param_float2(m_effect->get_object(), "u_imageSize", &imageSize);
vec2 imageTexelDelta; vec2 imageTexelDelta;
vec2_set(&imageTexelDelta, 1.0f, 1.0f); vec2_set(&imageTexelDelta, 1.0f, 1.0f);
vec2_div(&imageTexelDelta, &imageTexelDelta, &imageSize); vec2_div(&imageTexelDelta, &imageTexelDelta, &imageSize);
result = result && gs_set_param_float2(m_effect->GetObject(), "u_imageTexel", &imageTexelDelta); result = result && gs_set_param_float2(m_effect->get_object(), "u_imageTexel", &imageTexelDelta);
vec2 texel; vec2_set(&texel, texelX, texelY); vec2 texel; vec2_set(&texel, texelX, texelY);
result = result && gs_set_param_float2(m_effect->GetObject(), "u_texelDelta", &texel); result = result && gs_set_param_float2(m_effect->get_object(), "u_texelDelta", &texel);
result = result && gs_set_param_int(m_effect->GetObject(), "u_radius", (int)m_size); result = result && gs_set_param_int(m_effect->get_object(), "u_radius", (int)m_size);
result = result && gs_set_param_int(m_effect->GetObject(), "u_diameter", (int)(1 + (m_size * 2))); result = result && gs_set_param_int(m_effect->get_object(), "u_diameter", (int)(1 + (m_size * 2)));
return result; return result;
} }
@ -595,7 +595,7 @@ bool Filter::Blur::Instance::apply_bilateral_param() {
return false; return false;
// Bilateral Blur // Bilateral Blur
param = gs_effect_get_param_by_name(m_effect->GetObject(), "bilateralSmoothing"); param = gs_effect_get_param_by_name(m_effect->get_object(), "bilateralSmoothing");
if (!param) { if (!param) {
P_LOG_ERROR("<filter-blur> Failed to set bilateralSmoothing param."); P_LOG_ERROR("<filter-blur> Failed to set bilateralSmoothing param.");
return false; return false;
@ -605,7 +605,7 @@ bool Filter::Blur::Instance::apply_bilateral_param() {
(float)(m_bilateralSmoothing * (1 + m_size * 2))); (float)(m_bilateralSmoothing * (1 + m_size * 2)));
} }
param = gs_effect_get_param_by_name(m_effect->GetObject(), "bilateralSharpness"); param = gs_effect_get_param_by_name(m_effect->get_object(), "bilateralSharpness");
if (!param) { if (!param) {
P_LOG_ERROR("<filter-blur> Failed to set bilateralSmoothing param."); P_LOG_ERROR("<filter-blur> Failed to set bilateralSmoothing param.");
return false; return false;
@ -626,12 +626,12 @@ bool Filter::Blur::Instance::apply_gaussian_param() {
std::shared_ptr<gs::texture> tex; std::shared_ptr<gs::texture> tex;
if ((m_size - 1) < MaxKernelSize) { if ((m_size - 1) < MaxKernelSize) {
tex = g_gaussianKernels[size_t(m_size - 1)]; tex = g_gaussianKernels[size_t(m_size - 1)];
result = result && gs_set_param_texture(m_effect->GetObject(), "kernel", tex->GetObject()); result = result && gs_set_param_texture(m_effect->get_object(), "kernel", tex->get_object());
} }
vec2 kerneltexel; vec2 kerneltexel;
vec2_set(&kerneltexel, 1.0f / gs_texture_get_width(tex->GetObject()), 0); vec2_set(&kerneltexel, 1.0f / gs_texture_get_width(tex->get_object()), 0);
result = result && gs_set_param_float2(m_effect->GetObject(), "kernelTexel", &kerneltexel); result = result && gs_set_param_float2(m_effect->get_object(), "kernelTexel", &kerneltexel);
return result; return result;
} }

View file

@ -484,13 +484,13 @@ void Filter::CustomShader::Instance::video_render(gs_effect_t *effect) {
w = obs_source_get_width(prm.value.source.source); w = obs_source_get_width(prm.value.source.source);
h = obs_source_get_height(prm.value.source.source); h = obs_source_get_height(prm.value.source.source);
{ {
auto op = prm.value.source.rendertarget->Render(w, h); auto op = prm.value.source.rendertarget->render(w, h);
vec4 black; vec4_zero(&black); vec4 black; vec4_zero(&black);
gs_ortho(0, (float_t)w, 0, (float_t)h, 0, 1); gs_ortho(0, (float_t)w, 0, (float_t)h, 0, 1);
gs_clear(GS_CLEAR_COLOR, &black, 0, 0); gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
obs_source_video_render(prm.value.source.source); obs_source_video_render(prm.value.source.source);
} }
eprm.set_texture(prm.value.source.rendertarget->GetTextureObject()); eprm.set_texture(prm.value.source.rendertarget->get_object());
} }
} else { } else {
if (prm.value.file.texture) { if (prm.value.file.texture) {

View file

@ -20,7 +20,7 @@
#include <libobs/util/platform.h> #include <libobs/util/platform.h>
#include <fstream> #include <fstream>
bool gfx::ShaderSource::property_type_modified(void* priv, obs_properties_t* props, obs_property_t* prop, obs_data_t* sett) { bool gfx::effect_source::property_type_modified(void* priv, obs_properties_t* props, obs_property_t* prop, obs_data_t* sett) {
switch ((InputTypes)obs_data_get_int(sett, D_TYPE)) { switch ((InputTypes)obs_data_get_int(sett, D_TYPE)) {
default: default:
case InputTypes::Text: case InputTypes::Text:
@ -35,11 +35,11 @@ bool gfx::ShaderSource::property_type_modified(void* priv, obs_properties_t* pro
return true; return true;
} }
bool gfx::ShaderSource::property_input_modified(void* priv, obs_properties_t* props, obs_property_t* prop, obs_data_t* sett) { bool gfx::effect_source::property_input_modified(void* priv, obs_properties_t* props, obs_property_t* prop, obs_data_t* sett) {
return true; return true;
} }
gfx::ShaderSource::ShaderSource(obs_data_t* data, obs_source_t* owner) { gfx::effect_source::effect_source(obs_data_t* data, obs_source_t* owner) {
obs_source_addref(owner); obs_source_addref(owner);
m_source = owner; m_source = owner;
time_existing = 0; time_existing = 0;
@ -48,11 +48,11 @@ gfx::ShaderSource::ShaderSource(obs_data_t* data, obs_source_t* owner) {
update(data); update(data);
} }
gfx::ShaderSource::~ShaderSource() { gfx::effect_source::~effect_source() {
obs_source_release(m_source); obs_source_release(m_source);
} }
void gfx::ShaderSource::get_properties(obs_properties_t* properties) { void gfx::effect_source::get_properties(obs_properties_t* properties) {
obs_property_t* p = nullptr; obs_property_t* p = nullptr;
p = obs_properties_add_list(properties, D_TYPE, P_TRANSLATE(T_TYPE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); p = obs_properties_add_list(properties, D_TYPE, P_TRANSLATE(T_TYPE), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
@ -77,7 +77,7 @@ void gfx::ShaderSource::get_properties(obs_properties_t* properties) {
// ToDo: Place updated properties here or somewhere else? // ToDo: Place updated properties here or somewhere else?
} }
void gfx::ShaderSource::update(obs_data_t* data) { void gfx::effect_source::update(obs_data_t* data) {
obs_data_addref(data); obs_data_addref(data);
// Update Shader // Update Shader
@ -93,7 +93,7 @@ void gfx::ShaderSource::update(obs_data_t* data) {
obs_data_release(data); obs_data_release(data);
} }
bool gfx::ShaderSource::test_for_updates(const char* text, const char* path) { bool gfx::effect_source::test_for_updates(const char* text, const char* path) {
bool is_shader_different = false; bool is_shader_different = false;
if (text != nullptr) { if (text != nullptr) {
if (text != effect.text) { if (text != effect.text) {
@ -102,7 +102,7 @@ bool gfx::ShaderSource::test_for_updates(const char* text, const char* path) {
} }
if (is_shader_different) { if (is_shader_different) {
effect.effect = std::make_unique<GS::Effect>(effect.text, "Text"); effect.effect = std::make_unique<gs::effect>(effect.text, "Text");
} }
} else if (path != nullptr) { } else if (path != nullptr) {
if (path != this->effect.path) { if (path != this->effect.path) {
@ -134,7 +134,7 @@ bool gfx::ShaderSource::test_for_updates(const char* text, const char* path) {
} }
// Increment timer so that the next check is a reasonable timespan away. // Increment timer so that the next check is a reasonable timespan away.
effect.file_info.time_updated += 0.1; effect.file_info.time_updated += 0.1f;
} }
if (is_shader_different || effect.file_info.modified) { if (is_shader_different || effect.file_info.modified) {
@ -152,7 +152,7 @@ bool gfx::ShaderSource::test_for_updates(const char* text, const char* path) {
fs.close(); fs.close();
content[sz] = '\0'; content[sz] = '\0';
effect.effect = std::make_unique<GS::Effect>(content, effect.path); effect.effect = std::make_unique<gs::effect>(std::string(content.data()), effect.path);
} }
} }
} }
@ -166,23 +166,23 @@ bool gfx::ShaderSource::test_for_updates(const char* text, const char* path) {
return is_shader_different; return is_shader_different;
} }
void gfx::ShaderSource::active() { void gfx::effect_source::active() {
time_active = 0; time_active = 0;
} }
void gfx::ShaderSource::deactivate() { void gfx::effect_source::deactivate() {
time_active = 0; time_active = 0;
} }
uint32_t gfx::ShaderSource::get_width() { uint32_t gfx::effect_source::get_width() {
return 0; return 0;
} }
uint32_t gfx::ShaderSource::get_height() { uint32_t gfx::effect_source::get_height() {
return 0; return 0;
} }
void gfx::ShaderSource::video_tick(float time) { void gfx::effect_source::video_tick(float time) {
// Shader Timers // Shader Timers
time_existing += time; time_existing += time;
time_active += time; time_active += time;
@ -191,6 +191,6 @@ void gfx::ShaderSource::video_tick(float time) {
effect.file_info.time_updated -= time; effect.file_info.time_updated -= time;
} }
void gfx::ShaderSource::video_render(gs_effect_t* parent_effect) { void gfx::effect_source::video_render(gs_effect_t* parent_effect) {
} }

View file

@ -38,28 +38,13 @@
#define T_INPUT_FILE "CustomShader.Input.File" #define T_INPUT_FILE "CustomShader.Input.File"
namespace gfx { namespace gfx {
struct ShaderParameter { class effect_source {
};
struct ShaderTextureParameter : ShaderParameter {
bool is_source = false;
// File / Texture
std::shared_ptr<GS::Texture> texture;
// Source
std::shared_ptr<gfx::SourceTexture> source;
};
class ShaderSource {
obs_source_t* m_source; obs_source_t* m_source;
std::unique_ptr<GS::RenderTarget> m_renderTarget; std::unique_ptr<gs::rendertarget> m_renderTarget;
// Effect Information // Effect Information
struct { struct {
std::unique_ptr<GS::Effect> effect; std::unique_ptr<gs::effect> effect;
std::string text; std::string text;
std::string path; std::string path;
struct { struct {
@ -71,18 +56,6 @@ namespace gfx {
} file_info; } file_info;
} effect; } effect;
struct Parameter {
GS::EffectParameter parameter;
std::vector<char> data_names;
std::vector<char>
struct {
} value;
};
// Status // Status
float_t time_existing; float_t time_existing;
float_t time_active; float_t time_active;
@ -92,8 +65,8 @@ namespace gfx {
static bool property_input_modified(void* priv, obs_properties_t* props, obs_property_t* prop, obs_data_t* sett); static bool property_input_modified(void* priv, obs_properties_t* props, obs_property_t* prop, obs_data_t* sett);
public: public:
ShaderSource(obs_data_t* data, obs_source_t* owner); effect_source(obs_data_t* data, obs_source_t* owner);
~ShaderSource(); ~effect_source();
void get_properties(obs_properties_t* properties); void get_properties(obs_properties_t* properties);
void get_defaults(obs_data_t* data); void get_defaults(obs_data_t* data);
@ -114,7 +87,5 @@ namespace gfx {
Text, Text,
File File
}; };
}; };
} }

View file

@ -17,7 +17,7 @@
#include "gfx-source-texture.h" #include "gfx-source-texture.h"
gfx::SourceTexture::~SourceTexture() { gfx::source_texture::~source_texture() {
if (m_source) { if (m_source) {
obs_source_release(m_source); obs_source_release(m_source);
m_source = nullptr; m_source = nullptr;
@ -25,31 +25,31 @@ gfx::SourceTexture::~SourceTexture() {
m_rt = nullptr; m_rt = nullptr;
} }
gfx::SourceTexture::SourceTexture() { gfx::source_texture::source_texture() {
m_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE); m_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
} }
obs_source_t* gfx::SourceTexture::GetObject() { obs_source_t* gfx::source_texture::get_object() {
return m_source; return m_source;
} }
gfx::SourceTexture::SourceTexture(const char* name) : SourceTexture() { gfx::source_texture::source_texture(const char* name) : source_texture() {
m_source = obs_get_source_by_name(name); m_source = obs_get_source_by_name(name);
if (!m_source) { if (!m_source) {
throw std::invalid_argument("No such source."); throw std::invalid_argument("No such source.");
} }
} }
gfx::SourceTexture::SourceTexture(std::string name) : SourceTexture(name.c_str()) {} gfx::source_texture::source_texture(std::string name) : source_texture(name.c_str()) {}
gfx::SourceTexture::SourceTexture(obs_source_t* src) : SourceTexture() { gfx::source_texture::source_texture(obs_source_t* src) : source_texture() {
m_source = src; m_source = src;
if (!m_source) { if (!m_source) {
throw std::invalid_argument("No such source."); throw std::invalid_argument("No such source.");
} }
} }
std::shared_ptr<gs::texture> gfx::SourceTexture::Render(size_t width, size_t height) { std::shared_ptr<gs::texture> gfx::source_texture::render(size_t width, size_t height) {
if (!m_source) { if (!m_source) {
throw std::invalid_argument("Missing source to render."); throw std::invalid_argument("Missing source to render.");
} }
@ -61,7 +61,7 @@ std::shared_ptr<gs::texture> gfx::SourceTexture::Render(size_t width, size_t hei
} }
{ {
auto op = m_rt->Render((uint32_t)width, (uint32_t)height); auto op = m_rt->render((uint32_t)width, (uint32_t)height);
vec4 black; vec4_zero(&black); vec4 black; vec4_zero(&black);
gs_ortho(0, (float_t)width, 0, (float_t)height, 0, 1); gs_ortho(0, (float_t)width, 0, (float_t)height, 0, 1);
gs_clear(GS_CLEAR_COLOR, &black, 0, 0); gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
@ -69,6 +69,6 @@ std::shared_ptr<gs::texture> gfx::SourceTexture::Render(size_t width, size_t hei
} }
std::shared_ptr<gs::texture> tex; std::shared_ptr<gs::texture> tex;
m_rt->GetTexture(tex); m_rt->get_texture(tex);
return tex; return tex;
} }

View file

@ -23,19 +23,19 @@
#include "gs-rendertarget.h" #include "gs-rendertarget.h"
namespace gfx { namespace gfx {
class SourceTexture { class source_texture {
obs_source_t* m_source; obs_source_t* m_source;
std::shared_ptr<gs::rendertarget> m_rt; std::shared_ptr<gs::rendertarget> m_rt;
SourceTexture(); source_texture();
public: public:
~SourceTexture(); ~source_texture();
SourceTexture(const char* name); source_texture(const char* name);
SourceTexture(std::string name); source_texture(std::string name);
SourceTexture(obs_source_t* src); source_texture(obs_source_t* src);
obs_source_t* GetObject(); obs_source_t* get_object();
std::shared_ptr<gs::texture> Render(size_t width, size_t height); std::shared_ptr<gs::texture> render(size_t width, size_t height);
}; };
} }

View file

@ -261,7 +261,7 @@ void gs::effect_parameter::set_matrix(matrix4& v) {
void gs::effect_parameter::set_texture(std::shared_ptr<gs::texture> v) { void gs::effect_parameter::set_texture(std::shared_ptr<gs::texture> v) {
if (get_type() != type::Texture) if (get_type() != type::Texture)
throw std::bad_cast(); throw std::bad_cast();
gs_effect_set_texture(m_param, v->GetObject()); gs_effect_set_texture(m_param, v->get_object());
} }
void gs::effect_parameter::set_texture(gs_texture_t* v) { void gs::effect_parameter::set_texture(gs_texture_t* v) {
@ -273,7 +273,7 @@ void gs::effect_parameter::set_texture(gs_texture_t* v) {
void gs::effect_parameter::set_sampler(std::shared_ptr<gs::sampler> v) { void gs::effect_parameter::set_sampler(std::shared_ptr<gs::sampler> v) {
if (get_type() != type::Texture) if (get_type() != type::Texture)
throw std::bad_cast(); throw std::bad_cast();
gs_effect_set_next_sampler(m_param, v->GetObject()); gs_effect_set_next_sampler(m_param, v->get_object());
} }
void gs::effect_parameter::set_sampler(gs_sampler_state* v) { void gs::effect_parameter::set_sampler(gs_sampler_state* v) {

View file

@ -216,7 +216,7 @@ uint32_t Source::Mirror::get_width() {
if (m_rescale && m_width > 0 && !m_keepOriginalSize) if (m_rescale && m_width > 0 && !m_keepOriginalSize)
return m_width; return m_width;
if (m_mirrorSource) if (m_mirrorSource)
return obs_source_get_width(m_mirrorSource->GetObject()); return obs_source_get_width(m_mirrorSource->get_object());
return 1; return 1;
} }
@ -224,7 +224,7 @@ uint32_t Source::Mirror::get_height() {
if (m_rescale && m_height > 0 && !m_keepOriginalSize) if (m_rescale && m_height > 0 && !m_keepOriginalSize)
return m_height; return m_height;
if (m_mirrorSource) if (m_mirrorSource)
return obs_source_get_height(m_mirrorSource->GetObject()); return obs_source_get_height(m_mirrorSource->get_object());
return 1; return 1;
} }
@ -233,7 +233,7 @@ void Source::Mirror::update(obs_data_t* data) {
const char* sourceName = obs_data_get_string(data, P_SOURCE); const char* sourceName = obs_data_get_string(data, P_SOURCE);
if (sourceName != m_mirrorName) { if (sourceName != m_mirrorName) {
try { try {
m_mirrorSource = std::make_unique<gfx::SourceTexture>(sourceName); m_mirrorSource = std::make_unique<gfx::source_texture>(sourceName);
m_mirrorName = sourceName; m_mirrorName = sourceName;
} catch (...) { } catch (...) {
} }
@ -275,23 +275,23 @@ void Source::Mirror::update(obs_data_t* data) {
case ScalingMethod::Point: case ScalingMethod::Point:
default: default:
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT); m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
m_sampler->SetSampleFilter(GS_FILTER_POINT); m_sampler->set_filter(GS_FILTER_POINT);
break; break;
case ScalingMethod::Bilinear: case ScalingMethod::Bilinear:
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT); m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
m_sampler->SetSampleFilter(GS_FILTER_LINEAR); m_sampler->set_filter(GS_FILTER_LINEAR);
break; break;
case ScalingMethod::BilinearLowRes: case ScalingMethod::BilinearLowRes:
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_BILINEAR_LOWRES); m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_BILINEAR_LOWRES);
m_sampler->SetSampleFilter(GS_FILTER_LINEAR); m_sampler->set_filter(GS_FILTER_LINEAR);
break; break;
case ScalingMethod::Bicubic: case ScalingMethod::Bicubic:
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_BICUBIC); m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_BICUBIC);
m_sampler->SetSampleFilter(GS_FILTER_LINEAR); m_sampler->set_filter(GS_FILTER_LINEAR);
break; break;
case ScalingMethod::Lanczos: case ScalingMethod::Lanczos:
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_LANCZOS); m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_LANCZOS);
m_sampler->SetSampleFilter(GS_FILTER_LINEAR); m_sampler->set_filter(GS_FILTER_LINEAR);
break; break;
} }
@ -309,7 +309,7 @@ void Source::Mirror::deactivate() {
void Source::Mirror::video_tick(float) { void Source::Mirror::video_tick(float) {
if (m_mirrorSource) if (m_mirrorSource)
m_mirrorName = obs_source_get_name(m_mirrorSource->GetObject()); m_mirrorName = obs_source_get_name(m_mirrorSource->get_object());
} }
void Source::Mirror::video_render(gs_effect_t* effect) { void Source::Mirror::video_render(gs_effect_t* effect) {
@ -319,11 +319,11 @@ void Source::Mirror::video_render(gs_effect_t* effect) {
if (m_rescale && m_width > 0 && m_height > 0 && m_scalingEffect) { if (m_rescale && m_width > 0 && m_height > 0 && m_scalingEffect) {
uint32_t sw, sh; uint32_t sw, sh;
sw = obs_source_get_width(m_mirrorSource->GetObject()); sw = obs_source_get_width(m_mirrorSource->get_object());
sh = obs_source_get_height(m_mirrorSource->GetObject()); sh = obs_source_get_height(m_mirrorSource->get_object());
// Store original Source Texture // Store original Source Texture
std::shared_ptr<gs::texture> tex = m_mirrorSource->Render(sw, sh); std::shared_ptr<gs::texture> tex = m_mirrorSource->render(sw, sh);
gs_eparam_t *scale_param = gs_effect_get_param_by_name(m_scalingEffect, "base_dimension_i"); gs_eparam_t *scale_param = gs_effect_get_param_by_name(m_scalingEffect, "base_dimension_i");
if (scale_param) { if (scale_param) {
@ -342,23 +342,23 @@ void Source::Mirror::video_render(gs_effect_t* effect) {
gs_clear(GS_CLEAR_COLOR, &black, 0, 0); gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
while (gs_effect_loop(m_scalingEffect, "Draw")) { while (gs_effect_loop(m_scalingEffect, "Draw")) {
gs_eparam_t* image = gs_effect_get_param_by_name(m_scalingEffect, "image"); gs_eparam_t* image = gs_effect_get_param_by_name(m_scalingEffect, "image");
gs_effect_set_next_sampler(image, m_sampler->GetObject()); gs_effect_set_next_sampler(image, m_sampler->get_object());
obs_source_draw(tex->GetObject(), 0, 0, m_width, m_height, false); obs_source_draw(tex->get_object(), 0, 0, m_width, m_height, false);
} }
} }
while (gs_effect_loop(obs_get_base_effect(OBS_EFFECT_DEFAULT), "Draw")) { while (gs_effect_loop(obs_get_base_effect(OBS_EFFECT_DEFAULT), "Draw")) {
gs_eparam_t* image = gs_effect_get_param_by_name(obs_get_base_effect(OBS_EFFECT_DEFAULT), "image"); gs_eparam_t* image = gs_effect_get_param_by_name(obs_get_base_effect(OBS_EFFECT_DEFAULT), "image");
gs_effect_set_next_sampler(image, m_sampler->GetObject()); gs_effect_set_next_sampler(image, m_sampler->get_object());
obs_source_draw(m_renderTargetScale->get_object(), 0, 0, sw, sh, false); obs_source_draw(m_renderTargetScale->get_object(), 0, 0, sw, sh, false);
} }
} else { } else {
while (gs_effect_loop(m_scalingEffect, "Draw")) { while (gs_effect_loop(m_scalingEffect, "Draw")) {
gs_eparam_t* image = gs_effect_get_param_by_name(m_scalingEffect, "image"); gs_eparam_t* image = gs_effect_get_param_by_name(m_scalingEffect, "image");
gs_effect_set_next_sampler(image, m_sampler->GetObject()); gs_effect_set_next_sampler(image, m_sampler->get_object());
obs_source_draw(tex->GetObject(), 0, 0, m_width, m_height, false); obs_source_draw(tex->get_object(), 0, 0, m_width, m_height, false);
} }
} }
} else { } else {
obs_source_video_render(m_mirrorSource->GetObject()); obs_source_video_render(m_mirrorSource->get_object());
} }
} }

View file

@ -62,7 +62,7 @@ namespace Source {
std::shared_ptr<gs::sampler> m_sampler; std::shared_ptr<gs::sampler> m_sampler;
gs_effect_t* m_scalingEffect = nullptr; gs_effect_t* m_scalingEffect = nullptr;
std::unique_ptr<gfx::SourceTexture> m_mirrorSource; std::unique_ptr<gfx::source_texture> m_mirrorSource;
std::string m_mirrorName; std::string m_mirrorName;
public: public: