diff --git a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp index adcb2cdc1..1a16dc4fe 100644 --- a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp +++ b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp @@ -107,8 +107,6 @@ template typename DistanceFieldVectorGL::Com #endif GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - vert.addSource(configuration.flags() & Flag::TextureTransformation ? "#define TEXTURE_TRANSFORMATION\n"_s : ""_s) .addSource(dimensions == 2 ? "#define TWO_DIMENSIONS\n"_s : "#define THREE_DIMENSIONS\n"_s); #ifndef MAGNUM_TARGET_GLES2 @@ -121,7 +119,10 @@ template typename DistanceFieldVectorGL::Com } #endif vert.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("Vector.vert"_s)); + .addSource(rs.getString("Vector.vert"_s)) + .submitCompile(); + + GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); #ifndef MAGNUM_TARGET_GLES2 if(configuration.flags() >= Flag::UniformBuffers) { frag.addSource(Utility::format( @@ -134,10 +135,8 @@ template typename DistanceFieldVectorGL::Com } #endif frag.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("DistanceFieldVector.frag"_s)); - - vert.submitCompile(); - frag.submitCompile(); + .addSource(rs.getString("DistanceFieldVector.frag"_s)) + .submitCompile(); DistanceFieldVectorGL out{NoInit}; out._flags = configuration.flags(); diff --git a/src/Magnum/Shaders/FlatGL.cpp b/src/Magnum/Shaders/FlatGL.cpp index f74e67199..8138d04d9 100644 --- a/src/Magnum/Shaders/FlatGL.cpp +++ b/src/Magnum/Shaders/FlatGL.cpp @@ -159,8 +159,6 @@ template typename FlatGL::CompileState FlatG #endif GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - vert.addSource((configuration.flags() & Flag::Textured #ifndef MAGNUM_TARGET_GLES2 || configuration.flags() >= Flag::ObjectIdTexture @@ -212,7 +210,10 @@ template typename FlatGL::CompileState FlatG } #endif vert.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("Flat.vert"_s)); + .addSource(rs.getString("Flat.vert"_s)) + .submitCompile(); + + GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); frag.addSource(configuration.flags() & Flag::Textured ? "#define TEXTURED\n"_s : ""_s) #ifndef MAGNUM_TARGET_GLES2 .addSource(configuration.flags() & Flag::TextureArrays ? "#define TEXTURE_ARRAYS\n"_s : ""_s) @@ -237,10 +238,8 @@ template typename FlatGL::CompileState FlatG } #endif frag.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("Flat.frag"_s)); - - vert.submitCompile(); - frag.submitCompile(); + .addSource(rs.getString("Flat.frag"_s)) + .submitCompile(); out.attachShaders({vert, frag}); diff --git a/src/Magnum/Shaders/MeshVisualizerGL.cpp b/src/Magnum/Shaders/MeshVisualizerGL.cpp index 736231cd4..e6ebe39fb 100644 --- a/src/Magnum/Shaders/MeshVisualizerGL.cpp +++ b/src/Magnum/Shaders/MeshVisualizerGL.cpp @@ -174,8 +174,6 @@ GL::Version MeshVisualizerGLBase::setupShaders(GL::Shader& vert, GL::Shader& fra #endif vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - vert.addSource(flags & FlagBase::Wireframe ? "#define WIREFRAME_RENDERING\n"_s : ""_s) #ifndef MAGNUM_TARGET_GLES2 .addSource(flags >= FlagBase::ObjectIdTexture ? "#define TEXTURED\n"_s : ""_s) @@ -232,6 +230,8 @@ GL::Version MeshVisualizerGLBase::setupShaders(GL::Shader& vert, GL::Shader& fra vert.addSource(flags >= FlagBase::MultiDraw ? "#define MULTI_DRAW\n"_s : ""_s); } #endif + + frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); frag.addSource(flags & FlagBase::Wireframe ? "#define WIREFRAME_RENDERING\n"_s : ""_s) #ifndef MAGNUM_TARGET_GLES2 .addSource(flags & FlagBase::ObjectId ? "#define OBJECT_ID\n"_s : ""_s) @@ -510,7 +510,9 @@ MeshVisualizerGL2D::CompileState MeshVisualizerGL2D::compile(const Configuration .addSource((configuration.flags() & Flag::NoGeometryShader) || !(configuration.flags() & Flag::Wireframe) ? "#define NO_GEOMETRY_SHADER\n"_s : ""_s) .addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("MeshVisualizer.vert"_s)); + .addSource(rs.getString("MeshVisualizer.vert"_s)) + .submitCompile(); + frag /* Pass NO_GEOMETRY_SHADER not only when NoGeometryShader but also when nothing actually needs it, as that makes checks much simpler in @@ -522,8 +524,8 @@ MeshVisualizerGL2D::CompileState MeshVisualizerGL2D::compile(const Configuration frag.addSource("#define TWO_DIMENSIONS\n"_s); #endif frag.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("MeshVisualizer.frag"_s)); - + .addSource(rs.getString("MeshVisualizer.frag"_s)) + .submitCompile(); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(configuration.flags() & Flag::Wireframe && !(configuration.flags() & Flag::NoGeometryShader)) { @@ -551,16 +553,14 @@ MeshVisualizerGL2D::CompileState MeshVisualizerGL2D::compile(const Configuration geom->addSource(configuration.flags() >= Flag::MultiDraw ? "#define MULTI_DRAW\n"_s : ""_s); } #endif - geom->addSource(rs.getString("MeshVisualizer.geom"_s)); + (*geom) + .addSource(rs.getString("MeshVisualizer.geom"_s)) + .submitCompile(); } #else static_cast(version); #endif - vert.submitCompile(); - frag.submitCompile(); - if(geom) geom->submitCompile(); - out.attachShaders({vert, frag}); if(geom) out.attachShader(*geom); diff --git a/src/Magnum/Shaders/PhongGL.cpp b/src/Magnum/Shaders/PhongGL.cpp index d6e49247b..55873012c 100644 --- a/src/Magnum/Shaders/PhongGL.cpp +++ b/src/Magnum/Shaders/PhongGL.cpp @@ -185,9 +185,6 @@ PhongGL::CompileState PhongGL::compile(const Configuration& configuration) { 1 : out._perInstanceJointCountUniform + 1; #endif - GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - #ifndef MAGNUM_TARGET_GLES /* Initializer for the light color / position / range arrays -- we need a list of initializers joined by commas. For GLES we'll simply upload the @@ -203,6 +200,7 @@ PhongGL::CompileState PhongGL::compile(const Configuration& configuration) { ("1.0/0.0, "_s*configuration.lightCount()).exceptSuffix(2)); #endif + GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); vert.addSource((configuration.flags() & (Flag::AmbientTexture|Flag::DiffuseTexture|Flag::SpecularTexture|Flag::NormalTexture) #ifndef MAGNUM_TARGET_GLES2 || configuration.flags() >= Flag::ObjectIdTexture @@ -259,7 +257,10 @@ PhongGL::CompileState PhongGL::compile(const Configuration& configuration) { } #endif vert.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("Phong.vert"_s)); + .addSource(rs.getString("Phong.vert"_s)) + .submitCompile(); + + GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); frag.addSource(configuration.flags() & Flag::AmbientTexture ? "#define AMBIENT_TEXTURE\n"_s : ""_s) .addSource(configuration.flags() & Flag::DiffuseTexture ? "#define DIFFUSE_TEXTURE\n"_s : ""_s) .addSource(configuration.flags() & Flag::SpecularTexture ? "#define SPECULAR_TEXTURE\n"_s : ""_s) @@ -307,10 +308,8 @@ PhongGL::CompileState PhongGL::compile(const Configuration& configuration) { frag.addSource(std::move(lightInitializer)); #endif frag.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("Phong.frag"_s)); - - vert.submitCompile(); - frag.submitCompile(); + .addSource(rs.getString("Phong.frag"_s)) + .submitCompile(); out.attachShaders({vert, frag}); diff --git a/src/Magnum/Shaders/VectorGL.cpp b/src/Magnum/Shaders/VectorGL.cpp index dbbb4edf4..4693fcd8b 100644 --- a/src/Magnum/Shaders/VectorGL.cpp +++ b/src/Magnum/Shaders/VectorGL.cpp @@ -107,8 +107,6 @@ template typename VectorGL::CompileState Vec #endif GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - vert.addSource(configuration.flags() & Flag::TextureTransformation ? "#define TEXTURE_TRANSFORMATION\n"_s : ""_s) .addSource(dimensions == 2 ? "#define TWO_DIMENSIONS\n"_s : "#define THREE_DIMENSIONS\n"_s); #ifndef MAGNUM_TARGET_GLES2 @@ -121,7 +119,10 @@ template typename VectorGL::CompileState Vec } #endif vert.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("Vector.vert"_s)); + .addSource(rs.getString("Vector.vert"_s)) + .submitCompile(); + + GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); #ifndef MAGNUM_TARGET_GLES2 if(configuration.flags() >= Flag::UniformBuffers) { frag.addSource(Utility::format( @@ -134,10 +135,8 @@ template typename VectorGL::CompileState Vec } #endif frag.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("Vector.frag"_s)); - - vert.submitCompile(); - frag.submitCompile(); + .addSource(rs.getString("Vector.frag"_s)) + .submitCompile(); VectorGL out{NoInit}; out._flags = configuration.flags(); diff --git a/src/Magnum/Shaders/VertexColorGL.cpp b/src/Magnum/Shaders/VertexColorGL.cpp index 9f7658f5d..07dceec32 100644 --- a/src/Magnum/Shaders/VertexColorGL.cpp +++ b/src/Magnum/Shaders/VertexColorGL.cpp @@ -98,8 +98,6 @@ template typename VertexColorGL::CompileStat #endif GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - vert.addSource(dimensions == 2 ? "#define TWO_DIMENSIONS\n"_s : "#define THREE_DIMENSIONS\n"_s); #ifndef MAGNUM_TARGET_GLES2 if(configuration.flags() >= Flag::UniformBuffers) { @@ -111,12 +109,13 @@ template typename VertexColorGL::CompileStat } #endif vert.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("VertexColor.vert"_s)); - frag.addSource(rs.getString("generic.glsl"_s)) - .addSource(rs.getString("VertexColor.frag"_s)); + .addSource(rs.getString("VertexColor.vert"_s)) + .submitCompile(); - vert.submitCompile(); - frag.submitCompile(); + GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); + frag.addSource(rs.getString("generic.glsl"_s)) + .addSource(rs.getString("VertexColor.frag"_s)) + .submitCompile(); VertexColorGL out{NoInit}; out._flags = configuration.flags();