diff --git a/Outputs/CRT/Internals/Shaders/Shader.cpp b/Outputs/CRT/Internals/Shaders/Shader.cpp index f4968b752..f0e2fbb26 100644 --- a/Outputs/CRT/Internals/Shaders/Shader.cpp +++ b/Outputs/CRT/Internals/Shaders/Shader.cpp @@ -291,14 +291,18 @@ void Shader::set_uniform_matrix(const std::string &name, GLint size, GLsizei cou void Shader::enqueue_function(std::function function) { + _function_mutex.lock(); _enqueued_functions.push_back(function); + _function_mutex.unlock(); } void Shader::flush_functions() { + _function_mutex.lock(); for(std::function function : _enqueued_functions) { function(); } _enqueued_functions.clear(); + _function_mutex.unlock(); } diff --git a/Outputs/CRT/Internals/Shaders/Shader.hpp b/Outputs/CRT/Internals/Shaders/Shader.hpp index ead7ce397..b28335032 100644 --- a/Outputs/CRT/Internals/Shaders/Shader.hpp +++ b/Outputs/CRT/Internals/Shaders/Shader.hpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace OpenGL { @@ -110,6 +111,7 @@ private: void flush_functions(); std::list> _enqueued_functions; + std::mutex _function_mutex; protected: void enqueue_function(std::function function);