ok, its pretty simple to do without GLUT. in fact, its *nearly* exactly the same.
let me say at first, these directions may have some useless steps, as m learning this as well still, but here it goes
first off, you need to link with the openGL renderer (openGLGUIRender.lib i believe)
well, heres some chunks of source code (of what i got working with CEGUI)
includes i use:
Code: Select all
//-----------
//Crazy Eddies GUI includes
//------------
#include <CEGUI.h>//main include
#include <CEGUIGUILayout_xmlHandler.h>//XML loading
#include "Renderers/OpenGLGUIRenderer/openglrenderer.h"
#include <sstream> //for use with the FPS stats
//global variable - or variable in a class, etc.
//need it for the renderer
CEGUI::OpenGLRenderer *mCEGUIRenderer;
setting up the renderer - you really only need the rendering creating code
Code: Select all
void MainApplication::setupCEGUI()
{
// Set the clear color
glClearColor (0.0, 0.0, 0.0, 1.0);
// Enable depth testing
glEnable( GL_DEPTH_TEST );
// Draw the back faces of polygons in wireframe
glPolygonMode( GL_FRONT, GL_FILL );
glPolygonMode( GL_BACK, GL_LINE );
mCEGUIRenderer = new CEGUI::OpenGLRenderer(1024);
new CEGUI::System(mCEGUIRenderer);
//used for repeating keys
mLastKeyInjected=0;
mLastKeyInjectTime=0.0;
mKeyInjectRate=0.15;
}
heres how to draw it to the screen:
put this in your main loop or whatnot
Code: Select all
CEGUI::System::getSingleton().renderGUI();
heres how to insert key presses & mouse events
i use SDL, so replace mSDLEvent.keypress with whatever you plan on using to handle keyboard commands, and the injection comands take chars and unicode.
mCurrentTime is just a variable that holds the current time in seconds
mElapsed time holds elapsed time since last update (also global, and in seconds)
Code: Select all
void MainApplication::updateCEGUI()
{
if(mSDLEvent.type==SDL_KEYDOWN)
{
//repeat control
if(mLastKeyInjected!=mSDLEvent.key.keysym.sym||mLastKeyInjectTime+mKeyInjectRate<=mCurrentTime)
{
mLastKeyInjected=mSDLEvent.key.keysym.sym;
mLastKeyInjectTime=mCurrentTime;
if(mSDLEvent.key.keysym.sym==SDLK_BACKSPACE)
{
mCEGUISystem->injectKeyDown(0x0E);
}
else if(mSDLEvent.key.keysym.sym==SDLK_RETURN)
{
mCEGUISystem->injectKeyDown(0x1C);
}
else
{
mCEGUISystem->injectChar( mSDLEvent.key.keysym.unicode );
mCEGUISystem->injectKeyDown( mSDLEvent.key.keysym.unicode );
}
}
}
if(mSDLEvent.type==SDL_KEYUP)
{
//mCEGUISystem->injectKeyUp(mSDLEvent.key.keysym.sym);
mCEGUISystem->injectKeyUp( mSDLEvent.key.keysym.unicode );
}
if(mMouseButtons&SDL_BUTTON(1))
{
mCEGUISystem->injectMouseButtonDown(CEGUI::LeftButton);
}
else
{
mCEGUISystem->injectMouseButtonUp(CEGUI::LeftButton);
}
//mCEGUISystem->injectMouseButtonUp();
//mCEGUISystem->injectMouseMove();
mCEGUISystem->injectMousePosition(mMouseX,mMouseY);
//mCEGUISystem->injectMouseWheelChange();
mCEGUISystem->injectTimePulse(mElapsedTime);
}
and heres the function i use to load a random layout.xml
Code: Select all
void MainApplication::loadCEGUI(std::string filename)
{
using namespace CEGUI;
try{
Logger::getSingleton().setLoggingLevel(Informative);
mCEGUISchemeManager = SchemeManager::getSingletonPtr();
if(!mCEGUISchemeManager->isSchemePresent((utf8*)"TaharezLook"))
mCEGUISchemeManager->loadScheme((utf8*)"TaharezLook.scheme");
mCEGUISystem=System::getSingletonPtr();
mCEGUISystem->setDefaultMouseCursor((utf8*)"TaharezLook", (utf8*)"MouseArrow");
CEGUI::Font *font;
if(!CEGUI::FontManager::getSingleton().isFontPresent("Commonwealth-10"))
{
font = CEGUI::FontManager::getSingleton().createFont( "Commonwealth-10.font" );
}
else
{
font=CEGUI::FontManager::getSingleton().getFont("Commonwealth-10");
}
mCEGUIWindowManager=CEGUI::WindowManager::getSingletonPtr();
Window* rootWindow = mCEGUIWindowManager->loadWindowLayout(filename.c_str());
mCEGUISystem->setGUISheet(rootWindow);
rootWindow->setMouseCursor("TaharezLook", "MouseArrow");
rootWindow->show();
}
catch(CEGUI::Exception &c){}
{
//no gui will be drawn
}
}
and heres the destructor...
Code: Select all
MainApplication::~MainApplication()
{
//SDL_FreeSurface(mScreen);
if(mClock)
delete(mClock);
if(CEGUI::System::getSingletonPtr())
delete CEGUI::System::getSingletonPtr();
if(mOpenGLRenderer)
delete(mOpenGLRenderer);
}
for creating windows in code, the openGL demo shows some examples of random widget creation. hope some of this helps, its a bit disorgonized... but, its all i really have at the moment. good luck
also, its almost st patricks day, so