From ba8f8b889eb87054498ef2c64ffa90e782516864 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 28 Aug 2011 15:06:47 -0300 Subject: [PATCH] simplify outfit render --- src/framework/const.h | 2 +- src/framework/graphics/graphics.cpp | 4 ++-- src/otclient/core/creature.cpp | 30 +++++++++++++++-------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/framework/const.h b/src/framework/const.h index a04723f2..9315f6a8 100644 --- a/src/framework/const.h +++ b/src/framework/const.h @@ -58,7 +58,7 @@ namespace Fw }; enum BlendFunc { - BlendNormal, + BlendDefault, BlendColorzing }; diff --git a/src/framework/graphics/graphics.cpp b/src/framework/graphics/graphics.cpp index 35a30898..3ab0c6bb 100644 --- a/src/framework/graphics/graphics.cpp +++ b/src/framework/graphics/graphics.cpp @@ -51,7 +51,7 @@ void Graphics::init() m_emptyTexture = TexturePtr(new Texture); bindColor(Fw::white); - bindBlendFunc(Fw::BlendNormal); + bindBlendFunc(Fw::BlendDefault); } void Graphics::terminate() @@ -302,7 +302,7 @@ void Graphics::bindTexture(const TexturePtr& texture) void Graphics::bindBlendFunc(Fw::BlendFunc blendType) { switch(blendType) { - case Fw::BlendNormal: + case Fw::BlendDefault: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; case Fw::BlendColorzing: diff --git a/src/otclient/core/creature.cpp b/src/otclient/core/creature.cpp index 3e7a17d8..573cb784 100644 --- a/src/otclient/core/creature.cpp +++ b/src/otclient/core/creature.cpp @@ -117,25 +117,27 @@ void Creature::draw(int x, int y) // draw mask if exists if(attributes.blendframes > 1) { + // switch to blend color mode g_graphics.bindBlendFunc(Fw::BlendColorzing); - for(int mask = 0; mask < 4; ++mask) { + // head + g_graphics.bindColor(Otc::OutfitColors[m_outfit.head]); + internalDraw(x, y, 1, m_direction, ydiv, 0, m_animation, Otc::SpriteYellowMask); - int outfitColorId = 0; - if(mask == Otc::SpriteYellowMask) - outfitColorId = m_outfit.head; - else if(mask == Otc::SpriteRedMask) - outfitColorId = m_outfit.body; - else if(mask == Otc::SpriteGreenMask) - outfitColorId = m_outfit.legs; - else if(mask == Otc::SpriteBlueMask) - outfitColorId = m_outfit.feet; + // body + g_graphics.bindColor(Otc::OutfitColors[m_outfit.body]); + internalDraw(x, y, 1, m_direction, ydiv, 0, m_animation, Otc::SpriteRedMask); - g_graphics.bindColor(Otc::OutfitColors[outfitColorId]); - internalDraw(x, y, 1, m_direction, ydiv, 0, m_animation, (Otc::SpriteMask)mask); - } + // legs + g_graphics.bindColor(Otc::OutfitColors[m_outfit.legs]); + internalDraw(x, y, 1, m_direction, ydiv, 0, m_animation, Otc::SpriteGreenMask); - g_graphics.bindBlendFunc(Fw::BlendNormal); + // feet + g_graphics.bindColor(Otc::OutfitColors[m_outfit.feet]); + internalDraw(x, y, 1, m_direction, ydiv, 0, m_animation, Otc::SpriteBlueMask); + + // restore default blend func + g_graphics.bindBlendFunc(Fw::BlendDefault); g_graphics.bindColor(Fw::white); } }