I'm trying to integrate CEGUI with a school project, and I'm having a bit of trouble with the OpenGLRenderer. I set up the basic GL renderer and simple window as outlined in the beginner docs. I kinda banged my head against the desk a few times trying to figure out why CEGUI's mouse coordinates did not correspond to the coordinates GLUT was giving me for the mouse. Fortunately, I found the OpenGLRenderer::setDisplaySize() method and am now calling it before trying to render anything. That worked fine (this method may be worth a mention in the new user docs, actually). However, I now have a new problem. The renderer does not seem to want to render outside of an 800x600 box... I have linked the log and two images (1, 2) detailing the problem a bit more (these links may be dead in a few months, sorry. No attachments on this forum?). The actual window size can be read from the terminal on the right (format: DS: <width> <height>).
Any clue? Here is the code for my entire CEGUI renderer. It's a custom framework over GLUT, but it should be pretty obvious what method does what.
Code: Select all
#include "CeguiUI.h"
CeguiUI::CeguiUI() :
renderer(CEGUI::OpenGLRenderer::create())
{
CEGUI::System::create( renderer );
WindowManager& wmgr = WindowManager::getSingleton();
Window* myRoot = wmgr.createWindow( "DefaultWindow", "root" );
System::getSingleton().setGUISheet( myRoot );
CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>
(CEGUI::System::getSingleton().getResourceProvider());
rp->setResourceGroupDirectory("schemes", "/usr/local/share/CEGUI/schemes/");
rp->setResourceGroupDirectory("imagesets", "/usr/local/share/CEGUI/imagesets/");
rp->setResourceGroupDirectory("fonts", "/usr/local/share/CEGUI/fonts/");
rp->setResourceGroupDirectory("layouts", "/usr/local/share/CEGUI/layouts/");
rp->setResourceGroupDirectory("looknfeels", "/usr/local/share/CEGUI/looknfeel/");
rp->setResourceGroupDirectory("lua_scripts", "/usr/local/share/CEGUI/lua_scripts/");
// 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");
// setup default group for validation schemas
CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser();
if (parser->isPropertyPresent("SchemaDefaultResourceGroup"))
parser->setProperty("SchemaDefaultResourceGroup", "schemas");
CEGUI::SchemeManager::getSingleton().create( "TaharezLook.scheme" );
FrameWindow* fWnd = static_cast<FrameWindow*>(
wmgr.createWindow( "TaharezLook/FrameWindow", "testWindow" ));
myRoot->addChildWindow( fWnd );
// position a quarter of the way in from the top-left of parent.
fWnd->setPosition( UVector2( UDim( 0.25f, 0 ), UDim( 0.25f, 0 ) ) );
fWnd->setSize( UVector2( UDim( 0.5f, 0 ), UDim( 0.5f, 0 ) ) );
fWnd->setText( "Hello World!" );
}
CeguiUI::~CeguiUI() {
// TODO Auto-generated destructor stub
}
void CeguiUI::drawOverlay() {
CEGUI::System::getSingleton().renderGUI();
}
void CeguiUI::update(const GameState &state) {
const GameWindowState &window = state.window();
Size s(window.width, window.height);
renderer.setDisplaySize(s);
printf("DS: %f %f\n", s.d_width, s.d_height);
System &system = System::getSingleton();
const MouseState& mouse = state.mouse();
if(mouse.hasMoved()) {
system.injectMousePosition((float)mouse.getX(), (float)mouse.getY());
}
if(mouse.isDownNew(GAME_MOUSE_BUTTON_LEFT))
system.injectMouseButtonDown(LeftButton);
if(mouse.isDownNew(GAME_MOUSE_BUTTON_RIGHT))
system.injectMouseButtonDown(RightButton);
if(mouse.isUpNew(GAME_MOUSE_BUTTON_LEFT))
system.injectMouseButtonUp(LeftButton);
if(mouse.isUpNew(GAME_MOUSE_BUTTON_RIGHT))
system.injectMouseButtonUp(RightButton);
//TODO wheel
//TODO keyboard
system.injectTimePulse(state.gameTime()); /* gameTime() is time interval since last frame */
}
Thanks guys!