Easy Debug Text for MOGRE        
Print

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

// 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(external link).

Comments of the porter RichTufty(external link)

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


Contributors to this page: jacmoe133512 points  and Beauty10198 points  .
Page last modified on Saturday 05 of June, 2010 16:33:27 UTC by jacmoe133512 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.