| @@ -10,7 +10,7 @@ libcommon_a_SOURCES = \ | |||||
| forge.cpp forge.h video.cpp video.h timer.cpp timer.h bitfield.h \ | forge.cpp forge.h video.cpp video.h timer.cpp timer.h bitfield.h \ | ||||
| profiler.cpp profiler.h input.h input.cpp world.cpp world.h \ | profiler.cpp profiler.h input.h input.cpp world.cpp world.h \ | ||||
| debugfps.cpp debugfps.h debugsprite.cpp debugsprite.h \ | debugfps.cpp debugfps.h debugsprite.cpp debugsprite.h \ | ||||
| debugrecord.cpp debugrecord.h | |||||
| debugrecord.cpp debugrecord.h debugstats.cpp debugstats.h | |||||
| libcommon_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image` | libcommon_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image` | ||||
| test_map_SOURCES = test-map.cpp sdlinput.cpp sdlinput.h | test_map_SOURCES = test-map.cpp sdlinput.cpp sdlinput.h | ||||
| @@ -0,0 +1,59 @@ | |||||
| // | |||||
| // Deus Hax (working title) | |||||
| // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
| // | |||||
| #if defined HAVE_CONFIG_H | |||||
| # include "config.h" | |||||
| #endif | |||||
| #include <cstdio> | |||||
| #include "core.h" | |||||
| #include "debugstats.h" | |||||
| /* | |||||
| * DebugStats implementation class | |||||
| */ | |||||
| class DebugStatsData | |||||
| { | |||||
| friend class DebugStats; | |||||
| private: | |||||
| FILE *fp; | |||||
| }; | |||||
| /* | |||||
| * Public DebugStats class | |||||
| */ | |||||
| DebugStats::DebugStats(char const *path) | |||||
| { | |||||
| data = new DebugStatsData(); | |||||
| data->fp = fopen(path, "w+"); | |||||
| } | |||||
| Entity::Group DebugStats::GetGroup() | |||||
| { | |||||
| return GROUP_AFTER; | |||||
| } | |||||
| void DebugStats::TickGame(float deltams) | |||||
| { | |||||
| Entity::TickGame(deltams); | |||||
| fprintf(data->fp, "%i %f %f %f %f\n", | |||||
| Ticker::GetFrameNum(), | |||||
| Profiler::GetAvg(Profiler::STAT_TICK_GAME), | |||||
| Profiler::GetAvg(Profiler::STAT_TICK_DRAW), | |||||
| Profiler::GetAvg(Profiler::STAT_TICK_BLIT), | |||||
| Profiler::GetAvg(Profiler::STAT_TICK_FRAME)); | |||||
| } | |||||
| DebugStats::~DebugStats() | |||||
| { | |||||
| fclose(data->fp); | |||||
| delete data; | |||||
| } | |||||
| @@ -0,0 +1,33 @@ | |||||
| // | |||||
| // Deus Hax (working title) | |||||
| // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
| // | |||||
| // | |||||
| // The DebugStats class | |||||
| // -------------------- | |||||
| // | |||||
| #if !defined __DH_DEBUGSTATS_H__ | |||||
| #define __DH_DEBUGSTATS_H__ | |||||
| #include "entity.h" | |||||
| class DebugStatsData; | |||||
| class DebugStats : public Entity | |||||
| { | |||||
| public: | |||||
| DebugStats(char const *path); | |||||
| virtual ~DebugStats(); | |||||
| protected: | |||||
| virtual Group GetGroup(); | |||||
| virtual void TickGame(float deltams); | |||||
| private: | |||||
| DebugStatsData *data; | |||||
| }; | |||||
| #endif // __DH_DEBUGSTATS_H__ | |||||
| @@ -17,6 +17,7 @@ | |||||
| #include "debugfps.h" | #include "debugfps.h" | ||||
| #include "debugsprite.h" | #include "debugsprite.h" | ||||
| #include "debugrecord.h" | #include "debugrecord.h" | ||||
| #include "debugstats.h" | |||||
| static float const FPS = 30.0f; | static float const FPS = 30.0f; | ||||
| @@ -52,6 +53,7 @@ int main(int argc, char **argv) | |||||
| new DebugFps(); | new DebugFps(); | ||||
| new DebugSprite(game); | new DebugSprite(game); | ||||
| //new DebugRecord("lolengine.ogg"); | //new DebugRecord("lolengine.ogg"); | ||||
| new DebugStats("stats.txt"); | |||||
| while (!Ticker::Finished()) | while (!Ticker::Finished()) | ||||
| { | { | ||||