Skip to main content

History: Easy Debug Text for MOGRE

Preview of version: 3

This is a port of Easy debug text.

About

The following code is a class, for use with the OgreDebugPanel overlay that is added into all the demos and sample applications. The reason for creating it was to be able to change the debug text at different points in the code. If you do something like this...

Copy to clipboard
// this must be changed for C# code: mWindow->setDebugText(mWindow->getDebugText() + "new text");

...you end up with a never ending line of text that would keep growing and slowly kill your application.

Maybe the code has teething problems. If you need help or added improvements, please tell us in this thread.

Comments of the porter RichTufty

You will notice that in the actual printText() method I also couldn't find the setDebugText() method on the RenderWindow class, so I have put a line in there to write the debug text to the Visual Studio output window. You may have your own way of displaying debug information in your own project so just change that line.

Also the sceneManager and window objects aren't actually used, so they can be completely removed from this class, but i left them in incase you wanted to expand this class.

Source code

Copy to clipboard
using System; using System.Text; using System.Collections.Generic; using Mogre; namespace your_projects_namespace { public class DebugWriter { SceneManager sceneManager; RenderWindow window; List<string> debugLines; public DebugWriter(SceneManager _sceneManager, RenderWindow _window) { sceneManager = _sceneManager; window = _window; //create empty list of strings debugLines = new List<string>(); } public void addDebugText(string text) { //simply add string to our current list debugLines.Add(text); } public void printText() { string output = ""; //loop through each string in the list and join them together foreach (string line in debugLines) output += line + ", "; //output debug text // I didn't found a member like this... ?? //window.setDebugText(output); System.Diagnostics.Debug.WriteLine(output); debugLines.Clear(); } } }


Alias: Easy debug text MOGRE

History

Information Version
Sat 05 of Jun, 2010 16:33 GMT-0000 jacmoe 5
Sat 22 of May, 2010 17:24 GMT-0000 jacmoe 4
Thu 31 of Dec, 2009 11:39 GMT-0000 jacmoe 3
Sun 27 of Dec, 2009 23:26 GMT-0000 jacmoe 2
Sat 24 of Jan, 2009 17:00 GMT-0000 Beauty added to [[Category:Code Snippet]] 1