Index: KX_KetsjiEngine.cpp =================================================================== --- KX_KetsjiEngine.cpp (revision 49694) +++ KX_KetsjiEngine.cpp (working copy) @@ -722,7 +722,7 @@ frames--; } - bool bUseAsyncLogicBricks= false;//true; + bool bUseAsyncLogicBricks = false;//true; if (bUseAsyncLogicBricks) { @@ -1443,9 +1443,18 @@ void KX_KetsjiEngine::RenderDebugProperties() { STR_String debugtxt; - int xcoord = 10; // mmmm, these constants were taken from blender source - int ycoord = 14; // to 'mimic' behavior + int title_xmargin = -3; + int title_y_top_margin = 4; + int title_y_bottom_margin = 2; + int const_xindent =0; + int const_ysize = 14; + + int xcoord = 12; // mmmm, these constants were taken from blender source + int ycoord = 17; // to 'mimic' behavior + + int profile_indent = 64; + float tottime = m_logger->GetAverage(); if (tottime < 1e-6f) { tottime = 1e-6f; @@ -1455,43 +1464,92 @@ RAS_Rect viewport; m_canvas->SetViewPort(0, 0, int(m_canvas->GetWidth()), int(m_canvas->GetHeight())); + if (m_show_framerate || m_show_profile) + { + /* Title for profiling("Profile") */ + debugtxt.Format("Profile"); + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin + ycoord, + m_canvas->GetWidth() /* RdV, TODO ?? */, + m_canvas->GetHeight() /* RdV, TODO ?? */); + + // Increase the indent by default increase + ycoord += const_ysize; + // Add the title indent afterwards + ycoord += title_y_bottom_margin; + } + /* Framerate display */ - if (m_show_framerate) { - debugtxt.Format("swap : %.3f (%.3f frames per second)", tottime, 1.0/tottime); + if (m_show_framerate) + { + debugtxt.Format("Framerate :"); m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), - xcoord, + xcoord + const_xindent, ycoord, m_canvas->GetWidth() /* RdV, TODO ?? */, m_canvas->GetHeight() /* RdV, TODO ?? */); - ycoord += 14; + + debugtxt.Format("%.3fms (%.3f fps)", tottime * 1000.f, 1.0/tottime); + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord + const_xindent + profile_indent, + ycoord, + m_canvas->GetWidth() /* RdV, TODO ?? */, + m_canvas->GetHeight() /* RdV, TODO ?? */); + // Increase the indent by default increase + ycoord += const_ysize; } - /* Profile and framerate display */ + /* Profile display */ if (m_show_profile) - { + { for (int j = tc_first; j < tc_numCategories; j++) { debugtxt.Format(m_profileLabels[j]); m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), - xcoord,ycoord, + xcoord + const_xindent, + ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); + double time = m_logger->GetAverage((KX_TimeCategory)j); + debugtxt.Format("%.3fms (%2.2f %%)", time*1000.f, time/tottime * 100.f); m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), - xcoord + 60, ycoord, + xcoord + const_xindent + profile_indent, ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); - ycoord += 14; + ycoord += const_ysize; } } + // Add the ymargin for titles below the other section of debug info + ycoord += title_y_top_margin; + + /* Property display*/ if (m_show_debug_properties && m_propertiesPresent) { + + /* Title for debugging("Debug properties") */ + debugtxt.Format("Debug properties"); + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord + const_xindent + title_xmargin, // Adds the constant x indent (0 for now) to the title x margin + ycoord, + m_canvas->GetWidth() /* RdV, TODO ?? */, + m_canvas->GetHeight() /* RdV, TODO ?? */); + + // Increase the indent by default increase + ycoord += const_ysize; + // Add the title indent afterwards + ycoord += title_y_bottom_margin; + KX_SceneList::iterator sceneit; for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++) { @@ -1526,11 +1584,11 @@ } m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), - xcoord, + xcoord + const_xindent, ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); - ycoord += 14; + ycoord += const_ysize; } else { @@ -1538,14 +1596,14 @@ if (propval) { STR_String text = propval->GetText(); - debugtxt = objname + "." + propname + " = " + text; + debugtxt = objname + ": '" + propname + "' = " + text; m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, debugtxt.Ptr(), - xcoord, + xcoord + const_xindent, ycoord, m_canvas->GetWidth(), m_canvas->GetHeight()); - ycoord += 14; + ycoord += const_ysize; } } }