From 79838bffe3d198bf3e04e821378c21df1fe996e5 Mon Sep 17 00:00:00 2001 From: vlj Date: Thu, 26 Jun 2014 00:46:55 +0200 Subject: [PATCH] Add 50% transparency to minimap. --- data/shaders/uniformcolortexturedquad.frag | 2 +- src/graphics/glwrap.cpp | 13 ++++++++++--- src/graphics/glwrap.hpp | 2 +- src/guiengine/skin.cpp | 2 +- src/states_screens/race_gui.cpp | 2 +- src/states_screens/race_gui_overworld.cpp | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/data/shaders/uniformcolortexturedquad.frag b/data/shaders/uniformcolortexturedquad.frag index a4208f639..608da17ec 100644 --- a/data/shaders/uniformcolortexturedquad.frag +++ b/data/shaders/uniformcolortexturedquad.frag @@ -12,5 +12,5 @@ varying vec2 uv; void main() { vec4 res = texture(tex, uv); - FragColor = vec4(res.xyz * color.xyz / 255., res.a); + FragColor = res * color / 255.; } diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index 37f6cefe1..75e311bc0 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -779,7 +779,7 @@ void draw2DImage(const video::ITexture* texture, const core::rect& destRect void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h, const core::rect& destRect, const core::rect& sourceRect, const core::rect* clipRect, - bool useAlphaChannelOfTexture) + const video::SColor &colors, bool useAlphaChannelOfTexture) { if (useAlphaChannelOfTexture) { @@ -794,9 +794,16 @@ void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h, getSize(texture_w, texture_h, true, destRect, sourceRect, width, height, center_pos_x, center_pos_y, tex_width, tex_height, tex_center_pos_x, tex_center_pos_y); - drawTexQuad(texture, width, height, center_pos_x, center_pos_y, - tex_center_pos_x, tex_center_pos_y, tex_width, tex_height); + glUseProgram(UIShader::UniformColoredTextureRectShader::Program); + glBindVertexArray(UIShader::UniformColoredTextureRectShader::vao); + + setTexture(0, texture, GL_LINEAR, GL_LINEAR); + UIShader::UniformColoredTextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, colors, 0); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + glBindVertexArray(0); + glBindBuffer(GL_ARRAY_BUFFER, 0); } void draw2DImage(const video::ITexture* texture, const core::rect& destRect, diff --git a/src/graphics/glwrap.hpp b/src/graphics/glwrap.hpp index 9a735b3ec..1457a1e4e 100644 --- a/src/graphics/glwrap.hpp +++ b/src/graphics/glwrap.hpp @@ -224,7 +224,7 @@ void draw3DLine(const core::vector3df& start, void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h, const core::rect& destRect, const core::rect& sourceRect, const core::rect* clipRect, - bool useAlphaChannelOfTexture); + const video::SColor &colors, bool useAlphaChannelOfTexture); void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect& destRect, const irr::core::rect& sourceRect, const irr::core::rect* clipRect, diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp index 1f4048017..af78b6315 100644 --- a/src/guiengine/skin.cpp +++ b/src/guiengine/skin.cpp @@ -1922,7 +1922,7 @@ void Skin::process3DPane(IGUIElement *element, const core::recti &rect, if (fb != NULL && fb->getRTT().size() > 0) { draw2DImageFromRTT(fb->getRTT()[0], 512, 512, - rect, core::rect(0, 0, 512, 512), NULL, true); + rect, core::rect(0, 0, 512, 512), NULL, SColor(255, 255, 255, 255), true); } } else if (type == WTYPE_ICON_BUTTON || type == WTYPE_MODEL_VIEW) diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index 8bc797412..38b43a193 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -363,7 +363,7 @@ void RaceGUI::drawGlobalMiniMap() core::rect source(0, 0, new_rtt_mini_map->getWidth(), new_rtt_mini_map->getHeight()); draw2DImageFromRTT(new_rtt_mini_map->getRTT()[0], new_rtt_mini_map->getWidth(), new_rtt_mini_map->getHeight(), - dest, source, NULL, true); + dest, source, NULL, video::SColor(127, 255, 255, 255), true); } for(unsigned int i=0; igetNumKarts(); i++) diff --git a/src/states_screens/race_gui_overworld.cpp b/src/states_screens/race_gui_overworld.cpp index b5312fbe5..a2a7299f8 100644 --- a/src/states_screens/race_gui_overworld.cpp +++ b/src/states_screens/race_gui_overworld.cpp @@ -340,7 +340,7 @@ void RaceGUIOverworld::drawGlobalMiniMap() core::rect source(0, 0, new_rtt_mini_map->getWidth(), new_rtt_mini_map->getHeight()); draw2DImageFromRTT(new_rtt_mini_map->getRTT()[0], new_rtt_mini_map->getWidth(), new_rtt_mini_map->getHeight(), - dest, source, NULL, true); + dest, source, NULL, video::SColor(127, 255, 255, 255), true); } Vec3 kart_xyz;