I've been using SDL2 on my Macbook with Xcode for a little bit, and I'm very pleased. Lately I tried to receive a focus lost event, but it wasn't working. After some tinkering, I found out that no window events were being received, except a window event that had a type of 512 that showed up 2-5 times a second at random intervals. The WindowEventID
s are in an enum, not in hex format, so it shouldn't be some hex number. I ran a search through the SDL2 framework for 512 and found nothing. Other events, like SDL_QUIT
and SDL_KEYDOWN
work just fine. Anybody know what's going on?
Here is my event loop:
SDL_Event event;
bool running = false;
while(running) {
while(SDL_PollEvent(&event)) {
if(event.type == SDL_QUIT)
running = false;
else if(event.type == SDL_KEYDOWN) {
cout << event.key.type << endl;
}
else if(event.type == SDL_WINDOWEVENT) {
cout << event.window.type << endl;
}
}
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
while(SDL_PollEvent(&event)) {}
will consume lot of CPU. it is a non blocking operation and will keep returning false when there is no events.