From 1f2b19c698bb253113a45c7b190ad76435bfe4a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 25 Jul 2023 12:15:42 +0200 Subject: [PATCH] Shaders: drop the createCompatibilityShader() helper. With the workarounds moved to the GL::Shader class itself, it's just a complicated wrapper for adding the compatibility.glsl file and a rather strange way to define a file-local helper for resource import on static builds. Do that directly instead. --- .../Test/FullScreenTriangleGLTest.cpp | 12 ++-- src/Magnum/Shaders/CMakeLists.txt | 1 - src/Magnum/Shaders/DistanceFieldVectorGL.cpp | 14 +++-- src/Magnum/Shaders/FlatGL.cpp | 18 ++++-- .../CreateCompatibilityShader.h | 55 ------------------- src/Magnum/Shaders/LineGL.cpp | 17 ++++-- src/Magnum/Shaders/MeshVisualizerGL.cpp | 22 +++++--- src/Magnum/Shaders/PhongGL.cpp | 16 ++++-- src/Magnum/Shaders/VectorGL.cpp | 14 +++-- src/Magnum/Shaders/VertexColorGL.cpp | 17 ++++-- src/Magnum/TextureTools/DistanceField.cpp | 13 +++-- 11 files changed, 96 insertions(+), 103 deletions(-) delete mode 100644 src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h diff --git a/src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp b/src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp index efe032dd6..4c148ed42 100644 --- a/src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp +++ b/src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -40,7 +41,6 @@ #include "Magnum/GL/Version.h" #include "Magnum/Math/Color.h" #include "Magnum/MeshTools/FullScreenTriangle.h" -#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" namespace Magnum { namespace MeshTools { namespace Test { namespace { @@ -81,16 +81,18 @@ void FullScreenTriangleGLTest::test() { FullscreenFlatShader(GL::Version version) { Utility::Resource rs{"FullScreenTriangleTest"}; - GL::Shader vert = Shaders::Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - vert.addSource(rs.getString("FullScreenTriangle.glsl")) + GL::Shader vert{version, GL::Shader::Type::Vertex}; + vert.addSource(rs.getString("compatibility.glsl")) + .addSource(rs.getString("FullScreenTriangle.glsl")) .addSource(R"( void main() { fullScreenTriangle(); } )"); - GL::Shader frag = Shaders::Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - frag.addSource(R"( + GL::Shader frag{version, GL::Shader::Type::Fragment}; + frag.addSource(rs.getString("compatibility.glsl")) + .addSource(R"( #ifdef NEW_GLSL out lowp vec4 fragmentColor; #else diff --git a/src/Magnum/Shaders/CMakeLists.txt b/src/Magnum/Shaders/CMakeLists.txt index 18dffa397..759466af1 100644 --- a/src/Magnum/Shaders/CMakeLists.txt +++ b/src/Magnum/Shaders/CMakeLists.txt @@ -73,7 +73,6 @@ set(MagnumShaders_HEADERS # Header files to display in project view of IDEs only set(MagnumShaders_PRIVATE_HEADERS - Implementation/CreateCompatibilityShader.h Implementation/lineMiterLimit.h) if(NOT MAGNUM_TARGET_GLES2) diff --git a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp index 9a88ea000..f61ab9ad4 100644 --- a/src/Magnum/Shaders/DistanceFieldVectorGL.cpp +++ b/src/Magnum/Shaders/DistanceFieldVectorGL.cpp @@ -45,7 +45,11 @@ #include "Magnum/GL/Buffer.h" #endif -#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" +#ifdef MAGNUM_BUILD_STATIC +static void importShaderResources() { + CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RESOURCES_GL) +} +#endif namespace Magnum { namespace Shaders { @@ -124,8 +128,9 @@ template typename DistanceFieldVectorGL::Com GL::Version::GLES300, GL::Version::GLES200}); #endif - GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - vert.addSource(configuration.flags() & Flag::TextureTransformation ? "#define TEXTURE_TRANSFORMATION\n"_s : ""_s) + GL::Shader vert{version, GL::Shader::Type::Vertex}; + vert.addSource(rs.getString("compatibility.glsl"_s)) + .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 if(configuration.flags() >= Flag::UniformBuffers) { @@ -151,7 +156,8 @@ template typename DistanceFieldVectorGL::Com .addSource(rs.getString("Vector.vert"_s)) .submitCompile(); - GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); + GL::Shader frag{version, GL::Shader::Type::Fragment}; + frag.addSource(rs.getString("compatibility.glsl"_s)); #ifndef MAGNUM_TARGET_GLES2 if(configuration.flags() >= Flag::UniformBuffers) { #ifndef MAGNUM_TARGET_WEBGL diff --git a/src/Magnum/Shaders/FlatGL.cpp b/src/Magnum/Shaders/FlatGL.cpp index fe5a5cbe9..d7e6d1b7e 100644 --- a/src/Magnum/Shaders/FlatGL.cpp +++ b/src/Magnum/Shaders/FlatGL.cpp @@ -38,8 +38,6 @@ #include "Magnum/Math/Matrix3.h" #include "Magnum/Math/Matrix4.h" -#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" - #ifndef MAGNUM_TARGET_GLES2 #include #include @@ -48,6 +46,12 @@ #include "Magnum/GL/TextureArray.h" #endif +#ifdef MAGNUM_BUILD_STATIC +static void importShaderResources() { + CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RESOURCES_GL) +} +#endif + namespace Magnum { namespace Shaders { using namespace Containers::Literals; @@ -180,8 +184,9 @@ template typename FlatGL::CompileState FlatG 1 : out._perInstanceJointCountUniform + 1; #endif - GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - vert.addSource((configuration.flags() & Flag::Textured + GL::Shader vert{version, GL::Shader::Type::Vertex}; + vert.addSource(rs.getString("compatibility.glsl"_s)) + .addSource((configuration.flags() & Flag::Textured #ifndef MAGNUM_TARGET_GLES2 || configuration.flags() >= Flag::ObjectIdTexture #endif @@ -286,8 +291,9 @@ template typename FlatGL::CompileState FlatG .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) + GL::Shader frag{version, GL::Shader::Type::Fragment}; + frag.addSource(rs.getString("compatibility.glsl"_s)) + .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) #endif diff --git a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h deleted file mode 100644 index 8779506bc..000000000 --- a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef Magnum_Shaders_Implementation_CreateCompatibilityShader_h -#define Magnum_Shaders_Implementation_CreateCompatibilityShader_h -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, - 2020, 2021, 2022, 2023 Vladimír Vondruš - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. -*/ - -#include -#include - -#include "Magnum/GL/Context.h" -#include "Magnum/GL/Extensions.h" -#include "Magnum/GL/Shader.h" - -/* Enable only when compiling Shaders library and thus work around - "static symbol not used" warning when using this file for TextureTools */ -#if defined(MAGNUM_BUILD_STATIC) && defined(MAGNUM_SHADERS_EXPORT) -static void importShaderResources() { - CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RESOURCES_GL) -} -#endif - -namespace Magnum { namespace Shaders { namespace Implementation { - -inline GL::Shader createCompatibilityShader(const Utility::Resource& rs, GL::Version version, GL::Shader::Type type) { - using namespace Containers::Literals; - - GL::Shader shader(version, type); - shader.addSource(rs.getString("compatibility.glsl"_s)); - return shader; -} - -}}} - -#endif diff --git a/src/Magnum/Shaders/LineGL.cpp b/src/Magnum/Shaders/LineGL.cpp index 442b3d25a..2e35de76e 100644 --- a/src/Magnum/Shaders/LineGL.cpp +++ b/src/Magnum/Shaders/LineGL.cpp @@ -39,9 +39,14 @@ #include "Magnum/Math/Matrix3.h" #include "Magnum/Math/Matrix4.h" #include "Magnum/Shaders/Line.h" -#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" #include "Magnum/Shaders/Implementation/lineMiterLimit.h" +#ifdef MAGNUM_BUILD_STATIC +static void importShaderResources() { + CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RESOURCES_GL) +} +#endif + namespace Magnum { namespace Shaders { using namespace Containers::Literals; @@ -145,8 +150,9 @@ template typename LineGL::CompileState LineG CORRADE_INTERNAL_ASSERT(capStyleDefine); CORRADE_INTERNAL_ASSERT(joinStyleDefine); - GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - vert.addSource(capStyleDefine) + GL::Shader vert{version, GL::Shader::Type::Vertex}; + vert.addSource(rs.getString("compatibility.glsl"_s)) + .addSource(capStyleDefine) .addSource(joinStyleDefine) .addSource(configuration.flags() & Flag::VertexColor ? "#define VERTEX_COLOR\n"_s : ""_s) .addSource(dimensions == 2 ? "#define TWO_DIMENSIONS\n"_s : "#define THREE_DIMENSIONS\n"_s) @@ -176,8 +182,9 @@ template typename LineGL::CompileState LineG .addSource(rs.getString("Line.vert"_s)) .submitCompile(); - GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - frag.addSource(capStyleDefine) + GL::Shader frag{version, GL::Shader::Type::Fragment}; + frag.addSource(rs.getString("compatibility.glsl"_s)) + .addSource(capStyleDefine) .addSource(joinStyleDefine) .addSource(configuration.flags() & Flag::VertexColor ? "#define VERTEX_COLOR\n"_s : ""_s) .addSource(configuration.flags() & Flag::ObjectId ? "#define OBJECT_ID\n"_s : ""_s) diff --git a/src/Magnum/Shaders/MeshVisualizerGL.cpp b/src/Magnum/Shaders/MeshVisualizerGL.cpp index 485892ee0..5b11bb4e5 100644 --- a/src/Magnum/Shaders/MeshVisualizerGL.cpp +++ b/src/Magnum/Shaders/MeshVisualizerGL.cpp @@ -46,7 +46,11 @@ #include "Magnum/GL/TextureArray.h" #endif -#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" +#ifdef MAGNUM_BUILD_STATIC +static void importShaderResources() { + CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RESOURCES_GL) +} +#endif namespace Magnum { namespace Shaders { @@ -187,8 +191,9 @@ GL::Version MeshVisualizerGLBase::setupShaders(GL::Shader& vert, GL::Shader& fra const GL::Version version = context.supportedVersion({GL::Version::GLES300, GL::Version::GLES200}); #endif - vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - vert.addSource(flags & FlagBase::Wireframe ? "#define WIREFRAME_RENDERING\n"_s : ""_s) + vert = GL::Shader{version, GL::Shader::Type::Vertex}; + vert.addSource(rs.getString("compatibility.glsl"_s)) + .addSource(flags & FlagBase::Wireframe ? "#define WIREFRAME_RENDERING\n"_s : ""_s) #ifndef MAGNUM_TARGET_GLES2 .addSource(flags >= FlagBase::ObjectIdTexture ? "#define TEXTURED\n"_s : ""_s) .addSource(flags & FlagBase::TextureTransformation ? "#define TEXTURE_TRANSFORMATION\n"_s : ""_s) @@ -296,8 +301,9 @@ GL::Version MeshVisualizerGLBase::setupShaders(GL::Shader& vert, GL::Shader& fra } #endif - frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - frag.addSource(flags & FlagBase::Wireframe ? "#define WIREFRAME_RENDERING\n"_s : ""_s) + frag = GL::Shader{version, GL::Shader::Type::Fragment}; + frag.addSource(rs.getString("compatibility.glsl"_s)) + .addSource(flags & FlagBase::Wireframe ? "#define WIREFRAME_RENDERING\n"_s : ""_s) #ifndef MAGNUM_TARGET_GLES2 .addSource(flags & FlagBase::ObjectId ? "#define OBJECT_ID\n"_s : ""_s) .addSource(flags >= FlagBase::ObjectIdTexture ? "#define OBJECT_ID_TEXTURE\n"_s : ""_s) @@ -648,8 +654,9 @@ MeshVisualizerGL2D::CompileState MeshVisualizerGL2D::compile(const Configuration #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(configuration.flags() & Flag::Wireframe && !(configuration.flags() & Flag::NoGeometryShader)) { - geom = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Geometry); + geom = GL::Shader{version, GL::Shader::Type::Geometry}; (*geom) + .addSource(rs.getString("compatibility.glsl"_s)) .addSource("#define WIREFRAME_RENDERING\n#define MAX_VERTICES 3\n"_s) .addSource(baseFlags >= FlagBase::ObjectIdTexture ? "#define TEXTURED\n"_s : ""_s) .addSource(baseFlags & FlagBase::TextureArrays ? "#define TEXTURE_ARRAYS\n"_s : ""_s) @@ -1172,8 +1179,9 @@ MeshVisualizerGL3D::CompileState MeshVisualizerGL3D::compile(const Configuration maxVertices += 3*6; if(configuration.flags() & Flag::NormalDirection) maxVertices += 3*6; - geom = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Geometry); + geom = GL::Shader{version, GL::Shader::Type::Geometry}; (*geom) + .addSource(rs.getString("compatibility.glsl"_s)) .addSource(Utility::format("#define MAX_VERTICES {}\n", maxVertices)) .addSource(configuration.flags() & Flag::Wireframe ? "#define WIREFRAME_RENDERING\n"_s : ""_s) .addSource(baseFlags >= FlagBase::ObjectIdTexture ? "#define TEXTURED\n"_s : ""_s) diff --git a/src/Magnum/Shaders/PhongGL.cpp b/src/Magnum/Shaders/PhongGL.cpp index c5286abad..05e89a117 100644 --- a/src/Magnum/Shaders/PhongGL.cpp +++ b/src/Magnum/Shaders/PhongGL.cpp @@ -49,7 +49,11 @@ #include "Magnum/GL/TextureArray.h" #endif -#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" +#ifdef MAGNUM_BUILD_STATIC +static void importShaderResources() { + CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RESOURCES_GL) +} +#endif namespace Magnum { namespace Shaders { @@ -222,8 +226,9 @@ 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) + GL::Shader vert{version, GL::Shader::Type::Vertex}; + vert.addSource(rs.getString("compatibility.glsl"_s)) + .addSource((configuration.flags() & (Flag::AmbientTexture|Flag::DiffuseTexture|Flag::SpecularTexture|Flag::NormalTexture) #ifndef MAGNUM_TARGET_GLES2 || configuration.flags() >= Flag::ObjectIdTexture #endif @@ -332,8 +337,9 @@ PhongGL::CompileState PhongGL::compile(const Configuration& configuration) { .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) + GL::Shader frag{version, GL::Shader::Type::Fragment}; + frag.addSource(rs.getString("compatibility.glsl"_s)) + .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) .addSource(configuration.flags() & Flag::NormalTexture ? "#define NORMAL_TEXTURE\n"_s : ""_s) diff --git a/src/Magnum/Shaders/VectorGL.cpp b/src/Magnum/Shaders/VectorGL.cpp index 2c239a9a8..c4539f901 100644 --- a/src/Magnum/Shaders/VectorGL.cpp +++ b/src/Magnum/Shaders/VectorGL.cpp @@ -45,7 +45,11 @@ #include "Magnum/GL/Buffer.h" #endif -#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" +#ifdef MAGNUM_BUILD_STATIC +static void importShaderResources() { + CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RESOURCES_GL) +} +#endif namespace Magnum { namespace Shaders { @@ -124,8 +128,9 @@ template typename VectorGL::CompileState Vec GL::Version::GLES300, GL::Version::GLES200}); #endif - GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - vert.addSource(configuration.flags() & Flag::TextureTransformation ? "#define TEXTURE_TRANSFORMATION\n"_s : ""_s) + GL::Shader vert{version, GL::Shader::Type::Vertex}; + vert.addSource(rs.getString("compatibility.glsl"_s)) + .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 if(configuration.flags() >= Flag::UniformBuffers) { @@ -151,7 +156,8 @@ template typename VectorGL::CompileState Vec .addSource(rs.getString("Vector.vert"_s)) .submitCompile(); - GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); + GL::Shader frag{version, GL::Shader::Type::Fragment}; + frag.addSource(rs.getString("compatibility.glsl"_s)); #ifndef MAGNUM_TARGET_GLES2 if(configuration.flags() >= Flag::UniformBuffers) { #ifndef MAGNUM_TARGET_WEBGL diff --git a/src/Magnum/Shaders/VertexColorGL.cpp b/src/Magnum/Shaders/VertexColorGL.cpp index fbe691ff3..506af899d 100644 --- a/src/Magnum/Shaders/VertexColorGL.cpp +++ b/src/Magnum/Shaders/VertexColorGL.cpp @@ -32,6 +32,7 @@ #include "Magnum/GL/Context.h" #include "Magnum/GL/Extensions.h" +#include "Magnum/GL/Shader.h" #include "Magnum/Math/Color.h" #include "Magnum/Math/Matrix3.h" #include "Magnum/Math/Matrix4.h" @@ -43,7 +44,11 @@ #include "Magnum/GL/Buffer.h" #endif -#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" +#ifdef MAGNUM_BUILD_STATIC +static void importShaderResources() { + CORRADE_RESOURCE_INITIALIZE(MagnumShaders_RESOURCES_GL) +} +#endif namespace Magnum { namespace Shaders { @@ -115,8 +120,9 @@ template typename VertexColorGL::CompileStat GL::Version::GLES300, GL::Version::GLES200}); #endif - GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); - vert.addSource(dimensions == 2 ? "#define TWO_DIMENSIONS\n"_s : "#define THREE_DIMENSIONS\n"_s); + GL::Shader vert{version, GL::Shader::Type::Vertex}; + vert.addSource(rs.getString("compatibility.glsl"_s)) + .addSource(dimensions == 2 ? "#define TWO_DIMENSIONS\n"_s : "#define THREE_DIMENSIONS\n"_s); #ifndef MAGNUM_TARGET_GLES2 if(configuration.flags() >= Flag::UniformBuffers) { #ifndef MAGNUM_TARGET_WEBGL @@ -141,8 +147,9 @@ template typename VertexColorGL::CompileStat .addSource(rs.getString("VertexColor.vert"_s)) .submitCompile(); - GL::Shader frag = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Fragment); - frag.addSource(rs.getString("generic.glsl"_s)) + GL::Shader frag{version, GL::Shader::Type::Fragment}; + frag.addSource(rs.getString("compatibility.glsl"_s)) + .addSource(rs.getString("generic.glsl"_s)) .addSource(rs.getString("VertexColor.frag"_s)) .submitCompile(); diff --git a/src/Magnum/TextureTools/DistanceField.cpp b/src/Magnum/TextureTools/DistanceField.cpp index 3d5ea5d45..bfc540ef0 100644 --- a/src/Magnum/TextureTools/DistanceField.cpp +++ b/src/Magnum/TextureTools/DistanceField.cpp @@ -39,7 +39,6 @@ #include "Magnum/GL/Mesh.h" #include "Magnum/GL/Shader.h" #include "Magnum/GL/Texture.h" -#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" #ifdef MAGNUM_BUILD_STATIC static void importTextureToolResources() { @@ -103,12 +102,14 @@ DistanceFieldShader::DistanceFieldShader(const UnsignedInt radius) { GL::Version::GLES300, GL::Version::GLES200}); #endif - GL::Shader vert = Shaders::Implementation::createCompatibilityShader(rs, v, GL::Shader::Type::Vertex); - GL::Shader frag = Shaders::Implementation::createCompatibilityShader(rs, v, GL::Shader::Type::Fragment); - - vert.addSource(rs.getString("FullScreenTriangle.glsl"_s)) + GL::Shader vert{v, GL::Shader::Type::Vertex}; + vert.addSource(rs.getString("compatibility.glsl"_s)) + .addSource(rs.getString("FullScreenTriangle.glsl"_s)) .addSource(rs.getString("DistanceFieldShader.vert"_s)); - frag.addSource(Utility::format("#define RADIUS {}\n", radius)) + + GL::Shader frag{v, GL::Shader::Type::Fragment}; + frag.addSource(rs.getString("compatibility.glsl"_s)) + .addSource(Utility::format("#define RADIUS {}\n", radius)) .addSource(rs.getString("DistanceFieldShader.frag"_s)); CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile() && frag.compile());