obs-StreamFX/source/obs/gs/gs-effect-technique.cpp
Michael Fabian 'Xaymar' Dirks b54e95527a gs-effect*: Finish up refactoring onto std::shared_ptr
This is most likely not the last refactor, the entire obs/gs stuff is very very basic right now and likely needs a complete rewrite.
2019-12-15 12:55:19 +01:00

69 lines
1.9 KiB
C++

/*
* Modern effects for a modern Streamer
* Copyright (C) 2019 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
*/
#include "gs-effect-technique.hpp"
#include <cstring>
#include <stdexcept>
#include <graphics/effect.h>
gs::effect_technique::effect_technique(gs_technique_t* technique, std::shared_ptr<gs_effect_t>* parent)
: _parent(parent)
{
reset(technique, [](void*) {});
}
gs::effect_technique::~effect_technique() {}
std::string gs::effect_technique::name()
{
return std::string(get()->name, get()->name + strnlen_s(get()->name, 256));
}
size_t gs::effect_technique::count_passes()
{
return static_cast<size_t>(get()->passes.num);
}
gs::effect_pass gs::effect_technique::get_pass(size_t idx)
{
if (idx >= get()->passes.num) {
return nullptr;
}
return gs::effect_pass(get()->passes.array + idx, this);
}
gs::effect_pass gs::effect_technique::get_pass(std::string name)
{
for (size_t idx = 0; idx < get()->passes.num; idx++) {
auto ptr = get()->passes.array + idx;
if (strcmp(ptr->name, name.c_str()) == 0)
return gs::effect_pass(ptr, this);
}
return nullptr;
}
bool gs::effect_technique::has_pass(std::string name)
{
if (get_pass(name) != nullptr)
return true;
return false;
}