mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-09 13:24:01 +00:00
set GL textures to always repeat to avoid unnecessary calls to glTexParameteri()
Shouldn't have any visual changes because edge clamp is never actually used
This commit is contained in:
parent
17452f175e
commit
d31d320719
5 changed files with 7 additions and 26 deletions
|
@ -33,7 +33,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
bool RenderObject::renderCollisionShape = false;
|
bool RenderObject::renderCollisionShape = false;
|
||||||
size_t RenderObject::lastTextureApplied = 0;
|
size_t RenderObject::lastTextureApplied = 0;
|
||||||
bool RenderObject::lastTextureRepeat = false;
|
|
||||||
bool RenderObject::renderPaths = false;
|
bool RenderObject::renderPaths = false;
|
||||||
|
|
||||||
void RenderObject::toggleAlpha(float t)
|
void RenderObject::toggleAlpha(float t)
|
||||||
|
@ -482,20 +481,18 @@ nofollow:
|
||||||
{
|
{
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
if (texture->gltexid != lastTextureApplied || repeatTexture != lastTextureRepeat)
|
if (texture->gltexid != lastTextureApplied)
|
||||||
{
|
{
|
||||||
texture->apply(repeatTexture);
|
texture->apply();
|
||||||
lastTextureRepeat = repeatTexture;
|
|
||||||
lastTextureApplied = texture->gltexid;
|
lastTextureApplied = texture->gltexid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (lastTextureApplied != 0 || repeatTexture != lastTextureRepeat)
|
if (lastTextureApplied != 0)
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
lastTextureApplied = 0;
|
lastTextureApplied = 0;
|
||||||
lastTextureRepeat = repeatTexture;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,6 @@ public:
|
||||||
static bool renderCollisionShape;
|
static bool renderCollisionShape;
|
||||||
static bool renderPaths;
|
static bool renderPaths;
|
||||||
static size_t lastTextureApplied;
|
static size_t lastTextureApplied;
|
||||||
static bool lastTextureRepeat;
|
|
||||||
|
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ Texture::Texture()
|
||||||
gltexid = 0;
|
gltexid = 0;
|
||||||
width = height = 0;
|
width = height = 0;
|
||||||
|
|
||||||
_repeating = false;
|
|
||||||
ow = oh = -1;
|
ow = oh = -1;
|
||||||
_mipmap = false;
|
_mipmap = false;
|
||||||
success = false;
|
success = false;
|
||||||
|
@ -98,16 +97,9 @@ void Texture::unload()
|
||||||
}
|
}
|
||||||
|
|
||||||
static const GLenum repeatLUT[] = { GL_CLAMP_TO_EDGE, GL_REPEAT };
|
static const GLenum repeatLUT[] = { GL_CLAMP_TO_EDGE, GL_REPEAT };
|
||||||
void Texture::apply(bool repeat) const
|
void Texture::apply() const
|
||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, gltexid);
|
glBindTexture(GL_TEXTURE_2D, gltexid);
|
||||||
/*if(repeat != _repeating)
|
|
||||||
{
|
|
||||||
_repeating = repeat;
|
|
||||||
GLenum rep = repeatLUT[repeat];
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, rep);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, rep);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GlTexFormat
|
struct GlTexFormat
|
||||||
|
@ -142,7 +134,6 @@ bool Texture::upload(const ImageData& img, bool mipmap)
|
||||||
glBindTexture(GL_TEXTURE_2D, gltexid);
|
glBindTexture(GL_TEXTURE_2D, gltexid);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
_repeating = false;
|
|
||||||
|
|
||||||
const GlTexFormat& f = formatLUT[img.channels - 1];
|
const GlTexFormat& f = formatLUT[img.channels - 1];
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
Texture();
|
Texture();
|
||||||
~Texture();
|
~Texture();
|
||||||
|
|
||||||
void apply(bool repeat = false) const;
|
void apply() const;
|
||||||
void unload();
|
void unload();
|
||||||
|
|
||||||
unsigned gltexid;
|
unsigned gltexid;
|
||||||
|
@ -67,8 +67,6 @@ protected:
|
||||||
|
|
||||||
int ow, oh;
|
int ow, oh;
|
||||||
bool _mipmap;
|
bool _mipmap;
|
||||||
private:
|
|
||||||
mutable bool _repeating; // modified during rendering
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define UNREFTEX(x) {x = NULL;}
|
#define UNREFTEX(x) {x = NULL;}
|
||||||
|
|
|
@ -59,7 +59,6 @@ void TileRender::onRender(const RenderState& rs) const
|
||||||
const Vector M1 = Vector(1,1) - M;
|
const Vector M1 = Vector(1,1) - M;
|
||||||
const Vector T = C * (1 - F);
|
const Vector T = C * (1 - F);
|
||||||
|
|
||||||
unsigned lastTexRepeat = false;
|
|
||||||
unsigned lastTexId = 0;
|
unsigned lastTexId = 0;
|
||||||
|
|
||||||
const bool renderExtras = renderBorders || RenderObject::renderCollisionShape;
|
const bool renderExtras = renderBorders || RenderObject::renderCollisionShape;
|
||||||
|
@ -92,12 +91,10 @@ void TileRender::onRender(const RenderState& rs) const
|
||||||
if(const Texture * const tex = et->tex.content())
|
if(const Texture * const tex = et->tex.content())
|
||||||
{
|
{
|
||||||
unsigned texid = tex->gltexid;
|
unsigned texid = tex->gltexid;
|
||||||
unsigned rep = tile.flags & TILEFLAG_REPEAT;
|
if(texid != lastTexId)
|
||||||
if(texid != lastTexId || rep != lastTexRepeat)
|
|
||||||
{
|
{
|
||||||
lastTexId = texid;
|
lastTexId = texid;
|
||||||
lastTexRepeat = rep;
|
tex->apply();
|
||||||
tex->apply(!!rep);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -210,7 +207,6 @@ void TileRender::onRender(const RenderState& rs) const
|
||||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
|
||||||
|
|
||||||
RenderObject::lastTextureApplied = lastTexId;
|
RenderObject::lastTextureApplied = lastTexId;
|
||||||
RenderObject::lastTextureRepeat = !!lastTexRepeat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileRender::onUpdate(float dt)
|
void TileRender::onUpdate(float dt)
|
||||||
|
|
Loading…
Add table
Reference in a new issue