Page 1 of 1

[Solved] 0.8.2 Crash with injectMousePosition and SFML2.0

Posted: Tue Jul 23, 2013 01:23
by Sark

Code: Select all

22/07/2013 19:09:58 (Std)    ---- Version: 0.8.2 (Build: Jul 21 2013 Microsoft Windows MSVC++ 10.0 32 bit) ----
22/07/2013 19:09:58 (Std)    ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module.  TextureTarget support enabled via FBO extension. ----
22/07/2013 19:09:58 (Std)    ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
22/07/2013 19:09:58 (Std)    ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
22/07/2013 19:09:58 (Std)    ---- Scripting module is: None ----


Like the title says I get a crash when using injectMousePosition with SFML2.0. I'm able to properly draw windows to the screen and I can manually set the Mouse position using getMouseCursor().setPosition. Here's the code just in case I'm missing something obvious:

Code: Select all

#include <CEGUI/RendererModules/OpenGL/GLRenderer.h>
#include <CEGUI/CEGUI.h>

#include <SFML/Graphics.hpp>

using namespace CEGUI;

int main( int argc, char ** argv )
{
   sf::RenderWindow window( sf::VideoMode(800, 600), "CEGUI Test" );

   OpenGLRenderer & renderer = OpenGLRenderer::bootstrapSystem();
   
   GUIContext & context = System::getSingleton().getDefaultGUIContext();
   
   DefaultResourceProvider * rp = static_cast<DefaultResourceProvider*>(
      System::getSingleton().getResourceProvider());
   rp->setResourceGroupDirectory("defRes", "../data/");
   rp->setDefaultResourceGroup("defRes");
      
   SchemeManager::getSingleton().createFromFile("WindowsLook.scheme");
   context.getMouseCursor().setDefaultImage("WindowsLook/MouseArrow");
    Font & defaultFont = CEGUI::FontManager::getSingleton().createFromFile("DejaVuSans-12.font");

   WindowManager & winMgr = WindowManager::getSingleton();
   DefaultWindow * root = (DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");

   context.setRootWindow( root );
   
    while (window.isOpen())
    {
        sf::Event evt;
        while (window.pollEvent(evt))
        {
            if (evt.type == sf::Event::Closed ||
             sf::Keyboard::isKeyPressed( sf::Keyboard::Escape ) )
                window.close();

         if( evt.type == sf::Event::MouseMoved )
            context.injectMousePosition( evt.mouseMove.x, evt.mouseMove.y );

        }

      window.clear();
      
      System::getSingleton().renderAllGUIContexts();

      window.display();
    }

   CEGUI::OpenGLRenderer::destroySystem();

   return 0;
}


Even this results in the same crash:

Code: Select all

   sf::RenderWindow window( sf::VideoMode(800, 600), "CEGUI Test" );
   OpenGLRenderer & renderer = OpenGLRenderer::bootstrapSystem();
   GUIContext & context = System::getSingleton().getDefaultGUIContext();
   
   context.injectMousePosition( 5, 5 );

   CEGUI::OpenGLRenderer::destroySystem();
   return 0;


I'm clueless about how to fix this so any help would be appreciated!

Re: 0.8.2 Crash with injectMousePosition and SFML2.0

Posted: Wed Jul 24, 2013 12:08
by Kulik
Please provide a backtrace.

Re: 0.8.2 Crash with injectMousePosition and SFML2.0

Posted: Thu Jul 25, 2013 21:21
by Sark
It was not a bug with CEGUI after all, I was dumb and was simply linking with an incorrect version of the library. It's working fine now, sorry to have wasted your time!