From a019b5167b90cb5d78458737f65d5dc39ff1d5d5 Mon Sep 17 00:00:00 2001 From: kimci86 Date: Sat, 27 Jan 2024 15:36:42 +0100 Subject: [PATCH] Make Shader::Type a scoped enumeration --- examples/shader/Shader.cpp | 4 ++-- include/SFML/Graphics/Shader.hpp | 2 +- src/SFML/Graphics/Shader.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/shader/Shader.cpp b/examples/shader/Shader.cpp index 308add21d..106cfb5bc 100644 --- a/examples/shader/Shader.cpp +++ b/examples/shader/Shader.cpp @@ -33,7 +33,7 @@ public: m_sprite.emplace(m_texture); // Load the shader - if (!m_shader.loadFromFile("resources/pixelate.frag", sf::Shader::Fragment)) + if (!m_shader.loadFromFile("resources/pixelate.frag", sf::Shader::Type::Fragment)) return false; m_shader.setUniform("texture", sf::Shader::CurrentTexture); @@ -209,7 +209,7 @@ public: } // Load the shader - if (!m_shader.loadFromFile("resources/edge.frag", sf::Shader::Fragment)) + if (!m_shader.loadFromFile("resources/edge.frag", sf::Shader::Type::Fragment)) return false; m_shader.setUniform("texture", sf::Shader::CurrentTexture); diff --git a/include/SFML/Graphics/Shader.hpp b/include/SFML/Graphics/Shader.hpp index 24be18afa..88c5e6d6c 100644 --- a/include/SFML/Graphics/Shader.hpp +++ b/include/SFML/Graphics/Shader.hpp @@ -59,7 +59,7 @@ public: /// \brief Types of shaders /// //////////////////////////////////////////////////////////// - enum Type + enum class Type { Vertex, //!< %Vertex shader Geometry, //!< Geometry shader diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index f691966c5..0bd41157c 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -281,9 +281,9 @@ bool Shader::loadFromFile(const std::filesystem::path& filename, Type type) } // Compile the shader program - if (type == Vertex) + if (type == Type::Vertex) return compile(shader.data(), nullptr, nullptr); - else if (type == Geometry) + else if (type == Type::Geometry) return compile(nullptr, shader.data(), nullptr); else return compile(nullptr, nullptr, shader.data()); @@ -353,9 +353,9 @@ bool Shader::loadFromFile(const std::filesystem::path& vertexShaderFilename, bool Shader::loadFromMemory(const std::string& shader, Type type) { // Compile the shader program - if (type == Vertex) + if (type == Type::Vertex) return compile(shader.c_str(), nullptr, nullptr); - else if (type == Geometry) + else if (type == Type::Geometry) return compile(nullptr, shader.c_str(), nullptr); else return compile(nullptr, nullptr, shader.c_str()); @@ -390,9 +390,9 @@ bool Shader::loadFromStream(InputStream& stream, Type type) } // Compile the shader program - if (type == Vertex) + if (type == Type::Vertex) return compile(shader.data(), nullptr, nullptr); - else if (type == Geometry) + else if (type == Type::Geometry) return compile(nullptr, shader.data(), nullptr); else return compile(nullptr, nullptr, shader.data());