From 8e6ab562dd62383d191806e88548e89b4d0a9d65 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 25 May 2014 17:50:46 +0300 Subject: Add support for simple texture size detection. This test check from 1024 to max texture size reported by driver. --- src/resources/atlasmanager.cpp | 7 ++++++- src/resources/openglimagehelper.cpp | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/resources') diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index 49607786e..c60d6465d 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -24,6 +24,8 @@ #include "resources/atlasmanager.h" +#include "configuration.h" + #include "render/surfacegraphics.h" #include "utils/mathutils.h" @@ -53,7 +55,10 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name, AtlasResource *resource = new AtlasResource; loadImages(files, images); - const int maxSize = OpenGLImageHelper::getTextureSize(); + int maxSize = OpenGLImageHelper::getTextureSize(); + const int sz = config.getIntValue("textureSize"); + if (maxSize > sz) + maxSize = sz; // sorting images on atlases. simpleSort(name, atlases, images, maxSize); diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp index 7c4e08501..7421dc852 100644 --- a/src/resources/openglimagehelper.cpp +++ b/src/resources/openglimagehelper.cpp @@ -133,7 +133,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, return nullptr; // Flush current error flag. - glGetError(); + graphicsManager.getLastError(); if (!width) width = tmpImage->w; @@ -273,7 +273,7 @@ Image *OpenGLImageHelper::glLoad(SDL_Surface *tmpImage, if (oldImage) MSDL_FreeSurface(tmpImage); - GLenum error = glGetError(); + GLenum error = graphicsManager.getLastError(); if (error) { std::string errmsg = GraphicsManager::errorToString(error); -- cgit v1.2.3-70-g09d2