mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-02 22:14:37 +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
|
@ -212,10 +212,22 @@ void Quad::renderGrid(const RenderState& rs) const
|
|||
void Quad::repeatTextureToFill(bool 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
|
||||
{
|
||||
if (!renderQuad) return;
|
||||
|
@ -247,7 +259,7 @@ void Quad::onRender(const RenderState& rs) const
|
|||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Quad::refreshRepeatTextureToFill()
|
||||
void Quad::updateTexCoords()
|
||||
{
|
||||
if (repeatTexture && texture)
|
||||
{
|
||||
|
@ -255,7 +267,6 @@ void Quad::refreshRepeatTextureToFill()
|
|||
texcoords.v1 = texOff.y;
|
||||
texcoords.u2 = (width*scale.x*repeatToFillScale.x)/texture->width + texOff.x;
|
||||
texcoords.v2 = (height*scale.y*repeatToFillScale.y)/texture->height + texOff.y;
|
||||
//texcoords.fixflip();
|
||||
|
||||
if(!grid)
|
||||
{
|
||||
|
@ -265,14 +276,10 @@ void Quad::refreshRepeatTextureToFill()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (fabsf(texcoords.u2) > 1 || fabsf(texcoords.v2) > 1)
|
||||
{
|
||||
texcoords.u2 = 1;
|
||||
texcoords.v2 = 1;
|
||||
|
||||
if(grid && grid->gridType == GRID_UNDEFINED && texcoords.isStandard())
|
||||
deleteGrid();
|
||||
}
|
||||
texcoords.setStandard();
|
||||
// don't delete when a wavy effect is going on, for example
|
||||
if(grid && grid->gridType == GRID_UNDEFINED)
|
||||
deleteGrid();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
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);
|
||||
void setDrawGridAlpha(size_t x, size_t y, float alpha);
|
||||
void repeatTextureToFill(bool on);
|
||||
void refreshRepeatTextureToFill();
|
||||
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);
|
||||
DynamicRenderGrid *getGrid() { return grid; }
|
||||
const DynamicRenderGrid *getGrid() const { return grid; }
|
||||
|
@ -87,14 +90,14 @@ public:
|
|||
char autoWidth, autoHeight;
|
||||
bool renderQuad, renderCenter, renderBorder;
|
||||
|
||||
Vector texOff;
|
||||
|
||||
float borderAlpha;
|
||||
Vector renderBorderColor;
|
||||
Vector repeatToFillScale;
|
||||
|
||||
protected:
|
||||
void updateTexCoords();
|
||||
|
||||
Vector repeatToFillScale;
|
||||
Vector texOff;
|
||||
DynamicRenderGrid *grid;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue