mirror of https://github.com/Xaymar/obs-StreamFX
plugin: Allow new filters and transitions to self-register
This commit is contained in:
parent
3baecb4f2f
commit
fc02f3fdad
|
@ -32,15 +32,24 @@ Filter::Displacement *filterDisplacement;
|
||||||
Filter::Shape *filterShape;
|
Filter::Shape *filterShape;
|
||||||
Filter::Transform *filterTransform;
|
Filter::Transform *filterTransform;
|
||||||
|
|
||||||
|
std::list<std::function<void()>> initializerFunctions;
|
||||||
|
std::list<std::function<void()>> finalizerFunctions;
|
||||||
|
|
||||||
MODULE_EXPORT bool obs_module_load(void) {
|
MODULE_EXPORT bool obs_module_load(void) {
|
||||||
filterDisplacement = new Filter::Displacement();
|
filterDisplacement = new Filter::Displacement();
|
||||||
filterShape = new Filter::Shape();
|
filterShape = new Filter::Shape();
|
||||||
filterTransform = new Filter::Transform();
|
filterTransform = new Filter::Transform();
|
||||||
filterBlur = new Filter::Blur();
|
filterBlur = new Filter::Blur();
|
||||||
|
for (auto func : initializerFunctions) {
|
||||||
|
func();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MODULE_EXPORT void obs_module_unload(void) {
|
MODULE_EXPORT void obs_module_unload(void) {
|
||||||
|
for (auto func : finalizerFunctions) {
|
||||||
|
func();
|
||||||
|
}
|
||||||
delete filterTransform;
|
delete filterTransform;
|
||||||
delete filterShape;
|
delete filterShape;
|
||||||
delete filterDisplacement;
|
delete filterDisplacement;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <list>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#pragma warning (push)
|
#pragma warning (push)
|
||||||
#pragma warning (disable: 4201)
|
#pragma warning (disable: 4201)
|
||||||
|
@ -57,3 +59,30 @@
|
||||||
#define __FUNCTION_NAME__ __func__
|
#define __FUNCTION_NAME__ __func__
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define INITIALIZER(f) \
|
||||||
|
static void f(void); \
|
||||||
|
struct f##_t_ { f##_t_(void) { f(); } }; static f##_t_ f##_; \
|
||||||
|
static void f(void)
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#pragma section(".CRT$XCU",read)
|
||||||
|
#define INITIALIZER2_(f,p) \
|
||||||
|
static void f(void); \
|
||||||
|
__declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
|
||||||
|
__pragma(comment(linker,"/include:" p #f "_")) \
|
||||||
|
static void f(void)
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define INITIALIZER(f) INITIALIZER2_(f,"")
|
||||||
|
#else
|
||||||
|
#define INITIALIZER(f) INITIALIZER2_(f,"_")
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define INITIALIZER(f) \
|
||||||
|
static void f(void) __attribute__((constructor)); \
|
||||||
|
static void f(void)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Initializer & Finalizer
|
||||||
|
extern std::list<std::function<void()>> initializerFunctions;
|
||||||
|
extern std::list<std::function<void()>> finalizerFunctions;
|
||||||
|
|
Loading…
Reference in New Issue