First I will show you my first code running (quite nooby)
Code: Select all
#include<CEGUI/CEGUI.h>
#include<CEGUI/CEGUIDefaultResourceProvider.h>
#include<CEGUI/RendererModules/OpenGLGUIRenderer/openglrenderer.h>
using namespace CEGUI;
#include <allegro.h>
#include <GL/glut.h>
#include <iostream>
#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL/SDL.h>
int main ()
{
SDL_Surface * screen;
atexit (SDL_Quit);
SDL_Init (SDL_INIT_VIDEO);
screen = SDL_SetVideoMode (600, 480, 0, SDL_OPENGL);
CEGUI::OpenGLRenderer* myRenderer = new CEGUI::OpenGLRenderer(0, 800, 600);
new CEGUI::System( myRenderer );
//SDL_ShowCursor(SDL_DISABLE);
// initialise the required dirs for the DefaultResourceProvider
CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());
rp->setResourceGroupDirectory("schemes", "datafiles/schemes/");
rp->setResourceGroupDirectory("imagesets", "datafiles/imagesets/");
rp->setResourceGroupDirectory("fonts", "datafiles/fonts/");
rp->setResourceGroupDirectory("layouts", "datafiles/layouts/");
rp->setResourceGroupDirectory("looknfeels", "datafiles/looknfeel/");
rp->setResourceGroupDirectory("lua_scripts", "datafiles/lua_scripts/");
// This is only needed if you are using Xerces and need to
// specify the schemas location
rp->setResourceGroupDirectory("schemas", "../XMLRefSchema/");
// set the default resource groups to be used
CEGUI::Imageset::setDefaultResourceGroup("imagesets");
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
// Again, you only need to this one if you are using xerces and have
// defined a group for schemas.
//CEGUI::XercesParser::setSchemaDefaultResourceGroup("schemas");
// load in the scheme file, which auto-loads the TaharezLook imageset
CEGUI::SchemeManager::getSingleton().loadScheme( "TaharezLook.scheme" );
// load in a font. The first font loaded automatically becomes the default font.
if(! CEGUI::FontManager::getSingleton().isFontPresent( "Commonwealth-10" ) )
CEGUI::FontManager::getSingleton().createFont( "Commonwealth-10.font" );
System::getSingleton().setDefaultFont( "Commonwealth-10" );
System::getSingleton().setDefaultMouseCursor( "TaharezLook", "MouseArrow" );
//System::getSingleton().setDefaultToolTip( "TaharezLook/Tooltip" );
WindowManager& wmgr = WindowManager::getSingleton();
Window* myRoot = wmgr.createWindow( "DefaultWindow", "root" );
System::getSingleton().setGUISheet( myRoot );
FrameWindow* fWnd = (FrameWindow*)wmgr.createWindow( "TaharezLook/FrameWindow", "testWindow" );
myRoot->addChildWindow( fWnd );
fWnd->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
fWnd->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
fWnd->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
fWnd->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
fWnd->setText( "Hello World!" );
while (true)
{
glClear( GL_COLOR_BUFFER_BIT );
CEGUI::System::getSingleton().renderGUI();
SDL_GL_SwapBuffers();
}
}
I finally got sth drawn on the screen. Now I have some questions:
- The mouse cursor doesn't appear on screen... Why? I know I dissable it by SDL but the tutorial says that...
- If I show the mouse and I try to move the window or resize it, it doesn't work. Should it?
- When I try to integrate this code on another application that uses OpenGL I don't get the same result, I mean, the screen doesn't shows the window. Why?
Any more advices would be great!
Thanks!