diff --git a/IOSupport/GenericOCIOOpenGL.cpp b/IOSupport/GenericOCIOOpenGL.cpp index e7bc04f..3de25ca 100644 --- a/IOSupport/GenericOCIOOpenGL.cpp +++ b/IOSupport/GenericOCIOOpenGL.cpp @@ -244,7 +244,7 @@ GenericOCIO::applyGL(const Texture* srcImg, glBuilder->allocateAllTextures(1); // Step 5: Build the fragment shader program - glBuilder->buildProgram(g_fragShaderText); + glBuilder->buildProgram(g_fragShaderText, false); } glEnable(GL_TEXTURE_2D); diff --git a/IOSupport/glsl.README.txt b/IOSupport/glsl.README.txt index 21d204b..d591410 100644 --- a/IOSupport/glsl.README.txt +++ b/IOSupport/glsl.README.txt @@ -1,8 +1,8 @@ -glsl.cpp and glsl.h are from OpenCOlorIO 2.1.0: -https://github.com/AcademySoftwareFoundation/OpenColorIO/tree/v2.1.0/src/libutils/oglapphelpers +glsl.cpp and glsl.h are from OpenCOlorIO 2.1.1: +https://github.com/AcademySoftwareFoundation/OpenColorIO/tree/v2.1.1/src/libutils/oglapphelpers gsls.cpp was modified to use glad.h indlead of GL/glew.h, in order to avoid using another external library. These files are Copyright Contributors to the OpenColorIO Project. They are distributed under the BSD 3-Clause License: -https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/v2.1.0/LICENSE +https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/v2.1.1/LICENSE diff --git a/IOSupport/glsl.cpp b/IOSupport/glsl.cpp index c56ce94..88795e3 100644 --- a/IOSupport/glsl.cpp +++ b/IOSupport/glsl.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenColorIO Project. + #if 1 #include #define HAVE_GLU 1 @@ -460,20 +461,31 @@ void OpenGLBuilder::useAllUniforms() std::string OpenGLBuilder::getGLSLVersionString() { - if (m_shaderDesc->getLanguage() == GPU_LANGUAGE_GLSL_1_3) + switch (m_shaderDesc->getLanguage()) { + case GPU_LANGUAGE_GLSL_1_2: + case GPU_LANGUAGE_MSL_2_0: + // That's the minimal version supported. + return "#version 120"; + case GPU_LANGUAGE_GLSL_1_3: return "#version 130"; - } - else if (m_shaderDesc->getLanguage() == GPU_LANGUAGE_GLSL_4_0) - { + case GPU_LANGUAGE_GLSL_4_0: return "#version 400 core"; + case GPU_LANGUAGE_GLSL_ES_1_0: + return "#version 100"; + case GPU_LANGUAGE_GLSL_ES_3_0: + return "#version 300 es"; + case GPU_LANGUAGE_CG: + case GPU_LANGUAGE_HLSL_DX11: + case LANGUAGE_OSL_1: + default: + // These are all impossible in OpenGL contexts. + // The shader will be unusable, so let's throw + throw Exception("Invalid shader language for OpenGLBuilder"); } - - // That's the minimal version supported. - return "#version 120"; } -unsigned OpenGLBuilder::buildProgram(const std::string & clientShaderProgram) +unsigned OpenGLBuilder::buildProgram(const std::string & clientShaderProgram, bool standaloneShader) { const std::string shaderCacheID = m_shaderDesc->getCacheID(); if(shaderCacheID!=m_shaderCacheID) @@ -486,7 +498,7 @@ unsigned OpenGLBuilder::buildProgram(const std::string & clientShaderProgram) std::ostringstream os; os << getGLSLVersionString() << std::endl - << m_shaderDesc->getShaderText() << std::endl + << (!standaloneShader ? m_shaderDesc->getShaderText() : "") << std::endl << clientShaderProgram << std::endl; if(m_verbose) diff --git a/IOSupport/glsl.h b/IOSupport/glsl.h index 5a9c7fe..1fdd33d 100644 --- a/IOSupport/glsl.h +++ b/IOSupport/glsl.h @@ -79,7 +79,7 @@ class OpenGLBuilder // Build the complete shader program which includes the OCIO shader program // and the client shader program. - unsigned buildProgram(const std::string & clientShaderProgram); + unsigned buildProgram(const std::string & clientShaderProgram, bool standaloneShader); void useProgram(); unsigned getProgramHandle();