Drawing text using CEGUI::Font

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

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

Drawing text using CEGUI::Font

Postby Rakkar » Mon Aug 21, 2006 14:59

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

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

Postby lindquist » Mon Aug 21, 2006 15:33

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

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

Postby Rackle » Mon Aug 21, 2006 16:00

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.

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

Postby Rakkar » Tue Aug 22, 2006 04:50

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?

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

Postby Rackle » Tue Aug 22, 2006 13:01

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.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 25 guests