diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index 88ce39d..5c27b51 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -2028,8 +2028,9 @@ void Game::fillGridFromQuad(Quad *q, ObsType obsType, bool trim) if (trim) { - std::vector obsCopy = obs; - obs.clear(); + std::vector obsCopy; + obsCopy.swap(obs); + // obs now empty int sides = 0; for (int i = 0; i < obsCopy.size(); i++) diff --git a/Aquaria/UserSettings.cpp b/Aquaria/UserSettings.cpp index 977115d..4887e16 100644 --- a/Aquaria/UserSettings.cpp +++ b/Aquaria/UserSettings.cpp @@ -274,12 +274,6 @@ void UserSettings::save() } doc.InsertEndChild(xml_net); - TiXmlElement xml_debug("Debug"); - { - xml_debug.SetAttribute("textureMemoryMultiplier", debug.textureMemoryMultiplier); - } - doc.InsertEndChild(xml_debug); - } #if defined(BBGE_BUILD_UNIX) @@ -566,12 +560,6 @@ void UserSettings::load(bool doApply, const std::string &overrideFile) network.masterServer = serv; } - TiXmlElement *xml_debug = doc.FirstChildElement("Debug"); - if (xml_debug) - { - xml_debug->Attribute("textureMemoryMultiplier", &debug.textureMemoryMultiplier); - } - if (system.locale.empty()) getSystemLocale(); else @@ -618,9 +606,6 @@ void UserSettings::apply() core->settings.prebufferSounds = audio.prebuffer; - if (debug.textureMemoryMultiplier >= 1) - Texture::textureMemoryMultiplier = debug.textureMemoryMultiplier; - #endif } diff --git a/Aquaria/UserSettings.h b/Aquaria/UserSettings.h index 00db719..6be8e60 100644 --- a/Aquaria/UserSettings.h +++ b/Aquaria/UserSettings.h @@ -178,12 +178,6 @@ public: std::string masterServer; } network; - struct Debug - { - Debug() { textureMemoryMultiplier = 1; } - int textureMemoryMultiplier; - } debug; - void loadDefaults(bool doApply=true); void load(bool doApply=true, const std::string &overrideFile=""); void save(); diff --git a/BBGE/Texture.cpp b/BBGE/Texture.cpp index 9c4966b..5c7d030 100644 --- a/BBGE/Texture.cpp +++ b/BBGE/Texture.cpp @@ -56,8 +56,6 @@ bool Texture::useMipMaps = true; TexErr Texture::textureError = TEXERR_OK; -int Texture::textureMemoryMultiplier = 1; - Texture::Texture() : Resource() { #ifdef BBGE_BUILD_OPENGL @@ -821,7 +819,7 @@ static unsigned int clp2(unsigned int x) unsigned char * Texture::getBufferAndSize(int *wparam, int *hparam, unsigned int *sizeparam) { unsigned char *data = NULL; - unsigned int size = 0, allocsize = 0; + unsigned int size = 0; int tw = 0, th = 0; int w = 0, h = 0; @@ -836,13 +834,18 @@ unsigned char * Texture::getBufferAndSize(int *wparam, int *hparam, unsigned int glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h); - // As we know it - but round to nearest power of 2 OpenGL does this internally anyways. + // As we know it - but round to nearest power of 2 - OpenGL does this internally anyways. tw = clp2(width); // known to be > 0. th = clp2(height); if (w != tw || h != th) { - debugLog("Texture::getBufferAndSize() WARNING: width/height disagree"); + std::ostringstream os; + os << "Texture::getBufferAndSize() WARNING: width/height disagree: "; + os << "Driver says (" << w << ", " << h << "); "; + os << "Texture says (" << width << ", " << height << "); "; + os << "Rounded to (" << tw << ", " << th << ")"; + debugLog(os.str()); // choose max. for size calculation w = w > tw ? w : tw; h = h > th ? h : th; @@ -852,9 +855,7 @@ unsigned char * Texture::getBufferAndSize(int *wparam, int *hparam, unsigned int if (!size) goto fail; - allocsize = size * textureMemoryMultiplier; - - data = (unsigned char*)malloc(allocsize + 32); + data = (unsigned char*)malloc(size + 32); if (!data) { std::ostringstream os; @@ -862,12 +863,12 @@ unsigned char * Texture::getBufferAndSize(int *wparam, int *hparam, unsigned int errorLog(os.str()); goto fail; } - memcpy(data + allocsize, "SAFE", 5); + memcpy(data + size, "SAFE", 5); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); glBindTexture(GL_TEXTURE_2D, 0); // Not sure but this might be the case with nouveau drivers on linux... still investigating. -- fg - if(memcmp(data + allocsize, "SAFE", 5)) + if(memcmp(data + size, "SAFE", 5)) { errorLog("Texture::getBufferAndSize(): Broken graphics driver! Wrote past end of buffer!"); free(data); // in case we are here, this will most likely cause a crash. diff --git a/BBGE/Texture.h b/BBGE/Texture.h index 87dfddf..68b43fc 100644 --- a/BBGE/Texture.h +++ b/BBGE/Texture.h @@ -82,7 +82,6 @@ public: void read(int tx, int ty, int w, int h, unsigned char *pixels); unsigned char *getBufferAndSize(int *w, int *h, unsigned int *size); // returned memory must be free()'d - static int textureMemoryMultiplier; // 1. More for buggy drivers. protected: std::string loadName;