2019-12-18 05:37:38 +00:00
|
|
|
// 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
|
|
|
|
|
|
|
|
#pragma once
|
2020-04-02 15:02:01 +00:00
|
|
|
#include "common.hpp"
|
2019-12-25 09:09:56 +00:00
|
|
|
#include <vector>
|
2019-12-18 05:37:38 +00:00
|
|
|
#include "gfx-shader-param.hpp"
|
|
|
|
#include "obs/gs/gs-effect-parameter.hpp"
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
namespace streamfx::gfx {
|
2019-12-18 05:37:38 +00:00
|
|
|
namespace shader {
|
2019-12-25 09:09:56 +00:00
|
|
|
enum class basic_field_type {
|
|
|
|
Input,
|
|
|
|
Slider,
|
|
|
|
Enum,
|
|
|
|
};
|
|
|
|
|
|
|
|
basic_field_type get_field_type_from_string(std::string v);
|
|
|
|
|
|
|
|
struct basic_data {
|
|
|
|
union {
|
2020-08-10 01:29:05 +00:00
|
|
|
int32_t i32;
|
|
|
|
uint32_t ui32;
|
|
|
|
float_t f32;
|
2019-12-25 09:09:56 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct basic_enum_data {
|
|
|
|
std::string name;
|
|
|
|
basic_data data;
|
|
|
|
};
|
|
|
|
|
2020-05-13 06:43:37 +00:00
|
|
|
class basic_parameter : public parameter {
|
2019-12-25 09:09:56 +00:00
|
|
|
// Descriptor
|
|
|
|
basic_field_type _field_type;
|
|
|
|
std::string _suffix;
|
|
|
|
std::vector<std::string> _keys;
|
|
|
|
std::vector<std::string> _names;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Limits
|
|
|
|
std::vector<basic_data> _min;
|
|
|
|
std::vector<basic_data> _max;
|
|
|
|
std::vector<basic_data> _step;
|
|
|
|
std::vector<basic_data> _scale;
|
|
|
|
|
|
|
|
// Enumeration Information
|
2020-05-13 06:43:37 +00:00
|
|
|
std::list<basic_enum_data> _values;
|
2019-12-25 09:09:56 +00:00
|
|
|
|
|
|
|
public:
|
2021-11-25 04:57:37 +00:00
|
|
|
basic_parameter(streamfx::gfx::shader::shader* parent, streamfx::obs::gs::effect_parameter param,
|
|
|
|
std::string prefix);
|
2019-12-25 09:09:56 +00:00
|
|
|
virtual ~basic_parameter();
|
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
virtual void load_parameter_data(streamfx::obs::gs::effect_parameter parameter, basic_data& data);
|
2019-12-25 09:09:56 +00:00
|
|
|
|
|
|
|
public:
|
2020-05-13 06:43:37 +00:00
|
|
|
inline basic_field_type field_type()
|
|
|
|
{
|
|
|
|
return _field_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::string_view suffix()
|
|
|
|
{
|
|
|
|
return _suffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::string_view key_at(std::size_t idx)
|
|
|
|
{
|
|
|
|
if (idx >= get_size())
|
|
|
|
throw std::out_of_range("Index out of range.");
|
|
|
|
return _keys[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::string_view name_at(std::size_t idx)
|
|
|
|
{
|
|
|
|
if (idx >= get_size())
|
|
|
|
throw std::out_of_range("Index out of range.");
|
|
|
|
return _names[idx];
|
|
|
|
}
|
2019-12-25 09:09:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct bool_parameter : public basic_parameter {
|
|
|
|
// std::vector<bool> doesn't allow .data()
|
2020-08-10 01:29:05 +00:00
|
|
|
std::vector<int32_t> _data;
|
2019-12-18 05:37:38 +00:00
|
|
|
|
|
|
|
public:
|
2021-11-25 04:57:37 +00:00
|
|
|
bool_parameter(streamfx::gfx::shader::shader* parent, streamfx::obs::gs::effect_parameter param,
|
|
|
|
std::string prefix);
|
2019-12-18 05:37:38 +00:00
|
|
|
virtual ~bool_parameter();
|
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void defaults(obs_data_t* settings) override;
|
2019-12-22 05:07:54 +00:00
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void properties(obs_properties_t* props, obs_data_t* settings) override;
|
2019-12-18 05:37:38 +00:00
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void update(obs_data_t* settings) override;
|
2019-12-18 05:37:38 +00:00
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void assign() override;
|
2019-12-18 05:37:38 +00:00
|
|
|
};
|
|
|
|
|
2019-12-25 09:09:56 +00:00
|
|
|
struct float_parameter : public basic_parameter {
|
|
|
|
std::vector<basic_data> _data;
|
2019-12-18 05:37:38 +00:00
|
|
|
|
|
|
|
public:
|
2021-11-25 04:57:37 +00:00
|
|
|
float_parameter(streamfx::gfx::shader::shader* parent, streamfx::obs::gs::effect_parameter param,
|
|
|
|
std::string prefix);
|
2019-12-18 05:37:38 +00:00
|
|
|
virtual ~float_parameter();
|
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void defaults(obs_data_t* settings) override;
|
2019-12-22 05:07:54 +00:00
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void properties(obs_properties_t* props, obs_data_t* settings) override;
|
2019-12-18 05:37:38 +00:00
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void update(obs_data_t* settings) override;
|
2019-12-18 05:37:38 +00:00
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void assign() override;
|
2019-12-18 05:37:38 +00:00
|
|
|
};
|
|
|
|
|
2019-12-25 09:09:56 +00:00
|
|
|
struct int_parameter : public basic_parameter {
|
|
|
|
std::vector<basic_data> _data;
|
|
|
|
|
2019-12-18 05:37:38 +00:00
|
|
|
public:
|
2021-11-25 04:57:37 +00:00
|
|
|
int_parameter(streamfx::gfx::shader::shader* parent, streamfx::obs::gs::effect_parameter param,
|
|
|
|
std::string prefix);
|
2019-12-18 05:37:38 +00:00
|
|
|
virtual ~int_parameter();
|
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void defaults(obs_data_t* settings) override;
|
2019-12-25 18:10:01 +00:00
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void properties(obs_properties_t* props, obs_data_t* settings) override;
|
2019-12-25 18:10:01 +00:00
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void update(obs_data_t* settings) override;
|
2019-12-25 18:10:01 +00:00
|
|
|
|
2020-07-12 16:41:50 +00:00
|
|
|
void assign() override;
|
2019-12-18 05:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace shader
|
2021-06-08 02:47:04 +00:00
|
|
|
} // namespace streamfx::gfx
|