diff --git a/src/libprojectM/BackgroundWorker.hpp b/src/libprojectM/BackgroundWorker.hpp index 74d3e2c35..37ef8b5c8 100644 --- a/src/libprojectM/BackgroundWorker.hpp +++ b/src/libprojectM/BackgroundWorker.hpp @@ -3,6 +3,8 @@ #include #include +namespace libprojectM { + /** * Small class to encapsulate synchronization of a simple background task runner */ @@ -70,3 +72,5 @@ private: volatile bool m_finished{ false }; }; + +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/BlurTexture.cpp b/src/libprojectM/MilkdropPreset/BlurTexture.cpp index 5f8bd2e51..637dc2bff 100644 --- a/src/libprojectM/MilkdropPreset/BlurTexture.cpp +++ b/src/libprojectM/MilkdropPreset/BlurTexture.cpp @@ -7,8 +7,11 @@ #include +namespace libprojectM { +namespace MilkdropPreset { + BlurTexture::BlurTexture() - : m_blurSampler(std::make_shared(GL_CLAMP_TO_EDGE, GL_LINEAR)) + : m_blurSampler(std::make_shared(GL_CLAMP_TO_EDGE, GL_LINEAR)) { auto staticShaders = libprojectM::MilkdropPreset::MilkdropStaticShaders::Get(); @@ -38,7 +41,7 @@ BlurTexture::BlurTexture() glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, nullptr); // Position at index 0 and 1 + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, nullptr); // Position at index 0 and 1 glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, reinterpret_cast(sizeof(float) * 2)); // Texture coord at index 2 and 3 glBindVertexArray(0); @@ -53,7 +56,7 @@ BlurTexture::BlurTexture() textureName = "blur" + std::to_string(i / 2 + 1); } - m_blurTextures[i] = std::make_shared(textureName, 0, GL_TEXTURE_2D, 0, 0, false); + m_blurTextures[i] = std::make_shared(textureName, 0, GL_TEXTURE_2D, 0, 0, false); } } @@ -68,9 +71,9 @@ void BlurTexture::SetRequiredBlurLevel(BlurTexture::BlurLevel level) m_blurLevel = std::max(level, m_blurLevel); } -auto BlurTexture::GetDescriptorsForBlurLevel(BlurTexture::BlurLevel blurLevel) const -> std::vector +auto BlurTexture::GetDescriptorsForBlurLevel(BlurTexture::BlurLevel blurLevel) const -> std::vector { - std::vector descriptors; + std::vector descriptors; if (blurLevel == BlurLevel::Blur3) { @@ -91,7 +94,7 @@ auto BlurTexture::GetDescriptorsForBlurLevel(BlurTexture::BlurLevel blurLevel) c return descriptors; } -void BlurTexture::Update(const Texture& sourceTexture, const PerFrameContext& perFrameContext) +void BlurTexture::Update(const Renderer::Texture& sourceTexture, const PerFrameContext& perFrameContext) { if (m_blurLevel == BlurLevel::None) { @@ -150,7 +153,7 @@ void BlurTexture::Update(const Texture& sourceTexture, const PerFrameContext& pe } // set pixel shader - Shader* blurShader; + Renderer::Shader* blurShader; if ((pass % 2) == 0) { blurShader = &m_blur1Shader; @@ -255,10 +258,10 @@ void BlurTexture::Update(const Texture& sourceTexture, const PerFrameContext& pe glBindFramebuffer(GL_DRAW_FRAMEBUFFER, origDrawFramebuffer); glViewport(0, 0, sourceTexture.Width(), sourceTexture.Height()); - Shader::Unbind(); + Renderer::Shader::Unbind(); } -void BlurTexture::Bind(GLint& unit, Shader& shader) const +void BlurTexture::Bind(GLint& unit, Renderer::Shader& shader) const { for (size_t i = 0; i < static_cast(m_blurLevel) * 2; i++) { @@ -309,7 +312,7 @@ void BlurTexture::GetSafeBlurMinMaxValues(const PerFrameContext& perFrameContext } } -void BlurTexture::AllocateTextures(const Texture& sourceTexture) +void BlurTexture::AllocateTextures(const Renderer::Texture& sourceTexture) { int width = sourceTexture.Width(); int height = sourceTexture.Height(); @@ -354,9 +357,12 @@ void BlurTexture::AllocateTextures(const Texture& sourceTexture) } // This will automatically replace any old texture. - m_blurTextures[i] = std::make_shared(textureName, width2, height2, false); + m_blurTextures[i] = std::make_shared(textureName, width2, height2, false); } m_sourceTextureWidth = sourceTexture.Width(); m_sourceTextureHeight = sourceTexture.Height(); } + +} // namespace MilkdropPreset +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/BlurTexture.hpp b/src/libprojectM/MilkdropPreset/BlurTexture.hpp index 8ac566b7e..2f6a7998e 100644 --- a/src/libprojectM/MilkdropPreset/BlurTexture.hpp +++ b/src/libprojectM/MilkdropPreset/BlurTexture.hpp @@ -11,6 +11,9 @@ #include #include +namespace libprojectM { +namespace MilkdropPreset { + class PerFrameContext; class PresetState; @@ -58,14 +61,14 @@ public: * The blur textures don't need to be present and can be empty placeholders. * @param blurLevel The blur level. */ - auto GetDescriptorsForBlurLevel(BlurLevel blurLevel) const -> std::vector; + auto GetDescriptorsForBlurLevel(BlurLevel blurLevel) const -> std::vector; /** * @brief Renders the required blur passes on the given texture. * @param sourceTexture The texture to create the blur levels from. * @param perFrameContext The per-frame variables. */ - void Update(const Texture& sourceTexture, const PerFrameContext& perFrameContext); + void Update(const Renderer::Texture& sourceTexture, const PerFrameContext& perFrameContext); /** * @brief Binds the user-readable blur textures to the texture slots starting with the given index. @@ -74,7 +77,7 @@ public: * free unit, which can be the same as the input slot if no blur textures * are used. */ - void Bind(GLint& unit, Shader& shader) const; + void Bind(GLint& unit, Renderer::Shader& shader) const; /** * @brief Returns properly scaled and clamped vlur values from the given context. @@ -93,19 +96,22 @@ private: * Allocates the blur textures. * @param sourceTexture The source texture. */ - void AllocateTextures(const Texture& sourceTexture); + void AllocateTextures(const Renderer::Texture& sourceTexture); GLuint m_vboBlur; //!< Vertex buffer object for the fullscreen blur quad. GLuint m_vaoBlur; //!< Vertex array object for the fullscreen blur quad. - Shader m_blur1Shader; //!< The shader used on the first blur pass. - Shader m_blur2Shader; //!< The shader used for subsequent blur passes after the initial pass. + Renderer::Shader m_blur1Shader; //!< The shader used on the first blur pass. + Renderer::Shader m_blur2Shader; //!< The shader used for subsequent blur passes after the initial pass. - int m_sourceTextureWidth{}; //!< Width of the source texture used to create the blur textures. + int m_sourceTextureWidth{}; //!< Width of the source texture used to create the blur textures. int m_sourceTextureHeight{}; //!< Height of the source texture used to create the blur textures. - Framebuffer m_blurFramebuffer; //!< The framebuffer used to draw the blur textures. - std::shared_ptr m_blurSampler; //!< The blur sampler. - std::array, NumBlurTextures> m_blurTextures; //!< The blur textures for each pass. - BlurLevel m_blurLevel{BlurLevel::None}; //!< Current blur level. + Renderer::Framebuffer m_blurFramebuffer; //!< The framebuffer used to draw the blur textures. + std::shared_ptr m_blurSampler; //!< The blur sampler. + std::array, NumBlurTextures> m_blurTextures; //!< The blur textures for each pass. + BlurLevel m_blurLevel{BlurLevel::None}; //!< Current blur level. }; + +} // namespace MilkdropPreset +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/Border.cpp b/src/libprojectM/MilkdropPreset/Border.cpp index 0df79cec7..e20ff17ba 100644 --- a/src/libprojectM/MilkdropPreset/Border.cpp +++ b/src/libprojectM/MilkdropPreset/Border.cpp @@ -2,6 +2,9 @@ #include +namespace libprojectM { +namespace MilkdropPreset { + Border::Border(PresetState& presetState) : RenderItem() , m_presetState(presetState) @@ -75,9 +78,12 @@ void Border::Draw(const PerFrameContext& presetPerFrameContext) } } - Shader::Unbind(); + Renderer::Shader::Unbind(); glDisable(GL_BLEND); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); } + +} // namespace MilkdropPreset +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/Border.hpp b/src/libprojectM/MilkdropPreset/Border.hpp index e71ab532f..8b258f6d0 100644 --- a/src/libprojectM/MilkdropPreset/Border.hpp +++ b/src/libprojectM/MilkdropPreset/Border.hpp @@ -5,10 +5,14 @@ #include "Renderer/RenderItem.hpp" +namespace libprojectM { +namespace MilkdropPreset { + + /** * @brief Renders a border around the screen. */ -class Border : public RenderItem +class Border : public Renderer::RenderItem { public: Border() = delete; @@ -26,3 +30,6 @@ public: private: PresetState& m_presetState; //!< The global preset state. }; + +} // namespace MilkdropPreset +} // namespace libprojectM diff --git a/src/libprojectM/MilkdropPreset/CMakeLists.txt b/src/libprojectM/MilkdropPreset/CMakeLists.txt index 5b95364d2..ba2e8bdb8 100644 --- a/src/libprojectM/MilkdropPreset/CMakeLists.txt +++ b/src/libprojectM/MilkdropPreset/CMakeLists.txt @@ -61,8 +61,8 @@ add_library(MilkdropPreset OBJECT MilkdropPreset.cpp MilkdropPreset.hpp MilkdropPresetExceptions.hpp - MilkdropPresetFactory.cpp - MilkdropPresetFactory.hpp + Factory.cpp + Factory.hpp MilkdropShader.cpp MilkdropShader.hpp MilkdropStaticShaders.cpp.in diff --git a/src/libprojectM/MilkdropPreset/Constants.hpp b/src/libprojectM/MilkdropPreset/Constants.hpp index 1d9d71cd9..407769678 100644 --- a/src/libprojectM/MilkdropPreset/Constants.hpp +++ b/src/libprojectM/MilkdropPreset/Constants.hpp @@ -6,6 +6,9 @@ #include