mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-27 16:44:00 +00:00
ensure that texcoords are always updated when changing things that affect them
This commit is contained in:
parent
f1796475f1
commit
4c941419b4
6 changed files with 44 additions and 30 deletions
|
@ -3419,8 +3419,8 @@ void Game::toggleHelpScreen(bool on, const std::string &label)
|
||||||
helpBG = new Quad;
|
helpBG = new Quad;
|
||||||
//helpBG->color = 0;
|
//helpBG->color = 0;
|
||||||
helpBG->setTexture("brick");
|
helpBG->setTexture("brick");
|
||||||
|
helpBG->setRepeatScale(Vector(2, 2));
|
||||||
helpBG->repeatTextureToFill(true);
|
helpBG->repeatTextureToFill(true);
|
||||||
helpBG->repeatToFillScale = Vector(2, 2);
|
|
||||||
//helpBG->alphaMod = 0.75;
|
//helpBG->alphaMod = 0.75;
|
||||||
helpBG->autoWidth = AUTO_VIRTUALWIDTH;
|
helpBG->autoWidth = AUTO_VIRTUALWIDTH;
|
||||||
helpBG->autoHeight = AUTO_VIRTUALHEIGHT;
|
helpBG->autoHeight = AUTO_VIRTUALHEIGHT;
|
||||||
|
|
|
@ -109,7 +109,7 @@ static void tileToQuad(Quad *q, const TileData& t)
|
||||||
q->rotation.z = t.rotation;
|
q->rotation.z = t.rotation;
|
||||||
if(t.flags & TILEFLAG_REPEAT && t.rep)
|
if(t.flags & TILEFLAG_REPEAT && t.rep)
|
||||||
{
|
{
|
||||||
q->repeatToFillScale = Vector(t.rep->texscaleX, t.rep->texscaleY);
|
q->setRepeatScale(Vector(t.rep->texscaleX, t.rep->texscaleY));
|
||||||
q->repeatTextureToFill(true);
|
q->repeatTextureToFill(true);
|
||||||
}
|
}
|
||||||
q->texcoords = t.getTexcoords();
|
q->texcoords = t.getTexcoords();
|
||||||
|
@ -193,8 +193,8 @@ public:
|
||||||
|
|
||||||
void onUpdate(float dt)
|
void onUpdate(float dt)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < _quads.size(); ++i)
|
//for(size_t i = 0; i < _quads.size(); ++i)
|
||||||
_quads[i]->refreshRepeatTextureToFill();
|
// _quads[i]->refreshRepeatTextureToFill();
|
||||||
}
|
}
|
||||||
|
|
||||||
void finish()
|
void finish()
|
||||||
|
|
|
@ -1889,13 +1889,19 @@ luaFunc(quad_setRepeatScale)
|
||||||
{
|
{
|
||||||
Quad *b = getQuad(L);
|
Quad *b = getQuad(L);
|
||||||
if (b)
|
if (b)
|
||||||
{
|
b->setRepeatScale(Vector(lua_tonumber(L, 2), lua_tonumber(L, 3)));
|
||||||
b->repeatToFillScale = Vector(lua_tonumber(L, 2), lua_tonumber(L, 3));
|
|
||||||
b->refreshRepeatTextureToFill();
|
|
||||||
}
|
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
luaFunc(quad_getRepeatScale)
|
||||||
|
{
|
||||||
|
Vector s;
|
||||||
|
Quad *b = getQuad(L);
|
||||||
|
if (b)
|
||||||
|
s = b->getRepeatScale();
|
||||||
|
luaReturnVec2(s.x, s.y);
|
||||||
|
}
|
||||||
|
|
||||||
luaFunc(quad_isRepeatTexture)
|
luaFunc(quad_isRepeatTexture)
|
||||||
{
|
{
|
||||||
Quad *b = getQuad(L);
|
Quad *b = getQuad(L);
|
||||||
|
@ -1906,7 +1912,7 @@ luaFunc(quad_setTexOffset)
|
||||||
{
|
{
|
||||||
Quad *b = getQuad(L);
|
Quad *b = getQuad(L);
|
||||||
if (b)
|
if (b)
|
||||||
b->texOff = Vector(lua_tonumber(L, 2), lua_tonumber(L, 3));
|
b->setRepeatOffset(Vector(lua_tonumber(L, 2), lua_tonumber(L, 3)));
|
||||||
luaReturnNil();
|
luaReturnNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1915,7 +1921,7 @@ luaFunc(quad_getTexOffset)
|
||||||
Quad *b = getQuad(L);
|
Quad *b = getQuad(L);
|
||||||
Vector v;
|
Vector v;
|
||||||
if (b)
|
if (b)
|
||||||
v = b->texOff;
|
v = b->getRepeatOffset();
|
||||||
luaReturnVec2(v.x, v.y);
|
luaReturnVec2(v.x, v.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,9 @@ void WaterSurfaceRender::onUpdate(float dt)
|
||||||
qSurface->setWidthHeight(width, height);
|
qSurface->setWidthHeight(width, height);
|
||||||
|
|
||||||
float bit = core->cameraPos.x/300.0f;
|
float bit = core->cameraPos.x/300.0f;
|
||||||
|
Vector texoff = qLine->getRepeatOffset();
|
||||||
qLine->texOff.x = bit;
|
texoff.x = bit;
|
||||||
|
qLine->setRepeatOffset(texoff);
|
||||||
qLine->refreshRepeatTextureToFill();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (dsq->useFrameBuffer && dsq->frameBuffer.isInited())
|
if (dsq->useFrameBuffer && dsq->frameBuffer.isInited())
|
||||||
|
|
|
@ -212,10 +212,22 @@ void Quad::renderGrid(const RenderState& rs) const
|
||||||
void Quad::repeatTextureToFill(bool on)
|
void Quad::repeatTextureToFill(bool on)
|
||||||
{
|
{
|
||||||
repeatTexture = on;
|
repeatTexture = on;
|
||||||
refreshRepeatTextureToFill();
|
updateTexCoords();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Quad::setRepeatScale(const Vector& repscale)
|
||||||
|
{
|
||||||
|
repeatToFillScale = repscale;
|
||||||
|
updateTexCoords();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Quad::setRepeatOffset(const Vector& repoffs)
|
||||||
|
{
|
||||||
|
texOff = repoffs;
|
||||||
|
updateTexCoords();
|
||||||
|
}
|
||||||
|
|
||||||
void Quad::onRender(const RenderState& rs) const
|
void Quad::onRender(const RenderState& rs) const
|
||||||
{
|
{
|
||||||
if (!renderQuad) return;
|
if (!renderQuad) return;
|
||||||
|
@ -247,7 +259,7 @@ void Quad::onRender(const RenderState& rs) const
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Quad::refreshRepeatTextureToFill()
|
void Quad::updateTexCoords()
|
||||||
{
|
{
|
||||||
if (repeatTexture && texture)
|
if (repeatTexture && texture)
|
||||||
{
|
{
|
||||||
|
@ -255,7 +267,6 @@ void Quad::refreshRepeatTextureToFill()
|
||||||
texcoords.v1 = texOff.y;
|
texcoords.v1 = texOff.y;
|
||||||
texcoords.u2 = (width*scale.x*repeatToFillScale.x)/texture->width + texOff.x;
|
texcoords.u2 = (width*scale.x*repeatToFillScale.x)/texture->width + texOff.x;
|
||||||
texcoords.v2 = (height*scale.y*repeatToFillScale.y)/texture->height + texOff.y;
|
texcoords.v2 = (height*scale.y*repeatToFillScale.y)/texture->height + texOff.y;
|
||||||
//texcoords.fixflip();
|
|
||||||
|
|
||||||
if(!grid)
|
if(!grid)
|
||||||
{
|
{
|
||||||
|
@ -265,16 +276,12 @@ void Quad::refreshRepeatTextureToFill()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fabsf(texcoords.u2) > 1 || fabsf(texcoords.v2) > 1)
|
texcoords.setStandard();
|
||||||
{
|
// don't delete when a wavy effect is going on, for example
|
||||||
texcoords.u2 = 1;
|
if(grid && grid->gridType == GRID_UNDEFINED)
|
||||||
texcoords.v2 = 1;
|
|
||||||
|
|
||||||
if(grid && grid->gridType == GRID_UNDEFINED && texcoords.isStandard())
|
|
||||||
deleteGrid();
|
deleteGrid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Quad::reloadDevice()
|
void Quad::reloadDevice()
|
||||||
{
|
{
|
||||||
|
|
11
BBGE/Quad.h
11
BBGE/Quad.h
|
@ -71,8 +71,11 @@ public:
|
||||||
DynamicRenderGrid *setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo);
|
DynamicRenderGrid *setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo);
|
||||||
void setDrawGridAlpha(size_t x, size_t y, float alpha);
|
void setDrawGridAlpha(size_t x, size_t y, float alpha);
|
||||||
void repeatTextureToFill(bool on);
|
void repeatTextureToFill(bool on);
|
||||||
void refreshRepeatTextureToFill();
|
|
||||||
bool isRepeatingTextureToFill() const { return repeatTexture; }
|
bool isRepeatingTextureToFill() const { return repeatTexture; }
|
||||||
|
void setRepeatScale(const Vector& repscale);
|
||||||
|
inline const Vector& getRepeatScale() const { return repeatToFillScale; }
|
||||||
|
void setRepeatOffset(const Vector& repoffs);
|
||||||
|
inline const Vector& getRepeatOffset() const { return texOff; }
|
||||||
void setStripPoints(bool vert, const Vector *points, size_t n);
|
void setStripPoints(bool vert, const Vector *points, size_t n);
|
||||||
DynamicRenderGrid *getGrid() { return grid; }
|
DynamicRenderGrid *getGrid() { return grid; }
|
||||||
const DynamicRenderGrid *getGrid() const { return grid; }
|
const DynamicRenderGrid *getGrid() const { return grid; }
|
||||||
|
@ -87,14 +90,14 @@ public:
|
||||||
char autoWidth, autoHeight;
|
char autoWidth, autoHeight;
|
||||||
bool renderQuad, renderCenter, renderBorder;
|
bool renderQuad, renderCenter, renderBorder;
|
||||||
|
|
||||||
Vector texOff;
|
|
||||||
|
|
||||||
float borderAlpha;
|
float borderAlpha;
|
||||||
Vector renderBorderColor;
|
Vector renderBorderColor;
|
||||||
Vector repeatToFillScale;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void updateTexCoords();
|
||||||
|
|
||||||
|
Vector repeatToFillScale;
|
||||||
|
Vector texOff;
|
||||||
DynamicRenderGrid *grid;
|
DynamicRenderGrid *grid;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue