From 69cfcb156d4224753d439ac3cd7708366e27e365 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 25 Apr 2017 21:47:27 +0300 Subject: Report also altas creation OpenGL errors if enabled. --- src/render/mobileopenglgraphics.cpp | 4 ++++ src/render/normalopenglgraphics.cpp | 4 ++++ src/render/opengl/mglemu.cpp | 4 ++++ src/resources/atlas/atlasmanager.cpp | 23 +++++++++++++++++++++++ 4 files changed, 35 insertions(+) (limited to 'src') diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 2194405a5..b2baa7d66 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -24,6 +24,10 @@ #include "render/mobileopenglgraphics.h" +#ifdef OPENGLERRORS +#include "graphicsmanager.h" +#endif // OPENGLERRORS + #include "render/opengl/mgl.h" #ifdef __native_client__ #include "render/opengl/naclglfunctions.h" diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index c6b3f33ec..73013773f 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -24,6 +24,10 @@ #include "render/normalopenglgraphics.h" +#ifdef OPENGLERRORS +#include "graphicsmanager.h" +#endif // OPENGLERRORS + #ifdef DEBUG_OPENGL #include "render/opengl/mgl.h" #endif // DEBUG_OPENGL diff --git a/src/render/opengl/mglemu.cpp b/src/render/opengl/mglemu.cpp index eb5949f0b..864b130ef 100644 --- a/src/render/opengl/mglemu.cpp +++ b/src/render/opengl/mglemu.cpp @@ -22,6 +22,10 @@ #include "render/opengl/mglemu.h" +#ifdef OPENGLERRORS +#include "graphicsmanager.h" +#endif // OPENGLERRORS + #include "resources/openglimagehelper.h" #include "debug.h" diff --git a/src/resources/atlas/atlasmanager.cpp b/src/resources/atlas/atlasmanager.cpp index 4f38439ad..f8251ba7d 100644 --- a/src/resources/atlas/atlasmanager.cpp +++ b/src/resources/atlas/atlasmanager.cpp @@ -313,6 +313,10 @@ void AtlasManager::createSDLAtlas(TextureAtlas *const atlas) } BLOCK_END("AtlasManager::createSDLAtlas create surface") +#ifdef OPENGLERRORS + logger->log("OpenGL debug: creating atlase %dx%d", width, height); +#endif // OPENGLERRORS + Image *image = imageHelper->loadSurface(surface); // free SDL atlas surface MSDL_FreeSurface(surface); @@ -330,6 +334,25 @@ void AtlasManager::createSDLAtlas(TextureAtlas *const atlas) AtlasItem *const item = *it; imageHelper->copySurfaceToImage(image, item->x, item->y, item->image->mSDLSurface); +#ifdef OPENGLERRORS + logger->log("OpenGL debug: put atlas image %s (size %dx%d)," + " into %d,%d to %d,%d", + item->name.c_str(), + item->image->mSDLSurface->w, + item->image->mSDLSurface->h, + item->x, + item->y, + item->x + item->image->mSDLSurface->w - 1, + item->y + item->image->mSDLSurface->h - 1); + if (item->x >= width) + logger->log("OpenGL error: start x position outside of atlas"); + if (item->y >= height) + logger->log("OpenGL error: start y position outside of atlas"); + if (item->x + item->image->mSDLSurface->w - 1 >= width) + logger->log("OpenGL error: end x position outside of atlas"); + if (item->y + item->image->mSDLSurface->h - 1 >= height) + logger->log("OpenGL error: end y position outside of atlas"); +#endif // OPENGLERRORS } atlas->atlasImage = image; BLOCK_END("AtlasManager::createSDLAtlas") -- cgit v1.2.3-60-g2f50