SDL2 Window Not Responding (Windows 10)

SDL Newbie, just started following a tutorial and whenever I launch my window it pops up fine but the color does not change and it shows that it is not responding. All of the code compiles fine and I believe based on some of the other forums I have read that it might have something to do with the event system. I included both the cpp file for my game class as well as my main file any help would be appreciated.

Welcome! Show your main() function. You should include your code as file or wrap it inside code tags in your message like this:

int main() {
  return 0;

In Game::handleEvents you should check the return value of SDL_PollEvent to make sure there was an event before accessing the event object. Use a loop to handle all events.

while (SDL_PollEvent(&event))
	// handle event...

But I’m not sure that is what’s causing the problem you describe. Are you sure Game::render and Game::handleEvents are actually called? You might want to show us your game loop.

You say the colour doesn’t change but from the looks of it you only seem to draw a white background every time.

I’m sure that’s the problem, there’s mouse events generated in large amounts, while the render calls take all the CPU time, not allowing SDL pull events from Windows event queue. Nice catch!

Hello, here is the main function.

Game* game = nullptr;

int main(int argc, char* argv[])
	game = new Game();

	game->init("BirchEngine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, false);

	while (game->running());

	return 0;

Sorry I should have been more clear the window is meant to be white however when I load the window and it does not respond it is black.

while (game->running());
              Remove this semicolon
1 Like

Thank you, it works now, Very silly mistake lol.

edit: already answered. Weird that the forum didn’t show any of the other replies until I replied. LOL