From 031877a83abc6989e599d42950946a255281c715 Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Thu, 25 Jun 2015 21:21:47 +0200 Subject: [PATCH] added switch for Transparency -> F9 --- Weave/Events.cpp | 10 +++++++--- Weave/Graphix/Graphix.cpp | 16 ++++++++++++++++ Weave/Graphix/Graphix.h | 3 +++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Weave/Events.cpp b/Weave/Events.cpp index e763a11..d156113 100644 --- a/Weave/Events.cpp +++ b/Weave/Events.cpp @@ -122,13 +122,17 @@ void Events::KeyDown(int _key) break; case SDLK_F9: //TRANSPARENCY + if (!key_toggle[SDLK_F9]) + Graphix::disableEffects(EF_TRANSPARENCY); + else + Graphix::enableEffects(EF_TRANSPARENCY); break; case SDLK_F10: //??? FullScreen - if (key_toggle[SDLK_F10]) - Graphix::FullScreen(false,true); - else + if (!key_toggle[SDLK_F10]) Graphix::FullScreen(true,true); + else + Graphix::FullScreen(false,true); break; case SDLK_SPACE: jump++; diff --git a/Weave/Graphix/Graphix.cpp b/Weave/Graphix/Graphix.cpp index 5f91b01..5f5d40a 100644 --- a/Weave/Graphix/Graphix.cpp +++ b/Weave/Graphix/Graphix.cpp @@ -34,12 +34,16 @@ unsigned int Graphix::getWindowWidth() void Graphix::enableEffects(Effects _eff) { effects |= _eff; + + updateEffects(); } void Graphix::disableEffects(Effects _eff) { effects &= ~_eff; + + updateEffects(); } bool Graphix::testEffect(Effects _eff) @@ -47,6 +51,18 @@ bool Graphix::testEffect(Effects _eff) return effects & _eff; } +void Graphix::updateEffects() +{ + //Transparency + if (effects & EF_TRANSPARENCY) + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else + glDisable(GL_BLEND); +} + void Graphix::init() { diff --git a/Weave/Graphix/Graphix.h b/Weave/Graphix/Graphix.h index 3d4d3cb..bde1f6a 100644 --- a/Weave/Graphix/Graphix.h +++ b/Weave/Graphix/Graphix.h @@ -45,6 +45,9 @@ public: static Shader* shader_BBox; private: + + static void updateEffects(); + static unsigned int xpos, ypos, width, height; static unsigned int width_bkp, height_bkp; -- 2.47.3