pass item id to item shader
This commit is contained in:
parent
ff8cc88ec8
commit
0b220e2e88
|
@ -14,7 +14,7 @@ end
|
|||
function Effects.fadeOut(widget, time, elapsed)
|
||||
if not elapsed then elapsed = 0 end
|
||||
if not time then time = 250 end
|
||||
widget:setOpacity((time - elapsed)/time)
|
||||
widget:setOpacity(math.max((time - elapsed)/time, 0))
|
||||
if elapsed < time then
|
||||
scheduleEvent(function()
|
||||
Effects.fadeOut(widget, time, elapsed + 30)
|
||||
|
|
|
@ -49,6 +49,7 @@ ItemPtr Item::create(int id)
|
|||
}
|
||||
|
||||
PainterShaderProgramPtr itemProgram;
|
||||
int ITEM_ID_UNIFORM = 10;
|
||||
|
||||
void Item::draw(const Point& dest, float scaleFactor, bool animate)
|
||||
{
|
||||
|
@ -167,8 +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");
|
||||
}
|
||||
g_painter.setCustomProgram(itemProgram);
|
||||
itemProgram->bind();
|
||||
itemProgram->setUniformValue(ITEM_ID_UNIFORM, (int)m_id);
|
||||
|
||||
// now we can draw the item
|
||||
internalDraw(dest, scaleFactor, xPattern, yPattern, zPattern, animationPhase);
|
||||
|
|
Loading…
Reference in New Issue