Hello there, I’ve recently encountered a problem where my graphics window (besides the console output) freezes and becomes unusable after minimizing, maximizing, closing (attempt), or dragging it.
My program is wrapped in a structure where there is a “Main.cpp” file which contains a “while-loop” that stops running if the boolean “isRunning” is set to false.
This loop continuously calls the “handleEvents” method in another file.
The “handleEvents” method looks like this.
//Aforementioned while-loop
while (game->running()) {
game->setFrameStart();
game->handleEvents();
game->update();
game->render();
game->computeFrameTime();
game->runFrameDelay();
}
//HandleEvents Method
void Game::handleEvents() {
SDL_Event event;
SDL_PollEvent(&event);
if (event.type == SDL_QUIT) {
isRunning = false;
SDL_DestroyWindow(window);
printf("Quitting");
}
}
I’ve been in forums where people have encountered similar problems caused by them not polling events properly or not at all, but as seen above, I am indeed doing so.
Furthermore I’ve not been able to find any articles at all that match my problem.
I would greatly appreciate any help, also this is my first post here, so please, if I did something wrong do remind me of it.