From d6ade5a8e0bacbe4cc32f045a477163b80f97722 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Tue, 7 Feb 2012 05:59:20 -0200 Subject: [PATCH] fix draw of uicreature --- modules/game_shaders/item.frag | 4 +++- src/otclient/core/item.cpp | 6 +++--- src/otclient/core/thing.h | 1 + src/otclient/ui/uicreature.cpp | 5 ++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/game_shaders/item.frag b/modules/game_shaders/item.frag index abc75765..f7a3bfa6 100644 --- a/modules/game_shaders/item.frag +++ b/modules/game_shaders/item.frag @@ -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; } diff --git a/src/otclient/core/item.cpp b/src/otclient/core/item.cpp index 33b818fe..31f1b624 100644 --- a/src/otclient/core/item.cpp +++ b/src/otclient/core/item.cpp @@ -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); diff --git a/src/otclient/core/thing.h b/src/otclient/core/thing.h index ffc0a540..1b270009 100644 --- a/src/otclient/core/thing.h +++ b/src/otclient/core/thing.h @@ -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]; } diff --git a/src/otclient/ui/uicreature.cpp b/src/otclient/ui/uicreature.cpp index db7a5fd6..205f289f 100644 --- a/src/otclient/ui/uicreature.cpp +++ b/src/otclient/ui/uicreature.cpp @@ -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();