Original Post
Hi, I just switched from GLUT to SDL and I'm having trouble handling events. It seems that when an event is fired, it's fired continuously until another event is fired. For instance, when I tap a key on my keyboard, the event gets fired, and I handle it, but after I've handled it, the event gets fired again, and again, and again, etc. etc. It keeps on getting fired until another event gets fired. Here is my loop: I don't know what to do at this point. All my events are doing this, not just a key press. Any idea what's going on? thanks, -alex-
int counter = 0;
Sdl.SDL_Event evt;
while (quitFlag == false)
{
Sdl.SDL_PollEvent(out evt);
switch (evt.type)
{
case Sdl.SDL_KEYDOWN:
if ((evt.key.keysym.sym == (int)Sdl.SDLK_ESCAPE))
{
quitFlag = true;
}
foo++;
System.Diagnostics.Debug.WriteLine("Pressed: " + counter.ToString()); // This gets executed around 100 times on a single key press.
break;
}
Sdl.SDL_PumpEvents(); // I tried commenting this out and it doesn't help.
try
{
MyRenderFunction();
}
catch (Exception ex)
{
Log.WriteToLog("***Error: "+ex.ToString());
}
}
}