From 56d67a978b72901fe0936024632ce7cdde4a67ea Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Thu, 28 May 2026 21:13:24 -0700 Subject: [PATCH 1/2] IECoreGL : Restore GL 2.1 compatibility for macOS This isn't ideal, but will allow the OpenGL Scene Viewer in Gaffer 1.7 to continue to work on macOS. --- Changes | 5 +++++ glsl/IECoreGL/CurvesPrimitive.h | 4 ++-- src/IECoreGL/CurvesPrimitive.cpp | 11 +++++++---- src/IECoreGL/Shader.cpp | 6 +++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Changes b/Changes index 854bcd7ea6..a51c1d4183 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,12 @@ 10.7.x.x (relative to 10.7.0.0a10) ======== +Fixes +----- +- IECoreGL::Shader : Restored compatibility with OpenGL 2.1 in order to preserve macOS support [^1]. + +[^1]: To be omitted from the notes for the final 10.7.0.0 release. 10.7.0.0a10 (relative to 10.7.0.0a9) =========== diff --git a/glsl/IECoreGL/CurvesPrimitive.h b/glsl/IECoreGL/CurvesPrimitive.h index 6cfc6ffc44..a6469ed627 100644 --- a/glsl/IECoreGL/CurvesPrimitive.h +++ b/glsl/IECoreGL/CurvesPrimitive.h @@ -47,7 +47,7 @@ layout( lines_adjacency ) in;\ layout( line_strip, max_vertices = 10 ) out;\ \ - in int geometryIsCurveEndPoint[];\ + in float geometryIsCurveEndPoint[];\ \ uniform mat4x4 basis;\ uniform mat4x4 phantomBasis0;\ @@ -70,7 +70,7 @@ layout( lines_adjacency ) in;\ layout( triangle_strip, max_vertices = 20 ) out;\ \ - in int geometryIsCurveEndPoint[];\ + in float geometryIsCurveEndPoint[];\ \ uniform mat4x4 basis;\ uniform mat4x4 phantomBasis0;\ diff --git a/src/IECoreGL/CurvesPrimitive.cpp b/src/IECoreGL/CurvesPrimitive.cpp index 0e374b61bf..f1e4cc638e 100644 --- a/src/IECoreGL/CurvesPrimitive.cpp +++ b/src/IECoreGL/CurvesPrimitive.cpp @@ -338,15 +338,18 @@ const Shader::Setup *CurvesPrimitive::shaderSetup( const Shader *shader, State * // To handle "phantom vertices" in the geometry shader, we need to know which // vertices correspond to the original endpoints of the curve. We do that using // the `vertexIsCurveEndPoint` attribute. - IECore::IntVectorDataPtr isEndPointData = new IECore::IntVectorData(); - vector &isEndPoint = isEndPointData->writable(); + /// \todo `vertexIsCurveEndPoint` is a float attribute only to maintain compatibility + /// with OpenGL 2.1. Use an int attribute once we we're able to move IECoreGL to + /// OpenGL 3.3 Core Profile. + IECore::FloatVectorDataPtr isEndPointData = new IECore::FloatVectorData(); + vector &isEndPoint = isEndPointData->writable(); isEndPoint.resize( m_memberData->points->readable().size(), 0 ); int i = 0; for( auto c : m_memberData->vertsPerCurve->readable() ) { - isEndPoint[i] = 1; - isEndPoint[i+c-1] = 1; + isEndPoint[i] = 1.0f; + isEndPoint[i+c-1] = 1.0f; i += c; } geometryShaderSetup->addVertexAttribute( "vertexIsCurveEndPoint", isEndPointData ); diff --git a/src/IECoreGL/Shader.cpp b/src/IECoreGL/Shader.cpp index 24a281d64a..ebb2ac0361 100644 --- a/src/IECoreGL/Shader.cpp +++ b/src/IECoreGL/Shader.cpp @@ -970,7 +970,7 @@ const std::string &Shader::defaultVertexSource() { static const string g_s = R"( - #version 150 compatibility + #version 120 #if __VERSION__ <= 120 #define in attribute @@ -985,14 +985,14 @@ const std::string &Shader::defaultVertexSource() in vec3 vertexN; in vec2 vertexuv; in vec3 vertexCs; - in int vertexIsCurveEndPoint; + in float vertexIsCurveEndPoint; out vec3 geometryI; out vec3 geometryP; out vec3 geometryN; out vec2 geometryuv; out vec3 geometryCs; - out int geometryIsCurveEndPoint; + out float geometryIsCurveEndPoint; out vec3 fragmentI; out vec3 fragmentP; From 0e2450e878dcdb08f1879603cfbef9a1e0e219c6 Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Thu, 28 May 2026 21:13:49 -0700 Subject: [PATCH 2/2] IECoreGL : Remove trailing semicolons from shaders These were added with the conversion to raw string literals in cab67a2b2f92160c61f58eb77c3f3bad9197172d and lead to syntax errors when the shaders are compiled on macOS. --- src/IECoreGL/Shader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/IECoreGL/Shader.cpp b/src/IECoreGL/Shader.cpp index ebb2ac0361..b45ad92fcd 100644 --- a/src/IECoreGL/Shader.cpp +++ b/src/IECoreGL/Shader.cpp @@ -1063,7 +1063,7 @@ const std::string &Shader::defaultFragmentSource() vec3 Nf = faceforward( fragmentN, -fragmentI, fragmentN ); float f = dot( normalize( fragmentI ), normalize(Nf) ); gl_FragColor = vec4( f * fragmentCs, 1 ); - }; + } )"; @@ -1083,7 +1083,7 @@ const std::string &Shader::constantFragmentSource() void main() { gl_FragColor = vec4( fragmentCs, 1 ); - }; + } )"; @@ -1118,7 +1118,7 @@ const std::string &Shader::lambertFragmentSource() vec3 Cdiffuse = ieDiffuse( fragmentP, n, Cl, L, gl_MaxLights ); gl_FragColor = vec4( Cdiffuse, 1.0 ); - }; + } )";