First off, here is the information you will undoubtedly what to know about the system:
CEGUI Log file:
14/06/2017 21:43:45 (Std) ---- Version: 0.8.5 (Build: Jun 1 2017 Debug Microsoft Windows MSVC++ 14.0 (2015) 64 bit) ----
14/06/2017 21:43:45 (Std) ---- Renderer module is: CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module. ----
14/06/2017 21:43:45 (Std) ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
14/06/2017 21:43:45 (Std) ---- Image Codec module is: OgreImageCodec - Integrated ImageCodec using the Ogre engine. ----
14/06/2017 21:43:45 (Std) ---- Scripting module is: None ----
Rendering: Ogre 1.9 built with boost 1.61
Windowing and Input Handling: SDL 2.0.5
OS: Window 10Pro 64bit
The relevant functions:
Initializing CEGUI:
Code: Select all
void cegui_Init(Ogre::Root* ogreRoot) {
cegui = &CEGUI::OgreRenderer::bootstrapSystem(*(ogreRoot->getRenderTarget("test")));
//Specifiy the location of CEGUI resources and set a type and group.
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("F:/Libraries/Source/CEGUI/CEGUI_0_8_5/datafiles/imagesets", "FileSystem", "Imagesets");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("F:/Programming/Test/layouts", "FileSystem", "Layouts");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("F:/Libraries/Source/CEGUI/CEGUI_0_8_5/datafiles/fonts", "FileSystem", "Fonts");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("F:/Libraries/Source/CEGUI/CEGUI_0_8_5/datafiles/looknfeel", "FileSystem", "LookNFeel");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("F:/Libraries/Source/CEGUI/CEGUI_0_8_5/datafiles/schemes", "FileSystem", "Schemes");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("F:/Libraries/Source/CEGUI/CEGUI_0_8_5/datafiles/lua_scripts", "FileSystem", "lua_scripts");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("F:/Libraries/Source/CEGUI/CEGUI_0_8_5/datafiles/animations", "FileSystem", "Animations");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("F:/Libraries/Source/CEGUI/CEGUI_0_8_5/datafiles/xml_schemas", "FileSystem", "schemas");
//Set the Default Resource Groups
CEGUI::ImageManager::setImagesetDefaultResourceGroup("Imagesets");
CEGUI::Font::setDefaultResourceGroup("Fonts");
CEGUI::Scheme::setDefaultResourceGroup("Schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
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("SchemasDefaultResourceGroup", "schemas");
//-------------------------------------------------------------------Set the look and Feel----------------------------------------------------------------------
CEGUI::SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
CEGUI::FontManager::getSingleton().createFromFile("DejaVuSans-10.font");
//--------------------------------------------------------------Set and Initialize Default Systems---------------------------------------------------------------
//Ensure the default font is DejaVuSans-10
CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont("DejaVuSans-10");
//Set the default mouse cursor
CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
}
Create a button and subscribe it to and event
Code: Select all
CEGUI::Window* eBtn;
void ceGuiTestWindowInCode() {
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::Window* myRoot = wmgr.createWindow("DefaultWindow", "root");
CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(myRoot);
eBtn = wmgr.createWindow("TaharezLook/Button", "exit");
eBtn->setPosition(CEGUI::UVector2(CEGUI::UDim(0.43f, 0.0f), CEGUI::UDim(0.475f, 0.0f)));
eBtn->setSize(CEGUI::USize(CEGUI::UDim(0.15f, 0.0f), CEGUI::UDim(0.05f, 0.0f)));
eBtn->setText("Exit");
myRoot->addChild(eBtn);
eBtn->subscribeEvent(CEGUI::PushButton::EventClicked, exitEvent);
}
The function that should be getting called:
Code: Select all
bool exitEvent(const CEGUI::EventArgs& ) {
cont = false;
return false;
}
And Finally the main loop where input is injected:
Code: Select all
SDL_Event e;
float timer = 0;
//main loop
while (cont) {
Ogre::WindowEventUtilities::messagePump();
while (SDL_PollEvent(&e)) {
if (e.type == SDL_KEYDOWN)
cont = false;
if (e.type == SDL_MOUSEMOTION)
CEGUI::System::getSingleton().getDefaultGUIContext().injectMouseMove(e.motion.xrel, e.motion.yrel);
if (e.type == SDL_MOUSEBUTTONDOWN) {
if(e.button.button == SDL_BUTTON_LEFT)
CEGUI::System::getSingleton().getDefaultGUIContext().injectMouseButtonClick(CEGUI::LeftButton);
}
}
timer = timeSinceLast();
CEGUI::System::getSingleton().getDefaultGUIContext().injectTimePulse(timer);
CEGUI::System::getSingleton().injectTimePulse(timer);
root->renderOneFrame();
}
The window is created fine and the buttonWindow is displayed and the mouse cursor displays and seems to work fine. Also, when I mouse over the buttonWindow the button highlights so it seems to recognize the mouse is over it. The injectMouseButtonClick(DEGUI::LeftButton) line is called when the left mouse button is clicked, however, the exitEvent( const CEGUI::EventArgs&) function is never called (Or at least it never executes).
I've tried creating a function pointer and using that to register the event with the same result.
I've tried using the Event::Subscriber(exitEvent) same result.
I've tried encapsulating the exitEvent in a function and calling it exactly as the tutorial Practive A push button show... same result.
I've even tried creating the test GUI with a Layout file and going at it that way... same result. (This is a great feature by the way... you guys rock!)
I don't know if this is some weird interaction with SDL 2.0 (though I can't see what that would be) or If I'm just missing something but I've been tilting at this particular windmill off an on for three days now and I'm totally out of ideas. Any help would be much appreciated.
Thanks.