SFML community forums

Help => General => Topic started by: TheHobHobbit on April 25, 2020, 11:30:59 pm

Title: close console at the same time as window?
Post by: TheHobHobbit on April 25, 2020, 11:30:59 pm
so I've got my program working with a console (for debugging information) and the window (for my game) and I've got the basic outline I've found in tutorials and seen in the forums:

while(mainWindow.isOpen()){
sf::Event event;
while (mainWindow.pollEvent(event)){if (event.type == sf::Event::Closed){
mainWindow.close();
}

but I've added "quitEverything = true;" after "mainWindow.close();" to tell the other threads I'm using to terminate. this is all working as intended.

but when hit X to close the window, I have to go manually close the console as well. I know how to get rid of the console altogether, but I kind of need my debug info.

asking because I can't seem to find anything on forums or Google, can I tell the console to close as well when quitEverything is true?

something like

if (quitEverything){sf::Console::close();}  ? does this exist?

I know I can close the console first and they both close, but I often put the game window fullscreen, so it's mildly annoying to close it and then the console as well.

thanks in advance for answers!


Title: Re: close console at the same time as window?
Post by: Laurent on April 26, 2020, 09:06:37 am
The console should close automatically when your app exits. Have you tried simple examples, and debugged what happens to your threads when you quit? Do they really exit as intended?
Title: Re: close console at the same time as window?
Post by: av8r on April 26, 2020, 09:13:26 pm
Are you using Visual Studio Community 2019?

The console window remains open with this prompt after debugging:

Quote
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .