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!
The best way to display lots of text.
Moderators: CEGUI MVP, CEGUI Team
Re: The best way to display lots of text.
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
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
- 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.
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.
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.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Any change
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
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
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.
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.
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
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.
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.
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