Easy Debug Text for MOGRE        

This is a port of Easy debug text.

About

The following code is a class, for use with the OgreDebugPanel {LEX()}overlay{LEX} 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...

// 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

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();
        }
    }
}

See also



Alias: Easy debug text MOGRE