Page 1 of 1

Drawing text using CEGUI::Font

Posted: Mon Aug 21, 2006 14:59
by Rakkar
I thought I posted this yesterday but it seems like the post disappeared.

All I'm trying to do is print text to the screen using CEGUI::Font drawText

The text doesn't show up.

So my question is, what are some possible reasons for why it doesn't show up?

My color is 1.0,1.0,1.0,1.0.
It's a valid string.
I'm printing inside the clip area, which is the whole screen.
I'm printing inside the draw area.
The font I'm using is the default font.
I have a global window.

This question is pretty much equivalent to "What are the minimum steps needed to display "Hello World" using CEGUI::Font?"

*Edit*
Also, should I call drawText before or after I call Ogre::renderOneFrame()

Posted: Mon Aug 21, 2006 15:33
by lindquist
With the current state of the render system you should'nt use Font directly.
You will need to disable queueing of render quads, to make it work properly, which is VERY slow.

Instead use a widget to display your text, or use Ogres font routines.

HTH

Posted: Mon Aug 21, 2006 16:00
by Rackle
Could the missing post be this one? http://www.cegui.org.uk/phpBB2/viewtopi ... =9167#9167


The "Ogre font routine" that could be useful is: http://www.ogre3d.org/wiki/index.php/MovableText

To display text I'm using StaticText (have a look at Widget Galore for sample usage). That's suitable for field labels. Another option is to use a multi line edit box. However I believe you wanted to adjust the height of a window such that it would expand/contract to suit the amount of text being displayed. This I do not know how to accomplish.

There is code to detect whether scrollbars need to be displayed within a multiline editbox. Maybe you can hook into that event and adjust the height of the window accordingly.

Posted: Tue Aug 22, 2006 04:50
by Rakkar
Thanks for the answers.

I tried using static text but it's an abstract class. Should I make a derived class then?

Regarding widgets, I'm not sure what you mean and I don't see any samples for widgets. Are you referring to the class WidgetComponent?

Maybe I should just create a window and call setText on it?

Posted: Tue Aug 22, 2006 13:01
by Rackle
Here's my Widget Galore which presents an overview of every Cegui widget and some sample code. The Wiki contains a few nifty items within Code Snippets.

To quote myself:
The StaticText is now defunct and has been replaced by the DefaultWindow.

The currently displayed text can be specified via setText(). The color of this text can be specified via the "TextColours" property. The value of this property contains 4 color definitions: top left, top right, bottom left, and bottom right. Each color is specified as a two-digit hexadecimal value of the format AARRGGBB (alpha, red, green, blue). The text is aligned vertically via the "VertFormatting" property with a value of TopAligned, BottomAligned, or VertCentred. The text is aligned horizontally via the "HorzFormatting" property with a value of LeftAligned, RightAligned, HorzCentred, HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, or WordWrapJustified.


In case you have not found it, the layout editor is available from http://www.cegui.org.uk/wiki/index.php/ ... _0.5.0-RC2 As of right now the link for the installer is not working. However you can retrieve the source code. Have a look at the Compiling 0.5 from source thread.