From beb2216265b4948efbfae09775fd5b2dbac5b899 Mon Sep 17 00:00:00 2001 From: Valentin Ochs Date: Sat, 14 Jan 2017 20:10:42 +0100 Subject: [PATCH] Change some stuff for butt-endian architectures --- Aquaria/UserSettings.cpp | 8 ++++++-- BBGE/Shader.cpp | 6 +++--- BBGE/Shader.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Aquaria/UserSettings.cpp b/Aquaria/UserSettings.cpp index ec994a1..c708c82 100644 --- a/Aquaria/UserSettings.cpp +++ b/Aquaria/UserSettings.cpp @@ -506,8 +506,12 @@ void UserSettings::load(bool doApply, const std::string &overrideFile) XMLElement *xml_data = doc.FirstChildElement("Data"); if (xml_data) { - xml_data->QueryUnsignedAttribute("savePage", (unsigned int *)&data.savePage); - xml_data->QueryUnsignedAttribute("saveSlot", (unsigned int *)&data.saveSlot); + // use a temporary variable so we don't get into trouble on big-endian architectures + unsigned int tmp; + xml_data->QueryUnsignedAttribute("savePage", &tmp); + data.savePage = tmp; + xml_data->QueryUnsignedAttribute("saveSlot", &tmp); + data.saveSlot = tmp; if(const char *patchlist = xml_data->Attribute("activePatches")) { diff --git a/BBGE/Shader.cpp b/BBGE/Shader.cpp index 0e5546f..874384c 100644 --- a/BBGE/Shader.cpp +++ b/BBGE/Shader.cpp @@ -370,7 +370,7 @@ void Shader::_queryUniforms() { glGetObjectParameterivARB(g_programObj, GL_OBJECT_ACTIVE_UNIFORMS_ARB , (GLint*)&numUniforms); - if (numUniforms <= 0) + if (numUniforms == 0 || numUniforms == -1) { uniforms.clear(); return; @@ -426,7 +426,7 @@ int Shader::_getUniformIndex(const char *name) void Shader::setInt(const char *name, int x, int y /* = 0 */, int z /* = 0 */, int w /* = 0 */) { #if BBGE_BUILD_SHADERS - if(!g_programObj || numUniforms <= 0) + if(!g_programObj || numUniforms == 0 || numUniforms == -1) return; int idx = _getUniformIndex(name); if(unsigned(idx) >= uniforms.size()) @@ -444,7 +444,7 @@ void Shader::setInt(const char *name, int x, int y /* = 0 */, int z /* = 0 */, i void Shader::setFloat(const char *name, float x, float y /* = 0 */, float z /* = 0 */, float w /* = 0 */) { #if BBGE_BUILD_SHADERS - if(!g_programObj || numUniforms <= 0) + if(!g_programObj || numUniforms == 0 || numUniforms == -1) return; int idx = _getUniformIndex(name); if(unsigned(idx) >= uniforms.size()) diff --git a/BBGE/Shader.h b/BBGE/Shader.h index add57dc..8e29b7a 100644 --- a/BBGE/Shader.h +++ b/BBGE/Shader.h @@ -46,7 +46,7 @@ protected: std::string vertFile, fragFile; std::string vertSrc, fragSrc; GLuint g_programObj; - size_t numUniforms; + unsigned int numUniforms; private: static void staticInit();