X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2Fshader.cpp;h=0f372d014915478dda1c2c94a6a0cb4d58193b42;hb=ab817024b3c02a54a376fa8f60b5046e51128ebb;hp=0a31360e7adc4877836660177166563dab237676;hpb=76b630bd0a147bf7c78d3380237c86b9bfc48530;p=blobs.git diff --git a/src/graphics/shader.cpp b/src/graphics/shader.cpp index 0a31360..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" @@ -673,10 +673,10 @@ PlainColor::PlainColor() vao.ReserveAttributes(4, GL_STATIC_DRAW); { auto attrib = vao.MapAttributes(GL_WRITE_ONLY); - attrib[0].position = glm::vec3(-1.0f, -1.0f, 0.0f); - attrib[1].position = glm::vec3(-1.0f, 1.0f, 0.0f); - attrib[2].position = glm::vec3( 1.0f, -1.0f, 0.0f); - attrib[3].position = glm::vec3( 1.0f, 1.0f, 0.0f); + attrib[0].position = glm::vec3(-0.5f, -0.5f, 0.0f); + attrib[1].position = glm::vec3(-0.5f, 0.5f, 0.0f); + attrib[2].position = glm::vec3( 0.5f, -0.5f, 0.0f); + attrib[3].position = glm::vec3( 0.5f, 0.5f, 0.0f); } vao.BindElements(); vao.ReserveElements(7, GL_STATIC_DRAW); @@ -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); } @@ -807,13 +808,13 @@ AlphaSprite::AlphaSprite() vao.ReserveAttributes(4, GL_STATIC_DRAW); { auto attrib = vao.MapAttributes(GL_WRITE_ONLY); - attrib[0].position = glm::vec3(-1.0f, -1.0f, 0.0f); + attrib[0].position = glm::vec3(-0.5f, -0.5f, 0.0f); attrib[0].texture = glm::vec2(0.0f, 0.0f); - attrib[1].position = glm::vec3(-1.0f, 1.0f, 0.0f); + attrib[1].position = glm::vec3(-0.5f, 0.5f, 0.0f); attrib[1].texture = glm::vec2(0.0f, 1.0f); - attrib[2].position = glm::vec3( 1.0f, -1.0f, 0.0f); + attrib[2].position = glm::vec3( 0.5f, -0.5f, 0.0f); attrib[2].texture = glm::vec2(1.0f, 0.0f); - attrib[3].position = glm::vec3( 1.0f, 1.0f, 0.0f); + attrib[3].position = glm::vec3( 0.5f, 0.5f, 0.0f); attrib[3].texture = glm::vec2(1.0f, 1.0f); } vao.BindElements();