project: Correct usage of exceptions and include stdexcept

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-09-04 02:59:04 +02:00
parent 4765c57828
commit 03c704de1a
29 changed files with 176 additions and 6 deletions

View File

@ -0,0 +1,142 @@
// Always provided by OBS
uniform float4x4 ViewProj<
bool visible = false;
string name = "View Projection Matrix";
>;
// Provided by Stream Effects
uniform float4 Time<
bool visible = false;
string name = "Time Array";
string description = "A float4 value containing the total time, rendering time and the time since the last tick. The last value is a random number between 0 and 1.";
>;
uniform float4x4 Random<
bool visible = false;
string name = "Random Array";
string description = "A float4x4 value containing random values between 0 and 1";
>;
uniform texture2d ImageSource<
bool visible = false;
string name = "Source Texture (Filter, Transition)";
>;
uniform float2 ImageSource_Size<
bool visible = false;
string name = "Source Texture Size (Filter, Transition)";
>;
uniform float2 ImageSource_Texel<
bool visible = false;
string name = "Source Texture Texel Size (Filter, Transition)";
>;
// Shader Parameters
uniform float p_drunk_strength<
bool visible = true;
string name = "Strength";
float minimum = 0.;
float maximum = 100.;
float step = .01;
> = 25.0;
uniform float p_drunk_speed<
bool visible = true;
string name = "Speed";
float minimum = 0.;
float maximum = 100.;
float step = .01;
> = 2.0;
// ---------- Shader Code
sampler_state def_sampler {
AddressU = Clamp;
AddressV = Clamp;
Filter = Linear;
};
struct VertData {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
struct FragData {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
FragData VSDefault(VertData v_in) {
FragData vert_out;
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
vert_out.uv = v_in.uv;
return vert_out;
}
// ---------- Fixed Color
#define MAX_PTS 5
#define MAX_LINE 5.
float random_time_at(int x, int y) {
const float ts[MAX_PTS + 1][MAX_PTS + 1] = {
{.2, .8, -.2, .452, -.2832, .8},
{-.28, -1, -.42, -.89, .72, -.29},
{.75, .25, .33, .67, .98, .01},
{-.28, 0.8, -.32, -.189, .11, .84},
{-.48, 0.1, -.2323, -.555, .421, .23},
{-.28, 0.3, -1.3333, 1.333, 4, 1},
};
return ts[x][y];
}
float2 mult_at(int x, int y) {
float x2 = fmod(x, 2.);
float y2 = fmod(y, 2.);
float2 mult;
mult.x = (x2 < 1.) ? -1. : 1.;
mult.y = (y2 < 1.) ? -1. : 1.;
return mult;
}
float4 PS_Drunk(FragData v_in) : TARGET {
float2 uvs[MAX_PTS + 1][MAX_PTS + 1];
for (int x = 0; x <= MAX_PTS; x++) {
for (int y = 0; y <= MAX_PTS; y++) {
float2 off = float2(0, 0);
if ((x > 0) && (x < MAX_PTS)) {
off.x = cos(Time.y * p_drunk_speed + random_time_at(x, y)) * ImageSource_Texel.x;
}
if ((y > 0) && (y < MAX_PTS)) {
off.y = sin(Time.y * p_drunk_speed + random_time_at(x, y)) * ImageSource_Texel.y;
}
off *= (p_drunk_strength / 100.0) * ImageSource_Size * 0.5 * mult_at(x, y);
uvs[x][y] = float2(x / MAX_LINE + off.x, y / MAX_LINE + off.y);
}
}
float2 fade = frac(v_in.uv * MAX_LINE);
fade = (sin((fade - 0.5) * 3.141) + 1.0) * 0.5;
int2 _low = int2(floor(v_in.uv * MAX_LINE));
int2 _hig = int2(ceil(v_in.uv * MAX_LINE));
float2 uv = v_in.uv;
float2 uv_tl = uvs[_low.x][_low.y];
float2 uv_tr = uvs[_hig.x][_low.y];
float2 uv_bl = uvs[_low.x][_hig.y];
float2 uv_br = uvs[_hig.x][_hig.y];
float2 uv_t = lerp(uv_tl, uv_tr, fade.x);
float2 uv_b = lerp(uv_bl, uv_br, fade.x);
uv = lerp(uv_t, uv_b, fade.y);
return ImageSource.Sample(def_sampler, uv);
}
technique Draw
{
pass
{
vertex_shader = VSDefault(v_in);
pixel_shader = PS_Drunk(v_in);
}
}

View File

@ -18,6 +18,7 @@
*/
#include "filter-blur.hpp"
#include <stdexcept>
#include <cfloat>
#include <cinttypes>
#include <cmath>

View File

@ -18,6 +18,7 @@
*/
#include "filter-color-grade.hpp"
#include <stdexcept>
#include "strings.hpp"
#include "util-math.hpp"

View File

@ -18,6 +18,7 @@
*/
#include "filter-displacement.hpp"
#include <stdexcept>
#include <sys/stat.h>
#include "strings.hpp"

View File

@ -18,6 +18,7 @@
*/
#include "filter-dynamic-mask.hpp"
#include <stdexcept>
#include <sstream>
#include "strings.hpp"
@ -260,7 +261,7 @@ void filter::dynamic_mask::dynamic_mask_instance::update(obs_data_t* settings)
found = this->_channels.find(kv1.first);
if (found == this->_channels.end()) {
assert(found != this->_channels.end());
throw std::exception("Unable to insert element into data _store.");
throw std::runtime_error("Unable to insert element into data _store.");
}
}
@ -315,7 +316,7 @@ void filter::dynamic_mask::dynamic_mask_instance::save(obs_data_t* settings)
found = this->_channels.find(kv1.first);
if (found == this->_channels.end()) {
assert(found != this->_channels.end());
throw std::exception("Unable to insert element into data _store.");
throw std::runtime_error("Unable to insert element into data _store.");
}
}
@ -411,7 +412,7 @@ void filter::dynamic_mask::dynamic_mask_instance::video_render(gs_effect_t* in_e
gs_blend_state_pop();
} else {
throw std::exception("Failed to render filter.");
throw std::runtime_error("Failed to render filter.");
}
this->_filter_texture = this->_filter_rt->get_texture();

View File

@ -18,6 +18,7 @@
*/
#include "filter-sdf-effects.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "strings.hpp"

View File

@ -18,6 +18,7 @@
*/
#include "filter-shader.hpp"
#include <stdexcept>
#include "strings.hpp"
#include "utility.hpp"

View File

@ -18,6 +18,7 @@
*/
#include "filter-transform.hpp"
#include <stdexcept>
#include "strings.hpp"
#include "util-math.hpp"

View File

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-blur-base.hpp"
#include <stdexcept>
void gfx::blur::base::set_step_scale_x(double_t v)
{

View File

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-blur-box-linear.hpp"
#include <stdexcept>
#include <cmath>
#include <memory>
#include "obs/gs/gs-helper.hpp"

View File

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-blur-box.hpp"
#include <stdexcept>
#include <cmath>
#include <memory>
#include "obs/gs/gs-helper.hpp"

View File

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-blur-dual-filtering.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "plugin.hpp"
#include "util-math.hpp"

View File

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-blur-gaussian-linear.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "util-math.hpp"

View File

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-blur-gaussian.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "plugin.hpp"
#include "util-math.hpp"

View File

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-effect-source.hpp"
#include <stdexcept>
#include <cfloat>
#include <climits>
#include <cstdint>

View File

@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "gfx-source-texture.hpp"
#include <stdexcept>
gfx::source_texture::~source_texture()
{

View File

@ -18,6 +18,7 @@
*/
#include "gs-indexbuffer.hpp"
#include <stdexcept>
#include "gs-limits.hpp"
#include "obs/gs/gs-helper.hpp"

View File

@ -18,6 +18,7 @@
*/
#include "gs-mipmapper.hpp"
#include <stdexcept>
#include "obs/gs/gs-helper.hpp"
#include "plugin.hpp"

View File

@ -18,6 +18,7 @@
*/
#include "gs-sampler.hpp"
#include <stdexcept>
gs::sampler::sampler()
{

View File

@ -18,6 +18,7 @@
*/
#include "gs-vertex.hpp"
#include <stdexcept>
#include "util-memory.hpp"
gs::vertex::vertex()

View File

@ -18,6 +18,7 @@
*/
#include "obs-source-tracker.hpp"
#include <stdexcept>
static std::shared_ptr<obs::source_tracker> source_tracker_instance;

View File

@ -18,6 +18,7 @@
*/
#include "obs-source.hpp"
#include <stdexcept>
void obs::source::handle_destroy(void* p, calldata_t* calldata)
{

View File

@ -18,6 +18,7 @@
*/
#include "obs-tools.hpp"
#include <stdexcept>
#include <map>
struct scs_searchdata {

View File

@ -18,6 +18,7 @@
*/
#include "plugin.hpp"
#include <stdexcept>
#include "obs/obs-source-tracker.hpp"
#include "filters/filter-blur.hpp"
#include "filters/filter-color-grade.hpp"

View File

@ -18,6 +18,7 @@
*/
#include "source-mirror.hpp"
#include <stdexcept>
#include <bitset>
#include <cstring>
#include <functional>

View File

@ -18,6 +18,7 @@
*/
#include "source-shader.hpp"
#include <stdexcept>
#include "strings.hpp"
#include "utility.hpp"

View File

@ -18,6 +18,7 @@
*/
#include "util-math.hpp"
#include <stdexcept>
#include <cctype>
#include <cstdlib>
#include "util-memory.hpp"

View File

@ -18,6 +18,7 @@
*/
#include "util-memory.hpp"
#include <stdexcept>
#include <cstdlib>
#define USE_STD_ALLOC_FREE

View File

@ -18,6 +18,7 @@
*/
#include "utility.hpp"
#include <stdexcept>
#include <sstream>
#include "plugin.hpp"