simplify outfit render

master
Eduardo Bart 13 years ago
parent fbabe6b3ed
commit ba8f8b889e

@ -58,7 +58,7 @@ namespace Fw
}; };
enum BlendFunc { enum BlendFunc {
BlendNormal, BlendDefault,
BlendColorzing BlendColorzing
}; };

@ -51,7 +51,7 @@ void Graphics::init()
m_emptyTexture = TexturePtr(new Texture); m_emptyTexture = TexturePtr(new Texture);
bindColor(Fw::white); bindColor(Fw::white);
bindBlendFunc(Fw::BlendNormal); bindBlendFunc(Fw::BlendDefault);
} }
void Graphics::terminate() void Graphics::terminate()
@ -302,7 +302,7 @@ void Graphics::bindTexture(const TexturePtr& texture)
void Graphics::bindBlendFunc(Fw::BlendFunc blendType) void Graphics::bindBlendFunc(Fw::BlendFunc blendType)
{ {
switch(blendType) { switch(blendType) {
case Fw::BlendNormal: case Fw::BlendDefault:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break; break;
case Fw::BlendColorzing: case Fw::BlendColorzing:

@ -117,25 +117,27 @@ void Creature::draw(int x, int y)
// draw mask if exists // draw mask if exists
if(attributes.blendframes > 1) { if(attributes.blendframes > 1) {
// switch to blend color mode
g_graphics.bindBlendFunc(Fw::BlendColorzing); 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; // body
if(mask == Otc::SpriteYellowMask) g_graphics.bindColor(Otc::OutfitColors[m_outfit.body]);
outfitColorId = m_outfit.head; internalDraw(x, y, 1, m_direction, ydiv, 0, m_animation, Otc::SpriteRedMask);
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;
g_graphics.bindColor(Otc::OutfitColors[outfitColorId]); // legs
internalDraw(x, y, 1, m_direction, ydiv, 0, m_animation, (Otc::SpriteMask)mask); 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); g_graphics.bindColor(Fw::white);
} }
} }

Loading…
Cancel
Save