fix draw of uicreature

master
Eduardo Bart 12 years ago
parent 0b220e2e88
commit d6ade5a8e0

@ -3,8 +3,10 @@ uniform vec4 color; // painter color
uniform float time; // time in seconds since shader linkage
uniform sampler2D texture; // map texture
varying vec2 textureCoords; // map texture coords
//uniform int itemId; // item id
void main()
{
gl_FragColor = texture2D(texture, textureCoords) * opacity;
vec4 outColor = texture2D(texture, textureCoords);
gl_FragColor = outColor * opacity;
}

@ -49,7 +49,7 @@ ItemPtr Item::create(int id)
}
PainterShaderProgramPtr itemProgram;
int ITEM_ID_UNIFORM = 10;
//int ITEM_ID_UNIFORM = 10;
void Item::draw(const Point& dest, float scaleFactor, bool animate)
{
@ -168,11 +168,11 @@ void Item::draw(const Point& dest, float scaleFactor, bool animate)
itemProgram->addShaderFromSourceCode(Shader::Vertex, glslMainWithTexCoordsVertexShader + glslPositionOnlyVertexShader);
itemProgram->addShaderFromSourceFile(Shader::Fragment, "/game_shaders/item.frag");
assert(itemProgram->link());
itemProgram->bindUniformLocation(ITEM_ID_UNIFORM, "itemId");
//itemProgram->bindUniformLocation(ITEM_ID_UNIFORM, "itemId");
}
g_painter.setCustomProgram(itemProgram);
itemProgram->bind();
itemProgram->setUniformValue(ITEM_ID_UNIFORM, (int)m_id);
//itemProgram->setUniformValue(ITEM_ID_UNIFORM, (int)m_id);
// now we can draw the item
internalDraw(dest, scaleFactor, xPattern, yPattern, zPattern, animationPhase);

@ -91,6 +91,7 @@ public:
Size getDimension() { return Size(m_type->dimensions[ThingType::Width], m_type->dimensions[ThingType::Height]); }
int getDimensionWidth() { return m_type->dimensions[ThingType::Width]; }
int getDimensionHeight() { return m_type->dimensions[ThingType::Height]; }
int getExactSize() { return m_type->dimensions[ThingType::ExactSize]; }
Point getDisplacement() { return Point(m_type->parameters[ThingType::DisplacementX], m_type->parameters[ThingType::DisplacementY]); }
int getNumPatternsX() { return m_type->dimensions[ThingType::PatternX]; }
int getNumPatternsY() { return m_type->dimensions[ThingType::PatternY]; }

@ -30,7 +30,10 @@ void UICreature::draw()
if(m_creature) {
g_painter.setColor(Fw::white);
m_creature->draw(m_rect.bottomRight() - Point(32, 32) + Point(m_padding.left, m_padding.top), 1, false);
Rect drawRect = getChildrenRect();
float scaleFactor = drawRect.width() / (float)m_creature->getExactSize();
m_creature->draw(drawRect.bottomRight() - Point(32, 32) * scaleFactor , scaleFactor, false);
}
drawChildren();

Loading…
Cancel
Save