diff --git a/libs/openFrameworks/gl/ofShader.cpp b/libs/openFrameworks/gl/ofShader.cpp index 9fc24210f4d..342d35a7e06 100644 --- a/libs/openFrameworks/gl/ofShader.cpp +++ b/libs/openFrameworks/gl/ofShader.cpp @@ -1019,6 +1019,15 @@ void ofShader::setUniform4i(const string & name, int v1, int v2, int v3, int v4) } } +//-------------------------------------------------------------- +void ofShader::setUniformBufferObject(const std::string & name, const void * data, GLsizeiptr dataSize) { + if (!bufferObjectsCache[name].isAllocated()) { + bufferObjectsCache[name].allocate(dataSize, GL_STATIC_DRAW); + } + bufferObjectsCache[name].updateData(dataSize, data); + bufferObjectsCache[name].bindBase(GL_UNIFORM_BUFFER, getUniformBlockIndex(name)); +} + //-------------------------------------------------------------- void ofShader::setUniform1f(const string & name, float v1) const { if (bLoaded) { diff --git a/libs/openFrameworks/gl/ofShader.h b/libs/openFrameworks/gl/ofShader.h index c0330b67ccd..91349e2584d 100644 --- a/libs/openFrameworks/gl/ofShader.h +++ b/libs/openFrameworks/gl/ofShader.h @@ -167,6 +167,10 @@ class ofShader { void setUniform3i(const std::string & name, int v1, int v2, int v3) const; void setUniform4i(const std::string & name, int v1, int v2, int v3, int v4) const; + + // Dmtr testing + void setUniformBufferObject(const std::string & name, const void * data, GLsizeiptr dataSize); + void setUniform1f(const std::string & name, float v1) const; void setUniform2f(const std::string & name, float v1, float v2) const; void setUniform3f(const std::string & name, float v1, float v2, float v3) const; @@ -287,6 +291,8 @@ class ofShader { }; std::unordered_map shaders; + + std::unordered_map bufferObjectsCache; std::unordered_map uniformsCache; mutable std::unordered_map attributesBindingsCache;