mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
plugin: Allow new filters and transitions to self-register
This commit is contained in:
parent
3baecb4f2f
commit
fc02f3fdad
2 changed files with 38 additions and 0 deletions
|
@ -32,15 +32,24 @@ Filter::Displacement *filterDisplacement;
|
|||
Filter::Shape *filterShape;
|
||||
Filter::Transform *filterTransform;
|
||||
|
||||
std::list<std::function<void()>> initializerFunctions;
|
||||
std::list<std::function<void()>> finalizerFunctions;
|
||||
|
||||
MODULE_EXPORT bool obs_module_load(void) {
|
||||
filterDisplacement = new Filter::Displacement();
|
||||
filterShape = new Filter::Shape();
|
||||
filterTransform = new Filter::Transform();
|
||||
filterBlur = new Filter::Blur();
|
||||
for (auto func : initializerFunctions) {
|
||||
func();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
MODULE_EXPORT void obs_module_unload(void) {
|
||||
for (auto func : finalizerFunctions) {
|
||||
func();
|
||||
}
|
||||
delete filterTransform;
|
||||
delete filterShape;
|
||||
delete filterDisplacement;
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
#pragma once
|
||||
#include <inttypes.h>
|
||||
#include <list>
|
||||
#include <functional>
|
||||
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4201)
|
||||
|
@ -57,3 +59,30 @@
|
|||
#define __FUNCTION_NAME__ __func__
|
||||
#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 a new issue