Page 1 of 1

How to draw "Hello World"?

Posted: Thu Aug 24, 2006 15:32
by Rakkar
All I want to do is draw "Hello World" on the screen purely from code. No layouts or XML files. There shouldn't be a background or scroll bars. I just want "Hello World" by itself. Using the default font, color, etc. Use any coordinates you wish.

Can CEGUI do this? If so, can someone please post the code?

Posted: Thu Aug 24, 2006 16:33
by Rackle
Have a look at Sample_FirstWindow; it creates a frame window.

Line 128 of Sample_FirstWindow.cpp contains:

Code: Select all

FrameWindow* wnd = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "Demo Window");


Remove that line and those until the end of that function. You can then use this (slightly modified) snippet from Sample_Demo7.cpp to create the text:

Code: Select all

    // create a static text with some information in.
    StaticText* stxt = static_cast<StaticText*>(winMgr.createWindow("TaharezLook/StaticText", "Demo7/Window1/Text1"));
    root->addChildWindow(stxt);
    stxt->setMaximumSize(Size(1.0f, 1.0f));
    stxt->setPosition(Point(0.5f, 0.1f));
    stxt->setSize(Size(0.45f, 0.5f));
    stxt->setText("Hello world.");
    stxt->setFrameEnabled(false);
    stxt->setBackgroundEnabled(false);
    stxt->setHorizontalFormatting(StaticText::WordWrapCentred);


I'm assuming you are still using Cegui v0.4. If not then have a look at Widget Galore to convert the StaticText of v0.4 to that of v0.5.

Posted: Sat Aug 26, 2006 16:59
by Percy Camilo
In this post you will find some code:

[url]
http://www.cegui.org.uk/phpBB2/viewtopic.php?t=1408
[/url]