1
Window / GetEvent always returns true
« on: December 30, 2009, 02:17:02 am »
Hi again,
I seem to have a problem with events when I migrate my code to linux and gcc
Here is a snippet of my game loop:
This code works fine on windows and VC++, but in linux the event while loop --> while (mRenderWindow->GetEvent(mEvent)) <-- always returns true.
According to the debugger the first few events catched seems reasonable (Joy_Moved, Gained_Focus and Mouse_Entered)
After that it constantly receives the event Mouse_Moved.
The while loop never stops and obviously the code never reaches the actual rendering futher down.
I have tried to replace the while with an if, and then things start to work as expected. But I don't want to do that do I?
Am I overlooking something here or is this a bug?
I seem to have a problem with events when I migrate my code to linux and gcc
Here is a snippet of my game loop:
Code: [Select]
void StateManager::startRendering()
{
mRunning = true;
while (mRunning)
{
while (mRenderWindow->GetEvent(mEvent))
{
if (mEvent.Type == Event::Closed)
{
mRunning = false;
}
else if(mEvent.Type == Event::KeyPressed)
{
mStates.back()->keyPressed((Event::KeyEvent&)mEvent.Key);
}
else if(mEvent.Type == Event::KeyReleased)
{
mStates.back()->keyReleased((Event::KeyEvent&)mEvent.Key);
}
}
mRenderWindow->Clear();
if(mStates.back()->frameRender(*mRenderWindow))
{
mRunning = false;
}
mRenderWindow->Display();
}
mRenderWindow->Close();
}
This code works fine on windows and VC++, but in linux the event while loop --> while (mRenderWindow->GetEvent(mEvent)) <-- always returns true.
According to the debugger the first few events catched seems reasonable (Joy_Moved, Gained_Focus and Mouse_Entered)
After that it constantly receives the event Mouse_Moved.
The while loop never stops and obviously the code never reaches the actual rendering futher down.
I have tried to replace the while with an if, and then things start to work as expected. But I don't want to do that do I?
Am I overlooking something here or is this a bug?