mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-27 13:53:01 +00:00
gs-effect: Allow empty effect and check errorMessage validity
This commit is contained in:
parent
fc02f3fdad
commit
4b364865a1
2 changed files with 15 additions and 4 deletions
|
@ -26,13 +26,20 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
GS::Effect::Effect() {
|
||||
m_effect = nullptr;
|
||||
}
|
||||
|
||||
GS::Effect::Effect(std::string file) {
|
||||
obs_enter_graphics();
|
||||
char* errorMessage = nullptr;
|
||||
m_effect = gs_effect_create_from_file(file.c_str(), &errorMessage);
|
||||
if (!m_effect || errorMessage) {
|
||||
std::string error(errorMessage);
|
||||
bfree((void*)errorMessage);
|
||||
std::string error = "Generic Error";
|
||||
if (errorMessage) {
|
||||
error = std::string(errorMessage);
|
||||
bfree((void*)errorMessage);
|
||||
}
|
||||
obs_leave_graphics();
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
|
@ -44,8 +51,11 @@ GS::Effect::Effect(std::string code, std::string name) {
|
|||
char* errorMessage = nullptr;
|
||||
m_effect = gs_effect_create(code.c_str(), name.c_str(), &errorMessage);
|
||||
if (!m_effect || errorMessage) {
|
||||
std::string error(errorMessage);
|
||||
bfree((void*)errorMessage);
|
||||
std::string error = "Generic Error";
|
||||
if (errorMessage) {
|
||||
error = std::string(errorMessage);
|
||||
bfree((void*)errorMessage);
|
||||
}
|
||||
obs_leave_graphics();
|
||||
throw std::runtime_error(error);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ namespace GS {
|
|||
|
||||
class Effect {
|
||||
public:
|
||||
Effect();
|
||||
Effect(std::string file);
|
||||
Effect(std::string code, std::string name);
|
||||
virtual ~Effect();
|
||||
|
|
Loading…
Reference in a new issue