debug - oxygine/oxygine-framework GitHub Wiki
DebugActor
DebugActor displays some useful stats. Some of them available only in Debug mode:
To show it:
#include "oxygine-framework.h"
...
DebugActor::show();
- fps - frames per second
- objects - number of created instances of Object. Debug only, to enable it in release define OXYGINE_DEBUG_TRACE_LEAKS
- batches - number of batches per frame (draw calls). Debug only, to enable it in release define OXYGINE_TRACE_VIDEO_STATS
- triangles - number of triangles per frame
- update - RootActor::update time in milliseconds. It includes all children updates
- render - RootActor::render time in milliseconds. It includes all children rendering
- textures - number of total created textures
- listeners - number of event listeners attached to RootActor
Custom text
To display custom text on DebugActor (image above) call it each frame:
DebugActor::addDebugString("Custom text");
Tools
DebugActor has 4 buttons from left to right:
- Textures inspector shows all created and not deleted textures. Debug only, to enable it in release define OXYGINE_DEBUG_TRACE_LEAKS
- T2P - Texel2Pixel. It shows "blurred" sprites displayed without texel to pixel precision on display
- Finger - Animates clicked actors under mouse cursor. Could be useful to find out who blocked mouse events
- Tree Inspector show graph tree of actors with detailed info.
Logging
namespace logs has functions to print text to output.
If using Visual Studio 2013, make sure to open the Output window (View > Output) and set it to show output from Debug after compilation to view the messages.
logs::messageln("it is message");
> it is message
logs::messageln("printf formatting %s-%d", "abc", 123);
> printf formatting abc-123
logs::warning("it is warning");
> warning: it is warning
logs::error("it is error");
> error: it is error
Tracing Object leaks
Helps you to find leaked Objects.
It is Debug only feature, to enable it in release mode define: OXYGINE_DEBUG_TRACE_LEAKS
Guards to trace leaks:
ObjectBase::__startTracingLeaks();
new Actor;//leak
new Sprite;//leak
ObjectBase::__stopTracingLeaks();
If you want to display all created and not deleted Objects call:
ObjectBase::dumpCreatedObjects();
result:
allocated objects:
id = 3, name = '', typeid = 'class oxygine::Actor', refs = 0
id = 4, name = '', typeid = 'class oxygine::Sprite', refs = 0
total: 2 -----------------------------
There are some useful functions:
/**Shows assert when object with this unique ID will be created.*/
ObjectBase::showAssertInCtor(int id);
/**Shows assert when object with this unique ID will be destroyed.*/
ObjectBase::showAssertInDtor(int id);
"id" is numeric identifier which could be retrieved from "allocated objects" list
Each example has leak guards (main.cpp)