diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-05-08 02:50:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-05-08 02:50:15 +0300 |
commit | 373c794746bfe38d7abea0cedc446cb2aaa75c2e (patch) | |
tree | 03308276e8aabe045ed80f05f7382fe3f8553b5f | |
parent | cf09603b18f0158653723251445960d3bd534ea8 (diff) | |
download | manaplus-373c794746bfe38d7abea0cedc446cb2aaa75c2e.tar.gz manaplus-373c794746bfe38d7abea0cedc446cb2aaa75c2e.tar.bz2 manaplus-373c794746bfe38d7abea0cedc446cb2aaa75c2e.tar.xz manaplus-373c794746bfe38d7abea0cedc446cb2aaa75c2e.zip |
Add opengl texture counter for debugging.
-rw-r--r-- | src/client.cpp | 2 | ||||
-rw-r--r-- | src/client.h | 1 | ||||
-rw-r--r-- | src/gui/debugwindow.cpp | 16 | ||||
-rw-r--r-- | src/gui/debugwindow.h | 1 | ||||
-rw-r--r-- | src/main.h | 1 | ||||
-rw-r--r-- | src/resources/image.cpp | 8 |
6 files changed, 27 insertions, 2 deletions
diff --git a/src/client.cpp b/src/client.cpp index 1ac4be9f4..8bfebf58d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -156,6 +156,8 @@ bool isSafeMode = false; int serverVersion; int start_time; +int textures_count = 0; + /** * Advances game logic counter. * Called every 10 milliseconds by SDL_AddTimer() diff --git a/src/client.h b/src/client.h index eb859f0a8..f03a213db 100644 --- a/src/client.h +++ b/src/client.h @@ -63,6 +63,7 @@ extern volatile int cur_time; extern bool isSafeMode; extern int serverVersion; extern int start_time; +extern int textures_count; class ErrorListener : public gcn::ActionListener { diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index cbfce25dc..ddd2bc7db 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -124,7 +124,8 @@ void DebugWindow::widgetResized(const gcn::Event &event) mTabs->setDimension(gcn::Rectangle(0, 0, getWidth(), getHeight())); } -MapDebugTab::MapDebugTab() +MapDebugTab::MapDebugTab() : + mTexturesLabel(0) { LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); @@ -169,7 +170,12 @@ MapDebugTab::MapDebugTab() place(0, 5, mTileMouseLabel, 2); place(0, 6, mParticleCountLabel, 2); place(0, 7, mMapActorCountLabel, 2); - +#ifdef USE_OPENGL +#ifdef DEBUG_OPENGL_LEAKS + mTexturesLabel = new Label(strprintf("%s %s", _("Textures count:"), "?")); + place(0, 8, mTexturesLabel, 2); +#endif +#endif place.getCell().matchColWidth(0, 0); place = h.getPlacer(0, 1); setDimension(gcn::Rectangle(0, 0, 600, 300)); @@ -215,6 +221,12 @@ void MapDebugTab::logic() mMapActorCountLabel->setCaption( strprintf("%s %d", _("Map actors count:"), map->getActorsCount())); +#ifdef USE_OPENGL +#ifdef DEBUG_OPENGL_LEAKS + mTexturesLabel->setCaption(strprintf("%s %d", + _("Textures count:"), textures_count)); +#endif +#endif } } else diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h index b3432946b..ae4b1b597 100644 --- a/src/gui/debugwindow.h +++ b/src/gui/debugwindow.h @@ -63,6 +63,7 @@ class MapDebugTab : public DebugTab Label *mParticleCountLabel; Label *mMapActorCountLabel; Label *mXYLabel; + Label *mTexturesLabel; int mUpdateTime; Label *mFPSLabel; std::string mFPSText; diff --git a/src/main.h b/src/main.h index 883c7a9d5..9e0886fb4 100644 --- a/src/main.h +++ b/src/main.h @@ -88,6 +88,7 @@ //define DEBUG_FONT 1 //define DEBUG_FONT_COUNTERS 1 //define DEBUG_ALPHA_CACHE 1 +#define DEBUG_OPENGL_LEAKS 1 #define SMALL_VERSION "1.1.5.1" #define CHECK_VERSION "01.01.05.01" diff --git a/src/resources/image.cpp b/src/resources/image.cpp index d5db3b211..be7bb7f47 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -30,6 +30,7 @@ #include "opengl1graphics.h" #endif +#include "client.h" #include "log.h" #include "main.h" @@ -217,6 +218,10 @@ void Image::unload() { glDeleteTextures(1, &mGLImage); mGLImage = 0; +#ifdef DEBUG_OPENGL_LEAKS + if (textures_count > 0) + textures_count --; +#endif } #endif } @@ -675,6 +680,9 @@ Image *Image::_GLload(SDL_Surface *tmpImage) glTexImage2D(mTextureType, 0, 4, tmpImage->w, tmpImage->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->pixels); +#ifdef DEBUG_OPENGL_LEAKS + textures_count ++; +#endif glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |