Okey so, I am trying to send the SDL events to CEGUI. However, it always returns nullptr and I can't for the life of me figure out why. Now it's probably me that have done a dumb mistake somewhere along the way. But since I can't find the error maybe you guys can.
So this is the code that throws the exception:
Code: Select all
void cGUI::OnSDLEvent ( SDL_Event & in_event )
{
switch ( in_event.type )
{
case SDL_MOUSEMOTION:
m_context->injectMousePosition ( in_event.motion.x, in_event.motion.y );
break;
case SDL_KEYDOWN:
m_context->injectKeyDown ( SDLKeyToCEGUIKey ( in_event.key.keysym.sym ) );
break;
case SDL_KEYUP:
m_context->injectKeyUp ( SDLKeyToCEGUIKey ( in_event.key.keysym.sym ) );
break;
case SDL_TEXTINPUT:
break;
case SDL_MOUSEBUTTONDOWN:
m_context->injectMouseButtonDown ( SDLButnToCEGUIButn ( in_event.button.button ) );
break;
case SDL_MOUSEBUTTONUP:
m_context->injectMouseButtonUp ( SDLButnToCEGUIButn ( in_event.button.button ) );
break;
}
}
Note that even if I comment out injectMousePosition, the same exception will be thrown by KeyDown. Input works for SDL however, as I had it up and running before implementing CEGUI. And ofcourse, if I comment this code out all togheter I get no crashes.
Might be worth mentioning that if I have the cursor outside the window when I launch the application it will run until I move the cursor inside the window and then immediately crash. Giving me the nullptr error (Exception thrown: read access violation. this->m_context-> was nullptr.)
However, if I have the cursor inside the window when the application is launching it will say:
Exception thrown: read access violation. this->m_context-> was 0x1
It might mean the same thing, I dunno.
Anyway, this is my Call Stack when the application crashes:
Code: Select all
Monarchs.exe!cGUI::OnSDLEvent(SDL_Event& in_event) Line 78
Monarchs.exe!ProcessInput(sPosition& in_mousePos, ClientState& in_ClientState, cInputManager& in_InputManager, cGUI& in_GUI) Line 9
Monarchs.exe!cWindow::ProcInput(ClientState in_state) Line 66
Monarchs.exe!cClient::Run() Line 37
Monarchs.exe!cClient::cClient() Line 20
Monarchs.exe!SDL_Main(int argc, char** argv) Line 24
Monarchs.exe!main_utf8(int argc, char** argv) Line 126
Monarchs.exe!main_getcmdline(...) Line 159
Monarchs.exe!main(int arc, char** argv) Line 172
[External Code]
This is how I set my context if it's relevant:
Code: Select all
m_context = &CEGUI::System::getSingleton ( ).createGUIContext ( m_guiRender->getDefaultRenderTarget ( ) );
m_root = CEGUI::WindowManager::getSingleton ( ).createWindow ( "DefaultWindow", "Root" );
m_context->setRootWindow ( m_root );
Oh, and I'm using Visual Studio 2015. That's all the relevant information I can think of. If you need anything else, just tell me and I'll be happy to oblige.
Thanks guys