2023-02-28 01:15:26 +00:00
|
|
|
// AUTOGENERATED COPYRIGHT HEADER START
|
|
|
|
// Copyright (C) 2019-2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
|
|
|
// Copyright (C) 2022 lainon <GermanAizek@yandex.ru>
|
|
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
2019-12-15 08:05:23 +00:00
|
|
|
|
|
|
|
#include "gs-effect-technique.hpp"
|
2022-08-29 10:29:44 +00:00
|
|
|
|
|
|
|
#include "warning-disable.hpp"
|
2019-12-15 08:05:23 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <stdexcept>
|
2022-08-29 10:29:44 +00:00
|
|
|
#include "warning-enable.hpp"
|
2019-12-15 08:05:23 +00:00
|
|
|
|
2020-04-02 18:29:00 +00:00
|
|
|
extern "C" {
|
2022-08-29 10:29:44 +00:00
|
|
|
#include "warning-disable.hpp"
|
2019-12-15 08:05:23 +00:00
|
|
|
#include <graphics/effect.h>
|
2022-08-29 10:29:44 +00:00
|
|
|
#include "warning-enable.hpp"
|
2020-04-02 18:29:00 +00:00
|
|
|
}
|
2019-12-15 08:05:23 +00:00
|
|
|
|
2023-05-13 12:35:46 +00:00
|
|
|
streamfx::obs::gs::effect_technique::effect_technique(gs_technique_t* technique, std::shared_ptr<gs_effect_t> parent) : _parent(parent)
|
2019-12-15 08:05:23 +00:00
|
|
|
{
|
|
|
|
reset(technique, [](void*) {});
|
|
|
|
}
|
|
|
|
|
2022-07-21 11:09:10 +00:00
|
|
|
streamfx::obs::gs::effect_technique::~effect_technique() = default;
|
2019-12-15 08:05:23 +00:00
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
std::string streamfx::obs::gs::effect_technique::name()
|
2019-12-15 08:05:23 +00:00
|
|
|
{
|
2019-12-21 16:04:38 +00:00
|
|
|
const char* name_c = get()->name;
|
2020-04-08 21:38:42 +00:00
|
|
|
std::size_t name_len = strnlen(name_c, 256);
|
2019-12-18 05:35:06 +00:00
|
|
|
return name_c ? std::string(name_c, name_c + name_len) : std::string();
|
2019-12-15 08:05:23 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
std::size_t streamfx::obs::gs::effect_technique::count_passes()
|
2019-12-15 08:05:23 +00:00
|
|
|
{
|
|
|
|
return static_cast<size_t>(get()->passes.num);
|
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
streamfx::obs::gs::effect_pass streamfx::obs::gs::effect_technique::get_pass(std::size_t idx)
|
2019-12-15 08:05:23 +00:00
|
|
|
{
|
|
|
|
if (idx >= get()->passes.num) {
|
2019-12-15 09:37:57 +00:00
|
|
|
return nullptr;
|
2019-12-15 08:05:23 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
return streamfx::obs::gs::effect_pass(get()->passes.array + idx, *this);
|
2019-12-15 08:05:23 +00:00
|
|
|
}
|
|
|
|
|
2022-07-21 11:09:10 +00:00
|
|
|
streamfx::obs::gs::effect_pass streamfx::obs::gs::effect_technique::get_pass(std::string_view name)
|
2019-12-15 08:05:23 +00:00
|
|
|
{
|
2020-04-08 21:38:42 +00:00
|
|
|
for (std::size_t idx = 0; idx < get()->passes.num; idx++) {
|
2019-12-15 08:05:23 +00:00
|
|
|
auto ptr = get()->passes.array + idx;
|
2022-07-21 11:09:10 +00:00
|
|
|
if (strcmp(ptr->name, name.data()) == 0)
|
2021-06-08 02:38:24 +00:00
|
|
|
return streamfx::obs::gs::effect_pass(ptr, *this);
|
2019-12-15 08:05:23 +00:00
|
|
|
}
|
|
|
|
|
2019-12-15 09:37:57 +00:00
|
|
|
return nullptr;
|
2019-12-15 08:05:23 +00:00
|
|
|
}
|
|
|
|
|
2022-07-21 11:09:10 +00:00
|
|
|
bool streamfx::obs::gs::effect_technique::has_pass(std::string_view name)
|
2019-12-15 08:05:23 +00:00
|
|
|
{
|
2019-12-15 10:39:57 +00:00
|
|
|
if (get_pass(name) != nullptr)
|
|
|
|
return true;
|
2019-12-15 08:05:23 +00:00
|
|
|
return false;
|
|
|
|
}
|