Page 1 of 1

Creating a simple GUI with CEGUI / OGRE

Posted: Tue Jan 25, 2005 21:42
by NSXEagle
Hi!

It's me again and I have a problem. After I could solve this memory manager mess (you know - the OGRE vs. Xerces-C thing), I have now problems to create a simple GUI with CEGUI. AFAIK, it has something to do with font loading. Here is my sample .font file:

FontComic12.font

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Font Name="Comic-12" Type="Dynamic" Filename="comic.ttf" Size="12" AutoScaled="true" NativeHorzRes="800" NativeVertRes="600" />


Here is my CEGUI initialization code:

Code: Select all

CEGUI::SchemeManager::getSingleton().loadScheme("TaharezLook.scheme");
CEGUI::System::getSingleton().setDefaultMouseCursor("TaharezLook","MouseArrow");
CEGUI::Window* sheet = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow","root_wnd");
CEGUI::Font* gfont = CEGUI::FontManager::getSingleton().createFont("FontComic12.font");
CEGUI::FrameWindow* frame = (CEGUI::FrameWindow*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/FrameWindow","Frame1");
frame->setPosition(CEGUI::Point(0.0f, 0.83f));
frame->setSize(CEGUI::Size(0.23f, 0.17f));
frame->setAlwaysOnTop(true);
frame->setFont(gfont);
frame->setText("Test Window 1");
sheet->addChildWindow(frame);
CEGUI::System::getSingleton().setGUISheet(sheet);


My program crashes during the creation of the FrameWindow (to be more specific, in the last line of the following code):

Code: Select all

void TLFrameWindow::layoutComponentWidgets()
{
ImagesetManager& ismgr = ImagesetManager::getSingleton();
// calculate and set size of title bar
Size titleSz;
titleSz.d_height = d_titlebar->getFont()->getLineSpacing() + TitlebarTextPadding;


I looked at the font object used for the creation and it seems that it is corrupt or simply not existing. Did I miss something about a default font?

Re: Creating a simple GUI with CEGUI / OGRE

Posted: Tue Jan 25, 2005 22:54
by spannerman
Hmm, make sure you are looking in the correct locations for your font file. See the createFont method with its additional parameters.

Also, it might just be that you arent setting a default font:

Code: Select all

System::getSingleton().setDefaultFont(gfont);

Re: Creating a simple GUI with CEGUI / OGRE

Posted: Tue Jan 25, 2005 23:00
by NSXEagle
Thank you very much! Everything is working fine now! *bows* :D