filter-transform: Formatting

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2018-09-28 14:49:59 +02:00
parent b5746e473b
commit 04d7379ff1
2 changed files with 230 additions and 268 deletions

View File

@ -32,13 +32,10 @@ extern "C" {
// Initializer & Finalizer // Initializer & Finalizer
static Filter::Transform* filterTransformInstance; static Filter::Transform* filterTransformInstance;
INITIALIZER(FilterTransformInit) { INITIALIZER(FilterTransformInit)
initializerFunctions.push_back([] { {
filterTransformInstance = new Filter::Transform(); initializerFunctions.push_back([] { filterTransformInstance = new Filter::Transform(); });
}); finalizerFunctions.push_back([] { delete filterTransformInstance; });
finalizerFunctions.push_back([] {
delete filterTransformInstance;
});
} }
#define ST "Filter.Transform" #define ST "Filter.Transform"
@ -72,10 +69,7 @@ static const float farZ = 2097152.0f; // 2 pow 21
static const float nearZ = 1.0f / farZ; static const float nearZ = 1.0f / farZ;
static const float valueLimit = 65536.0f; static const float valueLimit = 65536.0f;
enum class CameraMode : int32_t { enum class CameraMode : int32_t { Orthographic, Perspective };
Orthographic,
Perspective
};
enum RotationOrder : int64_t { enum RotationOrder : int64_t {
XYZ, XYZ,
@ -86,7 +80,8 @@ enum RotationOrder : int64_t {
ZYX, ZYX,
}; };
Filter::Transform::Transform() { Filter::Transform::Transform()
{
memset(&sourceInfo, 0, sizeof(obs_source_info)); memset(&sourceInfo, 0, sizeof(obs_source_info));
sourceInfo.id = "obs-stream-effects-filter-transform"; sourceInfo.id = "obs-stream-effects-filter-transform";
sourceInfo.type = OBS_SOURCE_TYPE_FILTER; sourceInfo.type = OBS_SOURCE_TYPE_FILTER;
@ -108,14 +103,15 @@ Filter::Transform::Transform() {
Filter::Transform::~Transform() {} Filter::Transform::~Transform() {}
const char* Filter::Transform::get_name(void *) { const char* Filter::Transform::get_name(void*)
{
return P_TRANSLATE(ST); return P_TRANSLATE(ST);
} }
void Filter::Transform::get_defaults(obs_data_t *data) { void Filter::Transform::get_defaults(obs_data_t* data)
{
obs_data_set_default_int(data, ST_CAMERA, (int64_t)CameraMode::Orthographic); obs_data_set_default_int(data, ST_CAMERA, (int64_t)CameraMode::Orthographic);
obs_data_set_default_double(data, ST_CAMERA_FIELDOFVIEW, obs_data_set_default_double(data, ST_CAMERA_FIELDOFVIEW, 90.0);
90.0);
obs_data_set_default_double(data, ST_POSITION_X, 0); obs_data_set_default_double(data, ST_POSITION_X, 0);
obs_data_set_default_double(data, ST_POSITION_Y, 0); obs_data_set_default_double(data, ST_POSITION_Y, 0);
obs_data_set_default_double(data, ST_POSITION_Z, 0); obs_data_set_default_double(data, ST_POSITION_Z, 0);
@ -131,23 +127,20 @@ void Filter::Transform::get_defaults(obs_data_t *data) {
RotationOrder::ZXY); //ZXY RotationOrder::ZXY); //ZXY
} }
obs_properties_t * Filter::Transform::get_properties(void *) { obs_properties_t* Filter::Transform::get_properties(void*)
{
obs_properties_t* pr = obs_properties_create(); obs_properties_t* pr = obs_properties_create();
obs_property_t* p = NULL; obs_property_t* p = NULL;
p = obs_properties_add_list(pr, ST_CAMERA, P_TRANSLATE(ST_CAMERA), p = obs_properties_add_list(pr, ST_CAMERA, P_TRANSLATE(ST_CAMERA), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_CAMERA))); obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_CAMERA)));
obs_property_list_add_int(p, P_TRANSLATE(ST_CAMERA_ORTHOGRAPHIC), obs_property_list_add_int(p, P_TRANSLATE(ST_CAMERA_ORTHOGRAPHIC), (int64_t)CameraMode::Orthographic);
(int64_t)CameraMode::Orthographic); obs_property_list_add_int(p, P_TRANSLATE(ST_CAMERA_PERSPECTIVE), (int64_t)CameraMode::Perspective);
obs_property_list_add_int(p, P_TRANSLATE(ST_CAMERA_PERSPECTIVE),
(int64_t)CameraMode::Perspective);
obs_property_set_modified_callback(p, modified_properties); obs_property_set_modified_callback(p, modified_properties);
p = obs_properties_add_float_slider(pr, ST_CAMERA_FIELDOFVIEW, p = obs_properties_add_float_slider(pr, ST_CAMERA_FIELDOFVIEW, P_TRANSLATE(ST_CAMERA_FIELDOFVIEW), 1.0, 179.0,
P_TRANSLATE(ST_CAMERA_FIELDOFVIEW), 1.0, 179.0, 0.01); 0.01);
obs_property_set_long_description(p, obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_CAMERA_FIELDOFVIEW)));
P_TRANSLATE(P_DESC(ST_CAMERA_FIELDOFVIEW)));
// Position, Scale, Rotation // Position, Scale, Rotation
{ {
@ -157,10 +150,8 @@ obs_properties_t * Filter::Transform::get_properties(void *) {
std::make_pair(ST_POSITION_Z, P_DESC(ST_POSITION_Z)), std::make_pair(ST_POSITION_Z, P_DESC(ST_POSITION_Z)),
}; };
for (auto kv : entries) { for (auto kv : entries) {
p = obs_properties_add_float(pr, kv.first, p = obs_properties_add_float(pr, kv.first, P_TRANSLATE(kv.first), -10000, 10000, 0.01);
P_TRANSLATE(kv.first), -10000, 10000, 0.01); obs_property_set_long_description(p, P_TRANSLATE(kv.second));
obs_property_set_long_description(p,
P_TRANSLATE(kv.second));
} }
} }
{ {
@ -170,10 +161,8 @@ obs_properties_t * Filter::Transform::get_properties(void *) {
std::make_pair(ST_ROTATION_Z, P_DESC(ST_ROTATION_Z)), std::make_pair(ST_ROTATION_Z, P_DESC(ST_ROTATION_Z)),
}; };
for (auto kv : entries) { for (auto kv : entries) {
p = obs_properties_add_float_slider(pr, kv.first, p = obs_properties_add_float_slider(pr, kv.first, P_TRANSLATE(kv.first), -180, 180, 0.01);
P_TRANSLATE(kv.first), -180, 180, 0.01); obs_property_set_long_description(p, P_TRANSLATE(kv.second));
obs_property_set_long_description(p,
P_TRANSLATE(kv.second));
} }
} }
{ {
@ -182,10 +171,8 @@ obs_properties_t * Filter::Transform::get_properties(void *) {
std::make_pair(ST_SCALE_Y, P_DESC(ST_SCALE_Y)), std::make_pair(ST_SCALE_Y, P_DESC(ST_SCALE_Y)),
}; };
for (auto kv : entries) { for (auto kv : entries) {
p = obs_properties_add_float_slider(pr, kv.first, p = obs_properties_add_float_slider(pr, kv.first, P_TRANSLATE(kv.first), -1000, 1000, 0.01);
P_TRANSLATE(kv.first), -1000, 1000, 0.01); obs_property_set_long_description(p, P_TRANSLATE(kv.second));
obs_property_set_long_description(p,
P_TRANSLATE(kv.second));
} }
} }
{ {
@ -194,104 +181,96 @@ obs_properties_t * Filter::Transform::get_properties(void *) {
std::make_pair(ST_SHEAR_Y, P_DESC(ST_SHEAR_Y)), std::make_pair(ST_SHEAR_Y, P_DESC(ST_SHEAR_Y)),
}; };
for (auto kv : entries) { for (auto kv : entries) {
p = obs_properties_add_float_slider(pr, kv.first, p = obs_properties_add_float_slider(pr, kv.first, P_TRANSLATE(kv.first), -100.0, 100.0, 0.01);
P_TRANSLATE(kv.first), -100.0, 100.0, 0.01); obs_property_set_long_description(p, P_TRANSLATE(kv.second));
obs_property_set_long_description(p,
P_TRANSLATE(kv.second));
} }
} }
p = obs_properties_add_bool(pr, S_ADVANCED, P_TRANSLATE(S_ADVANCED)); p = obs_properties_add_bool(pr, S_ADVANCED, P_TRANSLATE(S_ADVANCED));
obs_property_set_modified_callback(p, modified_properties); obs_property_set_modified_callback(p, modified_properties);
p = obs_properties_add_list(pr, ST_ROTATION_ORDER, p = obs_properties_add_list(pr, ST_ROTATION_ORDER, P_TRANSLATE(ST_ROTATION_ORDER), OBS_COMBO_TYPE_LIST,
P_TRANSLATE(ST_ROTATION_ORDER), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_INT); OBS_COMBO_FORMAT_INT);
obs_property_set_long_description(p, obs_property_set_long_description(p, P_TRANSLATE(P_DESC(ST_ROTATION_ORDER)));
P_TRANSLATE(P_DESC(ST_ROTATION_ORDER))); obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_XYZ), RotationOrder::XYZ);
obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_XYZ), obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_XZY), RotationOrder::XZY);
RotationOrder::XYZ); obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_YXZ), RotationOrder::YXZ);
obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_XZY), obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_YZX), RotationOrder::YZX);
RotationOrder::XZY); obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_ZXY), RotationOrder::ZXY);
obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_YXZ), obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_ZYX), RotationOrder::ZYX);
RotationOrder::YXZ);
obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_YZX),
RotationOrder::YZX);
obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_ZXY),
RotationOrder::ZXY);
obs_property_list_add_int(p, P_TRANSLATE(ST_ROTATION_ORDER_ZYX),
RotationOrder::ZYX);
return pr; return pr;
} }
bool Filter::Transform::modified_properties(obs_properties_t *pr, bool Filter::Transform::modified_properties(obs_properties_t* pr, obs_property_t*, obs_data_t* d)
obs_property_t *, obs_data_t *d) { {
switch ((CameraMode)obs_data_get_int(d, ST_CAMERA)) { switch ((CameraMode)obs_data_get_int(d, ST_CAMERA)) {
case CameraMode::Orthographic: case CameraMode::Orthographic:
obs_property_set_visible(obs_properties_get(pr, obs_property_set_visible(obs_properties_get(pr, ST_CAMERA_FIELDOFVIEW), false);
ST_CAMERA_FIELDOFVIEW), false); obs_property_set_visible(obs_properties_get(pr, ST_POSITION_Z), false);
obs_property_set_visible(obs_properties_get(pr,
ST_POSITION_Z), false);
break; break;
case CameraMode::Perspective: case CameraMode::Perspective:
obs_property_set_visible(obs_properties_get(pr, obs_property_set_visible(obs_properties_get(pr, ST_CAMERA_FIELDOFVIEW), true);
ST_CAMERA_FIELDOFVIEW), true); obs_property_set_visible(obs_properties_get(pr, ST_POSITION_Z), true);
obs_property_set_visible(obs_properties_get(pr,
ST_POSITION_Z), true);
break; break;
} }
bool advancedVisible = obs_data_get_bool(d, S_ADVANCED); bool advancedVisible = obs_data_get_bool(d, S_ADVANCED);
obs_property_set_visible(obs_properties_get(pr, obs_property_set_visible(obs_properties_get(pr, ST_ROTATION_ORDER), advancedVisible);
ST_ROTATION_ORDER), advancedVisible);
return true; return true;
} }
void * Filter::Transform::create(obs_data_t *data, obs_source_t *source) { void* Filter::Transform::create(obs_data_t* data, obs_source_t* source)
{
return new Instance(data, source); return new Instance(data, source);
} }
void Filter::Transform::destroy(void *ptr) { void Filter::Transform::destroy(void* ptr)
{
delete reinterpret_cast<Instance*>(ptr); delete reinterpret_cast<Instance*>(ptr);
} }
uint32_t Filter::Transform::get_width(void *ptr) { uint32_t Filter::Transform::get_width(void* ptr)
{
return reinterpret_cast<Instance*>(ptr)->get_width(); return reinterpret_cast<Instance*>(ptr)->get_width();
} }
uint32_t Filter::Transform::get_height(void *ptr) { uint32_t Filter::Transform::get_height(void* ptr)
{
return reinterpret_cast<Instance*>(ptr)->get_height(); return reinterpret_cast<Instance*>(ptr)->get_height();
} }
void Filter::Transform::update(void *ptr, obs_data_t *data) { void Filter::Transform::update(void* ptr, obs_data_t* data)
{
reinterpret_cast<Instance*>(ptr)->update(data); reinterpret_cast<Instance*>(ptr)->update(data);
} }
void Filter::Transform::activate(void *ptr) { void Filter::Transform::activate(void* ptr)
{
reinterpret_cast<Instance*>(ptr)->activate(); reinterpret_cast<Instance*>(ptr)->activate();
} }
void Filter::Transform::deactivate(void *ptr) { void Filter::Transform::deactivate(void* ptr)
{
reinterpret_cast<Instance*>(ptr)->deactivate(); reinterpret_cast<Instance*>(ptr)->deactivate();
} }
void Filter::Transform::video_tick(void *ptr, float time) { void Filter::Transform::video_tick(void* ptr, float time)
{
reinterpret_cast<Instance*>(ptr)->video_tick(time); reinterpret_cast<Instance*>(ptr)->video_tick(time);
} }
void Filter::Transform::video_render(void *ptr, gs_effect_t *effect) { void Filter::Transform::video_render(void* ptr, gs_effect_t* effect)
{
reinterpret_cast<Instance*>(ptr)->video_render(effect); reinterpret_cast<Instance*>(ptr)->video_render(effect);
} }
Filter::Transform::Instance::Instance(obs_data_t *data, obs_source_t *context) : Filter::Transform::Instance::Instance(obs_data_t* data, obs_source_t* context)
m_sourceContext(context), m_vertexHelper(nullptr), : m_sourceContext(context), m_vertexHelper(nullptr), m_vertexBuffer(nullptr), m_texRender(nullptr),
m_vertexBuffer(nullptr), m_texRender(nullptr), m_shapeRender(nullptr), m_shapeRender(nullptr), m_isCameraOrthographic(true), m_cameraFieldOfView(90.0), m_isInactive(false),
m_isCameraOrthographic(true), m_cameraFieldOfView(90.0), m_isHidden(false), m_isMeshUpdateRequired(false), m_rotationOrder(RotationOrder::ZXY)
m_isInactive(false), m_isHidden(false), m_isMeshUpdateRequired(false), {
m_rotationOrder(RotationOrder::ZXY) {
m_position = std::make_unique<util::vec3a>(); m_position = std::make_unique<util::vec3a>();
m_rotation = std::make_unique<util::vec3a>(); m_rotation = std::make_unique<util::vec3a>();
m_scale = std::make_unique<util::vec3a>(); m_scale = std::make_unique<util::vec3a>();
@ -312,7 +291,8 @@ Filter::Transform::Instance::Instance(obs_data_t *data, obs_source_t *context) :
update(data); update(data);
} }
Filter::Transform::Instance::~Instance() { Filter::Transform::Instance::~Instance()
{
obs_enter_graphics(); obs_enter_graphics();
delete m_vertexHelper; delete m_vertexHelper;
gs_texrender_destroy(m_texRender); gs_texrender_destroy(m_texRender);
@ -320,11 +300,11 @@ Filter::Transform::Instance::~Instance() {
obs_leave_graphics(); obs_leave_graphics();
} }
void Filter::Transform::Instance::update(obs_data_t *data) { void Filter::Transform::Instance::update(obs_data_t* data)
{
// Camera // Camera
m_isCameraOrthographic = obs_data_get_int(data, ST_CAMERA) == 0; m_isCameraOrthographic = obs_data_get_int(data, ST_CAMERA) == 0;
m_cameraFieldOfView = (float)obs_data_get_double(data, m_cameraFieldOfView = (float)obs_data_get_double(data, ST_CAMERA_FIELDOFVIEW);
ST_CAMERA_FIELDOFVIEW);
// Source // Source
m_position->x = (float)obs_data_get_double(data, ST_POSITION_X) / 100.0f; m_position->x = (float)obs_data_get_double(data, ST_POSITION_X) / 100.0f;
@ -343,36 +323,37 @@ void Filter::Transform::Instance::update(obs_data_t *data) {
m_isMeshUpdateRequired = true; m_isMeshUpdateRequired = true;
} }
uint32_t Filter::Transform::Instance::get_width() { uint32_t Filter::Transform::Instance::get_width()
{
return 0; return 0;
} }
uint32_t Filter::Transform::Instance::get_height() { uint32_t Filter::Transform::Instance::get_height()
{
return 0; return 0;
} }
void Filter::Transform::Instance::activate() { void Filter::Transform::Instance::activate()
{
m_isInactive = false; m_isInactive = false;
} }
void Filter::Transform::Instance::deactivate() { void Filter::Transform::Instance::deactivate()
{
m_isInactive = true; m_isInactive = true;
} }
void Filter::Transform::Instance::video_tick(float) {} void Filter::Transform::Instance::video_tick(float) {}
void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) { void Filter::Transform::Instance::video_render(gs_effect_t* paramEffect)
{
obs_source_t* parent = obs_filter_get_parent(m_sourceContext); obs_source_t* parent = obs_filter_get_parent(m_sourceContext);
obs_source_t* target = obs_filter_get_target(m_sourceContext); obs_source_t* target = obs_filter_get_target(m_sourceContext);
uint32_t uint32_t baseW = obs_source_get_base_width(target), baseH = obs_source_get_base_height(target);
baseW = obs_source_get_base_width(target),
baseH = obs_source_get_base_height(target);
// 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_sourceContext if (!target || !parent || !m_sourceContext || !baseW || !baseH || !m_texRender || !m_shapeRender || m_isInactive
|| !baseW || !baseH || m_isHidden) {
|| !m_texRender || !m_shapeRender
|| m_isInactive || m_isHidden) {
obs_source_skip_video_filter(m_sourceContext); obs_source_skip_video_filter(m_sourceContext);
return; return;
} }
@ -393,10 +374,7 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &black, 0, 0); gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &black, 0, 0);
gs_set_cull_mode(GS_NEITHER); gs_set_cull_mode(GS_NEITHER);
gs_reset_blend_state(); gs_reset_blend_state();
gs_blend_function_separate( gs_blend_function_separate(gs_blend_type::GS_BLEND_ONE, gs_blend_type::GS_BLEND_ZERO, gs_blend_type::GS_BLEND_ONE,
gs_blend_type::GS_BLEND_ONE,
gs_blend_type::GS_BLEND_ZERO,
gs_blend_type::GS_BLEND_ONE,
gs_blend_type::GS_BLEND_ZERO); gs_blend_type::GS_BLEND_ZERO);
gs_enable_depth_test(false); gs_enable_depth_test(false);
gs_enable_stencil_test(false); gs_enable_stencil_test(false);
@ -404,11 +382,8 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
gs_enable_color(true, true, true, true); gs_enable_color(true, true, true, true);
/// Render original source /// Render original source
if (obs_source_process_filter_begin(m_sourceContext, GS_RGBA, if (obs_source_process_filter_begin(m_sourceContext, GS_RGBA, OBS_NO_DIRECT_RENDERING)) {
OBS_NO_DIRECT_RENDERING)) { obs_source_process_filter_end(m_sourceContext, paramEffect ? paramEffect : alphaEffect, baseW, baseH);
obs_source_process_filter_end(m_sourceContext,
paramEffect ? paramEffect : alphaEffect,
baseW, baseH);
} else { } else {
obs_source_skip_video_filter(m_sourceContext); obs_source_skip_video_filter(m_sourceContext);
} }
@ -468,36 +443,28 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
gs::vertex vtx = m_vertexHelper->at(0); gs::vertex vtx = m_vertexHelper->at(0);
*vtx.color = 0xFFFFFFFF; *vtx.color = 0xFFFFFFFF;
vec4_set(vtx.uv[0], 0, 0, 0, 0); vec4_set(vtx.uv[0], 0, 0, 0, 0);
vec3_set(vtx.position, vec3_set(vtx.position, -p_x + m_shear->x, -p_y - m_shear->y, 0);
-p_x + m_shear->x,
-p_y - m_shear->y, 0);
vec3_transform(vtx.position, vtx.position, &ident); vec3_transform(vtx.position, vtx.position, &ident);
} }
{ {
gs::vertex vtx = m_vertexHelper->at(1); gs::vertex vtx = m_vertexHelper->at(1);
*vtx.color = 0xFFFFFFFF; *vtx.color = 0xFFFFFFFF;
vec4_set(vtx.uv[0], 1, 0, 0, 0); vec4_set(vtx.uv[0], 1, 0, 0, 0);
vec3_set(vtx.position, vec3_set(vtx.position, p_x + m_shear->x, -p_y + m_shear->y, 0);
p_x + m_shear->x,
-p_y + m_shear->y, 0);
vec3_transform(vtx.position, vtx.position, &ident); vec3_transform(vtx.position, vtx.position, &ident);
} }
{ {
gs::vertex vtx = m_vertexHelper->at(2); gs::vertex vtx = m_vertexHelper->at(2);
*vtx.color = 0xFFFFFFFF; *vtx.color = 0xFFFFFFFF;
vec4_set(vtx.uv[0], 0, 1, 0, 0); vec4_set(vtx.uv[0], 0, 1, 0, 0);
vec3_set(vtx.position, vec3_set(vtx.position, -p_x - m_shear->x, p_y - m_shear->y, 0);
-p_x - m_shear->x,
p_y - m_shear->y, 0);
vec3_transform(vtx.position, vtx.position, &ident); vec3_transform(vtx.position, vtx.position, &ident);
} }
{ {
gs::vertex vtx = m_vertexHelper->at(3); gs::vertex vtx = m_vertexHelper->at(3);
*vtx.color = 0xFFFFFFFF; *vtx.color = 0xFFFFFFFF;
vec4_set(vtx.uv[0], 1, 1, 0, 0); vec4_set(vtx.uv[0], 1, 1, 0, 0);
vec3_set(vtx.position, vec3_set(vtx.position, p_x - m_shear->x, p_y + m_shear->y, 0);
p_x - m_shear->x,
p_y + m_shear->y, 0);
vec3_transform(vtx.position, vtx.position, &ident); vec3_transform(vtx.position, vtx.position, &ident);
} }
@ -515,8 +482,7 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
if (m_isCameraOrthographic) { if (m_isCameraOrthographic) {
gs_ortho(-1.0, 1.0, -1.0, 1.0, -farZ, farZ); gs_ortho(-1.0, 1.0, -1.0, 1.0, -farZ, farZ);
} else { } else {
gs_perspective(m_cameraFieldOfView, gs_perspective(m_cameraFieldOfView, float_t(baseW) / float_t(baseH), nearZ, farZ);
float_t(baseW) / float_t(baseH), nearZ, farZ);
// Fix camera pointing at -Z instead of +Z. // Fix camera pointing at -Z instead of +Z.
gs_matrix_scale3f(1.0, 1.0, -1.0); gs_matrix_scale3f(1.0, 1.0, -1.0);
// Move backwards so we can actually see stuff. // Move backwards so we can actually see stuff.
@ -535,9 +501,7 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
gs_enable_stencil_write(false); gs_enable_stencil_write(false);
gs_enable_color(true, true, true, true); gs_enable_color(true, true, true, true);
while (gs_effect_loop(alphaEffect, "Draw")) { while (gs_effect_loop(alphaEffect, "Draw")) {
gs_effect_set_texture( gs_effect_set_texture(gs_effect_get_param_by_name(alphaEffect, "image"), filterTexture);
gs_effect_get_param_by_name(alphaEffect,
"image"), filterTexture);
gs_load_vertexbuffer(m_vertexBuffer); gs_load_vertexbuffer(m_vertexBuffer);
gs_load_indexbuffer(NULL); gs_load_indexbuffer(NULL);
gs_draw(GS_TRISTRIP, 0, 4); gs_draw(GS_TRISTRIP, 0, 4);
@ -554,8 +518,7 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
gs_reset_blend_state(); gs_reset_blend_state();
gs_enable_depth_test(false); gs_enable_depth_test(false);
while (gs_effect_loop(alphaEffect, "Draw")) { while (gs_effect_loop(alphaEffect, "Draw")) {
gs_effect_set_texture(gs_effect_get_param_by_name(alphaEffect, gs_effect_set_texture(gs_effect_get_param_by_name(alphaEffect, "image"), shapeTexture);
"image"), shapeTexture);
gs_draw_sprite(shapeTexture, 0, 0, 0); gs_draw_sprite(shapeTexture, 0, 0, 0);
} }
} }

View File

@ -18,9 +18,9 @@
*/ */
#pragma once #pragma once
#include "plugin.h"
#include "gs-vertexbuffer.h"
#include <memory> #include <memory>
#include "gs-vertexbuffer.h"
#include "plugin.h"
namespace Filter { namespace Filter {
class Transform { class Transform {
@ -31,8 +31,7 @@ namespace Filter {
static const char* get_name(void*); static const char* get_name(void*);
static void get_defaults(obs_data_t*); static void get_defaults(obs_data_t*);
static obs_properties_t* get_properties(void*); static obs_properties_t* get_properties(void*);
static bool modified_properties(obs_properties_t *, static bool modified_properties(obs_properties_t*, obs_property_t*, obs_data_t*);
obs_property_t *, obs_data_t *);
static void* create(obs_data_t*, obs_source_t*); static void* create(obs_data_t*, obs_source_t*);
static void destroy(void*); static void destroy(void*);
@ -87,4 +86,4 @@ namespace Filter {
}; };
}; };
}; };
} } // namespace Filter