2017-09-17 19:55:16 +00:00
|
|
|
/*
|
|
|
|
* Modern effects for a modern Streamer
|
|
|
|
* Copyright (C) 2017 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
|
2019-01-14 10:23:21 +00:00
|
|
|
#include <cinttypes>
|
2018-09-28 12:18:09 +00:00
|
|
|
#include <list>
|
2017-09-17 19:55:16 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "gs-sampler.hpp"
|
|
|
|
#include "gs-texture.hpp"
|
2018-09-28 12:18:09 +00:00
|
|
|
|
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4201)
|
|
|
|
#include <graphics/graphics.h>
|
|
|
|
#include <graphics/matrix4.h>
|
|
|
|
#include <graphics/vec2.h>
|
2018-11-07 14:24:25 +00:00
|
|
|
#include <graphics/vec3.h>
|
|
|
|
#include <graphics/vec4.h>
|
2018-09-28 12:18:09 +00:00
|
|
|
#pragma warning(pop)
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
namespace gs {
|
|
|
|
class effect_parameter {
|
2017-09-17 19:55:16 +00:00
|
|
|
public:
|
2018-03-20 11:43:37 +00:00
|
|
|
enum class type : uint8_t {
|
2017-09-17 19:55:16 +00:00
|
|
|
Unknown,
|
|
|
|
Boolean,
|
|
|
|
Float,
|
|
|
|
Float2,
|
|
|
|
Float3,
|
|
|
|
Float4,
|
|
|
|
Integer,
|
|
|
|
Integer2,
|
|
|
|
Integer3,
|
|
|
|
Integer4,
|
|
|
|
Matrix,
|
|
|
|
String,
|
|
|
|
Texture,
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2018-03-20 11:43:37 +00:00
|
|
|
effect_parameter(gs_eparam_t* param);
|
2018-09-28 12:18:09 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
std::string get_name();
|
2018-09-28 12:18:09 +00:00
|
|
|
type get_type();
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
void set_bool(bool v);
|
|
|
|
void set_bool_array(bool v[], size_t sz);
|
|
|
|
void set_float(float_t x);
|
|
|
|
void set_float2(vec2& v);
|
|
|
|
void set_float2(float_t x, float_t y);
|
|
|
|
void set_float3(vec3& v);
|
|
|
|
void set_float3(float_t x, float_t y, float_t z);
|
|
|
|
void set_float4(vec4& v);
|
|
|
|
void set_float4(float_t x, float_t y, float_t z, float_t w);
|
|
|
|
void set_float_array(float_t v[], size_t sz);
|
|
|
|
void set_int(int32_t x);
|
|
|
|
void set_int2(int32_t x, int32_t y);
|
|
|
|
void set_int3(int32_t x, int32_t y, int32_t z);
|
|
|
|
void set_int4(int32_t x, int32_t y, int32_t z, int32_t w);
|
|
|
|
void set_int_array(int32_t v[], size_t sz);
|
|
|
|
void set_matrix(matrix4& v);
|
|
|
|
void set_texture(std::shared_ptr<gs::texture> v);
|
|
|
|
void set_texture(gs_texture_t* v);
|
|
|
|
void set_sampler(std::shared_ptr<gs::sampler> v);
|
|
|
|
void set_sampler(gs_sampler_state* v);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
|
|
|
private:
|
2018-09-28 12:18:09 +00:00
|
|
|
gs_eparam_t* m_param;
|
2017-09-17 19:55:16 +00:00
|
|
|
gs_effect_param_info m_paramInfo;
|
|
|
|
};
|
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
class effect {
|
2017-09-17 19:55:16 +00:00
|
|
|
public:
|
2018-03-20 11:43:37 +00:00
|
|
|
effect();
|
|
|
|
effect(std::string file);
|
|
|
|
effect(std::string code, std::string name);
|
|
|
|
virtual ~effect();
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
gs_effect_t* get_object();
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-09-28 12:18:09 +00:00
|
|
|
size_t count_parameters();
|
2018-03-20 11:43:37 +00:00
|
|
|
std::list<effect_parameter> get_parameters();
|
2018-09-28 12:18:09 +00:00
|
|
|
effect_parameter get_parameter(size_t idx);
|
|
|
|
effect_parameter get_parameter(std::string name);
|
|
|
|
bool has_parameter(std::string name);
|
|
|
|
bool has_parameter(std::string name, effect_parameter::type type);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
gs_effect_t* m_effect;
|
|
|
|
};
|
2018-09-28 12:18:09 +00:00
|
|
|
} // namespace gs
|