From: Daniel Karbach Date: Mon, 20 Nov 2017 07:57:05 +0000 (+0100) Subject: allow alpha in plain color shader X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=f7fdde845eb7bb84ca83ae8cf7361abce8b2086e;p=blobs.git allow alpha in plain color shader --- diff --git a/src/graphics/PlainColor.hpp b/src/graphics/PlainColor.hpp index 660ca93..534218b 100644 --- a/src/graphics/PlainColor.hpp +++ b/src/graphics/PlainColor.hpp @@ -30,7 +30,7 @@ public: void SetM(const glm::mat4 &m) noexcept; void SetVP(const glm::mat4 &v, const glm::mat4 &p) noexcept; void SetMVP(const glm::mat4 &m, const glm::mat4 &v, const glm::mat4 &p) noexcept; - void SetColor(const glm::vec3 &color) noexcept; + void SetColor(const glm::vec4 &color) noexcept; const glm::mat4 &M() const noexcept { return m; } const glm::mat4 &V() const noexcept { return v; } diff --git a/src/graphics/shader.cpp b/src/graphics/shader.cpp index b14da4d..0f372d0 100644 --- a/src/graphics/shader.cpp +++ b/src/graphics/shader.cpp @@ -648,9 +648,9 @@ PlainColor::PlainColor() GL_FRAGMENT_SHADER, "#version 330 core\n" - "uniform vec3 fg_color;\n" + "uniform vec4 fg_color;\n" - "out vec3 color;\n" + "out vec4 color;\n" "void main() {\n" "color = fg_color;\n" @@ -701,7 +701,8 @@ void PlainColor::Activate() noexcept { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_CULL_FACE); - glDisable(GL_BLEND); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } void PlainColor::SetM(const glm::mat4 &mm) noexcept { @@ -733,7 +734,7 @@ void PlainColor::SetMVP(const glm::mat4 &mm, const glm::mat4 &vv, const glm::mat prog.Uniform(mvp_handle, mvp); } -void PlainColor::SetColor(const glm::vec3 &color) noexcept { +void PlainColor::SetColor(const glm::vec4 &color) noexcept { prog.Uniform(fg_color_handle, color); }