I'm having trouble implementing CEGUI into my SFML game. I did some testing and found out that it's to do with drawing a sprite.
Here's what the basic Hello World CEGUI tutorial window looks like for me when I also try to draw a sprite:
And this is what it looks like with the sprite draw call commented out:
Here's the code:
#include <CEGUI.h>
#include <RendererModules\OpenGL\CEGUIOpenGLRenderer.h>
#include <SFML\Graphics.hpp>
#include <SFML\System.hpp>
using namespace CEGUI;
int main(int /*argc*/, char* /*argv*/[])
{
sf::RenderWindow window(sf::VideoMode(1280, 720), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
CEGUI::OpenGLRenderer& myRenderer = CEGUI::OpenGLRenderer::create();
CEGUI::System::create( myRenderer );
// 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 really needed if you are using Xerces and need to
// specify the schemas location
rp->setResourceGroupDirectory("schemas", "datafiles/xml_schemas/");
// 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");
SchemeManager::getSingleton().create("TaharezLook.scheme");
System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
WindowManager& winMgr = WindowManager::getSingleton();
DefaultWindow* root = (DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");
System::getSingleton().setGUISheet(root);
FrameWindow* wnd = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "Demo Window");
root->addChildWindow(wnd);
wnd->setPosition(UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
wnd->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
wnd->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
wnd->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
wnd->setText("Hello World!");
sf::Texture texture;
sf::Sprite sprite;
texture.loadFromFile("Data/Textures/Ship.png");
sprite.setTexture(texture);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color(255, 255, 255));
window.draw(sprite);
CEGUI::System::getSingleton().renderGUI();
window.display();
}
return 0;
}
Drawing a shape works properly, it's only a sprite which messes things up. Also, once the sprite draw call has been called once, I can stop calling it and the issue still persists. It's messing with the underlying OpenGL somehow.
Anybody have any advice?