Manually keep track of bound textures, so we don't have to poll each frame

Patch submitted by slime73.
This commit is contained in:
Bart van Strien
2012-01-10 15:36:18 +01:00
parent 51d4553b7d
commit 2ac4a9e6d0
10 changed files with 33 additions and 26 deletions
+4 -9
View File
@@ -265,12 +265,7 @@ namespace opengl
if (texture == 0)
return;
GLuint boundTex;
glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&boundTex);
// only bind if this texture is not already bound
if (boundTex != texture)
glBindTexture(GL_TEXTURE_2D, texture);
bindTexture(texture);
}
bool Image::load()
@@ -294,7 +289,7 @@ namespace opengl
bool Image::loadVolatilePOT()
{
glGenTextures(1,(GLuint*)&texture);
glBindTexture(GL_TEXTURE_2D, texture);
bindTexture(texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -340,7 +335,7 @@ namespace opengl
bool Image::loadVolatileNPOT()
{
glGenTextures(1,(GLuint*)&texture);
glBindTexture(GL_TEXTURE_2D, texture);
bindTexture(texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -370,7 +365,7 @@ namespace opengl
// Delete the hardware texture.
if (texture != 0)
{
glDeleteTextures(1, (GLuint*)&texture);
deleteTexture(texture);
texture = 0;
}
}