The best way to display lots of text.

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
EJohnson
Just popping in
Just popping in
Posts: 11
Joined: Fri Jul 01, 2005 03:45
Location: California
Contact:

The best way to display lots of text.

Postby EJohnson » Thu Aug 11, 2005 22:57

I recently switched some Widgets from Editbox to StaticText since the text was read-only anyways. In doing so, my rendering performance took a big it.

I have lots of text being displayed, like a couple pages worth, and I'm wondering what Window is best for displaying that? Scrollbars are required - editing is not.


(As an aside, I noticed that StaticText::drawSelf() is calling Font::getFormattedLineCount() which looks like it might be a time consuming method. I don't see Editbox calling that method. Is that why one is slower than the other?)

Thanks for any insight!

User avatar
J_A_X
Quite a regular
Quite a regular
Posts: 72
Joined: Wed Jun 29, 2005 13:18
Contact:

Re: The best way to display lots of text.

Postby J_A_X » Fri Aug 12, 2005 15:28

You should look more into the scheme widgets, it has everything you'd need there.

I this case, I think what you need is a MultiLineEditbox with readOnly on and WordWrap on. I'm using it right now for my console, seems to be working pretty decently :P

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: The best way to display lots of text.

Postby CrazyEddie » Sun Aug 14, 2005 09:21

The only real insight I can give is that, in general, text is expensive.

The multi-line editbox has the advantage that it pre-formats the text, whereas the StaticText does not, which means it's calculating the formatting more often, and so I would say that's where the hit is coming from.

LarsW
Just popping in
Just popping in
Posts: 1
Joined: Tue Oct 10, 2006 16:40

Any change

Postby LarsW » Tue Oct 10, 2006 22:13

Hi

Is there any change to the problems with large amounts of text in StaticText? Maybe a new kind of textwidget?

Cause the wrapping applied in the MultiLineEditbox does not look very good, and does not allow the RightAligned, Centered or Justified Wrapping modes.

greets
Lars

Rakkar
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 15, 2006 02:49

Postby Rakkar » Tue May 22, 2007 04:40

You aren't kidding about being expensive. My FPS dropped from 48 to < 20 with only 6 lines of text on the screen.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Tue May 22, 2007 10:44

I downloaded a bible in .txt format and used it with the following program. In debug mode it takes a while to read the file and with only a multiline editbox displaying the contents of that file I get 200ish FPS in debug mode. But when I switch to release mode I get 1700ish FPS.

Dragging the scrollbar up and down (in release mode) manages to reduce FPS all the way to 35 FPS if I maniacally scroll through that 3.88 meg file. However scrolling through page down only lowers FPS down to 1300ish FPS.

I realise that this is a special case, where there's only one widget active. But still, the impact of debug mode is evident. I'm assuming that everyone tested their programs in release mode and not in debug mode, right? What kind of interface (how many of which widgets) are you using, how much text are you displaying in total?

Here's my test program. All that's missing is a main.cpp from one of my Wiki articles.

EDIT: New code to add a static text widget.

Code: Select all

#ifndef _LotsOfText_h_
#define _LotsOfText_h_

#include "CEGuiSample.h"
#include "CEGUI.h"
#include "CEGUIDefaultResourceProvider.h"
#include <fstream>

class DemoSample : public CEGuiSample
{
public:
    bool initialiseSample()
   {
      using namespace CEGUI;

      // The executable is stored within <cegui>/bin
      // The following will change the location of the datafiles from their default of
      // ../datafiles (which works well for samples) to <cegui>/samples/datafiles
      DefaultResourceProvider* rp = reinterpret_cast<DefaultResourceProvider*>(System::getSingleton().getResourceProvider());
      rp->setResourceGroupDirectory("fonts",         "../samples/datafiles/fonts/");
      rp->setResourceGroupDirectory("imagesets",      "../samples/datafiles/imagesets/");
      rp->setResourceGroupDirectory("layouts",      "c:/programming/_Projects/CeguiTestBed/");
      rp->setResourceGroupDirectory("looknfeels",      "../samples/datafiles/looknfeel/");
      rp->setResourceGroupDirectory("lua_scripts",   "../samples/datafiles/lua_scripts/");
      rp->setResourceGroupDirectory("schemes",      "../samples/datafiles/schemes/");
      Font::setDefaultResourceGroup("fonts");
      Imageset::setDefaultResourceGroup("imagesets");
      WindowManager::setDefaultResourceGroup("layouts");
      WidgetLookManager::setDefaultResourceGroup("looknfeels");
      ScriptModule::setDefaultResourceGroup("lua_scripts");
      Scheme::setDefaultResourceGroup("schemes");

      try
      {
         // Retrieve the window manager
         WindowManager& winMgr = WindowManager::getSingleton();

         // Load the TaharezLook scheme and set up the default mouse cursor and font
         SchemeManager::getSingleton().loadScheme("TaharezLook.scheme");
         System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
         FontManager::getSingleton().createFont("Commonwealth-10.font");

         // Set the GUI Sheet
         Window* sheet = winMgr.createWindow("DefaultWindow", "root_wnd");
         System::getSingleton().setGUISheet(sheet);

         // Create the layout
         CEGUI::Window* mle = winMgr.createWindow("TaharezLook/MultiLineEditbox");
         sheet->addChildWindow(mle);
         mle->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.0f), CEGUI::UDim(0.05f, 0.0f)));
         mle->setSize(CEGUI::UVector2(CEGUI::UDim(1.0f, 0.0f), CEGUI::UDim(0.50f, 0.0f)));

         CEGUI::DefaultWindow* staticText = static_cast<CEGUI::DefaultWindow*>(winMgr.createWindow("TaharezLook/StaticText"));
         sheet->addChildWindow(staticText);
         staticText->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0f, 0.0f), CEGUI::UDim(0.55f, 0.0f)));
         staticText->setSize(CEGUI::UVector2(CEGUI::UDim(10.0f, 0.0f), CEGUI::UDim(0.45f, 0.0f)));
         staticText->setProperty("VertScrollbar", "True");
         staticText->setProperty("HorzScrollbar", "True");

         // Read the file
         // http://www.daimi.au.dk/~jmahle/bible.txt
         CEGUI::String fullText;
         std::stringstream ss;
         std::ifstream myFile( "C:\\Programming\\_Projects\\CeguiTestBed\\Bible.txt" );
         ss << myFile.rdbuf();
         fullText = ss.str();
         fullText = "The text contains "
                + CEGUI::PropertyHelper::intToString(fullText.size())
                + " characters\n"
                + fullText;
         mle->setText(fullText);
         staticText->setText(fullText);
      }
      catch(Exception &e)
      {
         #if defined( __WIN32__ ) || defined( _WIN32 )
            MessageBox(NULL, e.getMessage().c_str(), "Error initializing the demo", MB_OK | MB_ICONERROR | MB_TASKMODAL);
         #else
            std::cerr << "Error initializing the demo:" << e.getMessage().c_str() << "\n";
         #endif
      }

      return true;
   }

    void cleanupSample(void)
   {
   }
};

#endif // _LotsOfText_h_
Last edited by Rackle on Wed May 23, 2007 11:42, edited 1 time in total.

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Postby lindquist » Tue May 22, 2007 11:20

I've seen huge speed differences in CEGUI before with Debug vs. Release, and it has usually been a flaw. If someone could profile this a bit it might get looked at... Big difference in being told: "this stuff is really slow" vs. "this specific method being called for each glyph is really slow"...
I'm sure this can be fixed if someone is willing to put a little time into identifying the parts that are inefficient. Not saying I'll do it, I might, but finding the trouble code is huge progress towards a fix.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed May 23, 2007 11:46

I've modified my layout such that the upper half contains a multiline editobox and the bottom half contains a static text. Performance (in release mode) hits bottom. While doing nothing I nearly get 700 fps but when I start interacting I can get 1 fps. Bleh. If the bottom widget is a second MLE things are better, but still, this needs to be optimized.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 6 guests