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) 2021 coolsoft.rf <coolsoft.rf@gmail.com>
|
|
|
|
// Copyright (C) 2022 lainon <GermanAizek@yandex.ru>
|
|
|
|
// AUTOGENERATED COPYRIGHT HEADER END
|
2019-12-18 05:37:38 +00:00
|
|
|
|
|
|
|
#include "gfx-shader-param.hpp"
|
|
|
|
#include "gfx-shader-param-basic.hpp"
|
2021-11-25 20:11:59 +00:00
|
|
|
#include "gfx-shader-param-texture.hpp"
|
2019-12-18 05:37:38 +00:00
|
|
|
|
2022-08-29 10:29:44 +00:00
|
|
|
#include "warning-disable.hpp"
|
|
|
|
#include <algorithm>
|
|
|
|
#include <sstream>
|
|
|
|
#include "warning-enable.hpp"
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
#define ST_ANNO_ORDER "order"
|
|
|
|
#define ST_ANNO_VISIBILITY "visible"
|
|
|
|
#define ST_ANNO_AUTOMATIC "automatic"
|
|
|
|
#define ST_ANNO_NAME "name"
|
|
|
|
#define ST_ANNO_DESCRIPTION "description"
|
|
|
|
#define ST_ANNO_TYPE "type"
|
|
|
|
#define ST_ANNO_SIZE "size"
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
|
2021-06-08 02:38:24 +00:00
|
|
|
typedef streamfx::obs::gs::effect_parameter::type eptype;
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
streamfx::gfx::shader::parameter_type
|
|
|
|
streamfx::gfx::shader::get_type_from_effect_type(streamfx::obs::gs::effect_parameter::type type)
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case eptype::Boolean:
|
|
|
|
return parameter_type::Boolean;
|
|
|
|
case eptype::Integer:
|
|
|
|
case eptype::Integer2:
|
|
|
|
case eptype::Integer3:
|
|
|
|
case eptype::Integer4:
|
|
|
|
return parameter_type::Integer;
|
|
|
|
case eptype::Float:
|
|
|
|
case eptype::Float2:
|
|
|
|
case eptype::Float3:
|
|
|
|
case eptype::Float4:
|
|
|
|
case eptype::Matrix:
|
|
|
|
return parameter_type::Float;
|
|
|
|
case eptype::String:
|
|
|
|
return parameter_type::String;
|
|
|
|
case eptype::Texture:
|
|
|
|
return parameter_type::Texture;
|
|
|
|
default:
|
|
|
|
return parameter_type::Unknown;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
std::size_t streamfx::gfx::shader::get_length_from_effect_type(streamfx::obs::gs::effect_parameter::type type)
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
{
|
|
|
|
switch (type) {
|
2019-12-25 09:09:56 +00:00
|
|
|
default:
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
case eptype::Unknown:
|
|
|
|
case eptype::Invalid:
|
|
|
|
case eptype::String:
|
|
|
|
return 0;
|
|
|
|
case eptype::Boolean:
|
|
|
|
case eptype::Float:
|
|
|
|
case eptype::Integer:
|
|
|
|
case eptype::Texture:
|
|
|
|
return 1;
|
|
|
|
case eptype::Float2:
|
|
|
|
case eptype::Integer2:
|
|
|
|
return 2;
|
|
|
|
case eptype::Float3:
|
|
|
|
case eptype::Integer3:
|
|
|
|
return 3;
|
|
|
|
case eptype::Float4:
|
|
|
|
case eptype::Integer4:
|
|
|
|
return 4;
|
|
|
|
case eptype::Matrix:
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-21 11:09:10 +00:00
|
|
|
streamfx::gfx::shader::parameter_type streamfx::gfx::shader::get_type_from_string(std::string_view v)
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
{
|
|
|
|
if ((v == "bool") || (v == "boolean")) {
|
|
|
|
return parameter_type::Boolean;
|
|
|
|
}
|
|
|
|
if ((v == "float") || (v == "single")) {
|
|
|
|
return parameter_type::Float;
|
|
|
|
}
|
|
|
|
if ((v == "int") || (v == "integer")) {
|
|
|
|
return parameter_type::Integer;
|
|
|
|
}
|
|
|
|
if ((v == "text") || (v == "string")) {
|
|
|
|
return parameter_type::String;
|
|
|
|
}
|
|
|
|
if ((v == "tex") || (v == "texture")) {
|
|
|
|
return parameter_type::Texture;
|
|
|
|
}
|
|
|
|
if ((v == "sampler")) {
|
|
|
|
return parameter_type::Sampler;
|
|
|
|
}
|
|
|
|
/* To decide on in the future:
|
|
|
|
* - Double support?
|
|
|
|
* - Half Support?
|
|
|
|
* - Texture Arrays? (Likely not supported in libobs)
|
|
|
|
*/
|
|
|
|
throw std::invalid_argument("Invalid parameter type string.");
|
|
|
|
}
|
|
|
|
|
2021-11-25 04:57:37 +00:00
|
|
|
streamfx::gfx::shader::parameter::parameter(streamfx::gfx::shader::shader* parent,
|
|
|
|
streamfx::obs::gs::effect_parameter param, std::string key_prefix)
|
|
|
|
: _parent(parent), _param(param), _order(0), _key(_param.get_name()), _visible(true), _automatic(false),
|
|
|
|
_name(_key), _description()
|
2019-12-24 07:38:01 +00:00
|
|
|
{
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << key_prefix << "." << param.get_name();
|
|
|
|
_name = (_key);
|
|
|
|
}
|
|
|
|
|
2019-12-25 09:14:04 +00:00
|
|
|
// Read Order
|
2021-06-08 02:47:04 +00:00
|
|
|
if (auto anno = _param.get_annotation(ST_ANNO_VISIBILITY); anno) {
|
2019-12-25 09:14:04 +00:00
|
|
|
_visible = anno.get_default_bool();
|
|
|
|
}
|
2021-06-08 02:47:04 +00:00
|
|
|
if (auto anno = _param.get_annotation(ST_ANNO_AUTOMATIC); anno) {
|
2019-12-25 09:14:04 +00:00
|
|
|
_automatic = anno.get_default_bool();
|
|
|
|
}
|
|
|
|
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
// Read Order
|
2021-06-08 02:47:04 +00:00
|
|
|
if (auto anno = _param.get_annotation(ST_ANNO_ORDER); anno) {
|
2019-12-24 07:38:01 +00:00
|
|
|
_order = anno.get_default_int();
|
|
|
|
}
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
|
|
|
|
// Read Name
|
2021-06-08 02:47:04 +00:00
|
|
|
if (auto anno = _param.get_annotation(ST_ANNO_NAME); anno) {
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
if (std::string v = anno.get_default_string(); v.length() > 0) {
|
2022-07-21 11:09:10 +00:00
|
|
|
_name = std::move(v);
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
} else {
|
2021-06-08 02:47:04 +00:00
|
|
|
throw std::out_of_range("'" ST_ANNO_NAME "' annotation has zero length.");
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
}
|
2019-12-24 07:38:01 +00:00
|
|
|
}
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
|
|
|
|
// Read Description
|
2021-06-08 02:47:04 +00:00
|
|
|
if (auto anno = _param.get_annotation(ST_ANNO_DESCRIPTION); anno) {
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
if (std::string v = anno.get_default_string(); v.length() > 0) {
|
2022-07-21 11:09:10 +00:00
|
|
|
_description = std::move(v);
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
} else {
|
2021-06-08 02:47:04 +00:00
|
|
|
throw std::out_of_range("'" ST_ANNO_DESCRIPTION "' annotation has zero length.");
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
}
|
2019-12-24 07:38:01 +00:00
|
|
|
}
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
|
|
|
|
// Read Type override.
|
|
|
|
_type = get_type_from_effect_type(_param.get_type());
|
2021-06-08 02:47:04 +00:00
|
|
|
if (auto anno = _param.get_annotation(ST_ANNO_TYPE); anno) {
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
// We have a type override.
|
|
|
|
_type = get_type_from_string(anno.get_default_string());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read Size override.
|
|
|
|
_size = get_length_from_effect_type(_param.get_type());
|
2021-06-08 02:47:04 +00:00
|
|
|
if (auto anno = _param.get_annotation(ST_ANNO_SIZE); anno) {
|
2020-04-08 21:38:42 +00:00
|
|
|
std::size_t ov = static_cast<size_t>(anno.get_default_int());
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
if (ov > 0)
|
|
|
|
_size = ov;
|
|
|
|
}
|
2020-04-02 18:29:00 +00:00
|
|
|
_size = std::clamp<size_t>(_size, size_t{1}, size_t{32});
|
2019-12-24 07:38:01 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
void streamfx::gfx::shader::parameter::defaults(obs_data_t* settings) {}
|
2019-12-22 05:07:37 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
void streamfx::gfx::shader::parameter::properties(obs_properties_t* props, obs_data_t* settings) {}
|
2019-12-18 05:37:38 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
void streamfx::gfx::shader::parameter::update(obs_data_t* settings) {}
|
2019-12-18 05:37:38 +00:00
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
void streamfx::gfx::shader::parameter::assign() {}
|
2019-12-18 05:37:38 +00:00
|
|
|
|
2021-10-15 14:30:01 +00:00
|
|
|
void streamfx::gfx::shader::parameter::visible(bool visible) {}
|
|
|
|
|
|
|
|
void streamfx::gfx::shader::parameter::active(bool active) {}
|
|
|
|
|
2021-06-08 02:47:04 +00:00
|
|
|
std::shared_ptr<streamfx::gfx::shader::parameter>
|
2021-11-25 04:57:37 +00:00
|
|
|
streamfx::gfx::shader::parameter::make_parameter(streamfx::gfx::shader::shader* parent,
|
|
|
|
streamfx::obs::gs::effect_parameter param, std::string prefix)
|
2019-12-18 05:37:38 +00:00
|
|
|
{
|
2021-11-25 04:57:37 +00:00
|
|
|
if (!parent || !param) {
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
throw std::runtime_error("Bad call to make_parameter. This is a bug in the plugin.");
|
2019-12-18 06:49:43 +00:00
|
|
|
}
|
|
|
|
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
parameter_type real_type = get_type_from_effect_type(param.get_type());
|
2021-06-08 02:47:04 +00:00
|
|
|
if (auto anno = param.get_annotation(ST_ANNO_TYPE); anno) {
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
// We have a type override.
|
2019-12-25 09:09:56 +00:00
|
|
|
real_type = get_type_from_string(param.get_default_string());
|
2019-12-18 05:37:38 +00:00
|
|
|
}
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
|
|
|
|
switch (real_type) {
|
|
|
|
case parameter_type::Boolean:
|
2021-11-25 04:57:37 +00:00
|
|
|
return std::make_shared<streamfx::gfx::shader::bool_parameter>(parent, param, prefix);
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
case parameter_type::Integer:
|
2021-11-25 04:57:37 +00:00
|
|
|
return std::make_shared<streamfx::gfx::shader::int_parameter>(parent, param, prefix);
|
gfx-shader-param: Vastly improve parameter functionality
Allow for overriding type and size of an element, opening the path for `int#[]`, `float#[]`, `int#x#`, `float#x#`, `bool#x#`, `vector<type, #>` and `matrix<type, #, #>`. Also allows for specifying the exact type of texture instead of hoping the user gets it right, as well as samplers.
Parameters are also now created if they are invisible, which means that the properties() function must not be called, but they must still be used like any other. This is due to a problem with default values not being applied all the time, and sometimes just vanishing.
The code also now throws exceptions with reasonable text, which should be caught by the gfx::shader implementation and refuse a load of the effect. No other state should be modified at that point, so care must be taken that up until the moment the complete initialization is done no other state is modified.
2019-12-24 21:02:37 +00:00
|
|
|
case parameter_type::Float:
|
2021-11-25 04:57:37 +00:00
|
|
|
return std::make_shared<streamfx::gfx::shader::float_parameter>(parent, param, prefix);
|
2021-11-25 20:11:59 +00:00
|
|
|
case parameter_type::Texture:
|
|
|
|
return std::make_shared<streamfx::gfx::shader::texture_parameter>(parent, param, prefix);
|
2019-12-18 05:37:38 +00:00
|
|
|
default:
|
2019-12-21 16:04:38 +00:00
|
|
|
return nullptr;
|
2019-12-18 05:37:38 +00:00
|
|
|
}
|
|
|
|
}
|