CEGui - Ogre (Noobie Question)

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
jdhorux
Just popping in
Just popping in
Posts: 2
Joined: Fri Apr 08, 2005 10:03
Contact:

CEGui - Ogre (Noobie Question)

Postby jdhorux » Mon Apr 11, 2005 07:20

Hi there,

I'm a ABSOLUTE NOOBIE with CEGui, and i'm trying to make a SIMPLE DEMO with Ogre.

On Ogre comes a Demo (I think i'm dumie :hammer: ) that's hard for me. :cry:

Could someone send me THE CODE of a STUPID demo with simple GUI with easy understanding??? :oops:

Thanks a lot. :D

JD

User avatar
kungfoomasta
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Wed Apr 06, 2005 08:25

Re: CEGui - Ogre (Noobie Question)

Postby kungfoomasta » Mon Apr 11, 2005 19:12

I got this code from Lindquist on a different post a short while back. This is his actual post, Hope it helps.
--------------------------------------------------------

hi. setting up the library actually takes a bit of code, but i'll give it a go...

personally i'm using cegui together with ogre but i would guess that it's about the same!

here are the steps to get it running:

1. create a OpenGL capable window.

2. create a CEGUI::OpenGLRenderer
3. create the CEGUI::System
4. load scheme files
5. set default font and mousecursor
6. create a gui sheet
7. create interface


#include "CEGUI/renderers/OpenGLGUIRenderer/openglrenderer.h"

CEGUI::OpenGLRenderer *gl_renderer = 0;

void createInterface();



// initialises cegui ready for use
void initCEGUI()
{
// create OpenGL GUI Renderer
const unsigned int max_quads = 1000;
const int width = screen.width(); // replace with your screen width function
const int height = screen.height(); // replace with your screen height function
gl_renderer = new CEGUI::OpenGLRenderer( max_quads, width, height );

// create cegui system
new CEGUI::System( gl_renderer );


// load schemes
CEGUI::SchemeManager::getSingleton().loadScheme( "data/schemes/TaharezLook.scheme" );
CEGUI::SchemeManager::getSingleton().loadScheme( "data/schemes/WindowsLook.scheme" );


// set default mouse cursor
CEGUI::System::getSingleton().setDefaultMouseCursor( "WindowsLook", "MouseArrow" );

// set default font
CEGUI::Font *font = CEGUI::FontManager::getSingleton().createFont( "data/fonts/Commonwealth-10.font" );
font->defineFontGlyphs( (CEGUI::utf8*)" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~æøåÆØÅ" );
CEGUI::System::getSingleton().setDefaultFont( font );

// create the interface
createInterface();
}



// create the user interface windows
void createInterface()
{
CEGUI::WindowManager &wm = CEGUI::WindowManager::getSingleton();

// create gui sheet
CEGUI::Window *sheet = wm.createWindow( "DefaultGUISheet", "root" );
CEGUI::System::getSingleton().setGUISheet( sheet );


// create framewindow
CEGUI::FrameWindow *fw = (CEGUI::FrameWindow *)wm.createWindow( "WindowsLook/FrameWindow", "mainWindow" );
sheet->addChildWindow( fw );
fw->setText( "test framewindow" );
fw->setMinimumSize( CEGUI::Size( .25f, .25f ) );
fw->setMaximumSize( CEGUI::Size( .75f, .75f ) );
fw->setSize( CEGUI::Size( .5f, .5f ) );
fw->setPosition( CEGUI::Point( .2f, .2f ) );
fw->setCloseButtonEnabled( false );

// child button
CEGUI::PushButton *pb = (CEGUI::PushButton*)wm.createWindow( "WindowsLook/Button", "mainWindow/testButton" );
fw->addChildWindow( pb );
pb->setText( "test button" );
pb->setMinimumSize( CEGUI::Size( .1f, .1f ) );
pb->setMaximumSize( CEGUI::Size( .5f, .5f ) );
pb->setSize( CEGUI::Size( .3f, .3f ) );
pb->setPosition( CEGUI::Point( .125f, .125f ) );
}


8. pass events and time-pulses to the CEGUI::System
you must pass: key-press, key-release, mouse-press, mouse-release and mouse-move event on the CEGUI::System with injectKeyDown, injectKeyUp, injectMouseButtonDown, injectMouseButtonUp, injectMouseMove.

with key-press events you must also send the character with injectChar

timepulses must me sent with injectTimePulse which takes a float value with the time in seconds that passed since the last call to the function.

9. render the gui

its done with:

CEGUI::System::getSingleton().renderGUI();

10. cleanup.

delete CEGUI::System::getSingletonPtr();
if ( gl_renderer )
delete gl_renderer;


hope this helps... and that i have remembered everything!
i assume that you know how to get your OpenGL up and running!


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 12 guests