Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How you are supposed to close the window correctly?  (Read 14893 times)

0 Members and 4 Guests are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: How you are supposed to close the window correctly?
« Reply #15 on: June 22, 2012, 12:38:12 am »
SFML doesn't provide a function to hide and show the console since this is a very OS specific task.
So you either hide it completly (you'd need to tell the linker about sfml-main(-d).lib), let stay in the background and don't hide it or write your own OS specific code (not recommended).

Non blocking input via the console doesn't work directly. You'd have to run the window and the console in seperate threads and then sync the messages between them.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kapesu8

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: How you are supposed to close the window correctly?
« Reply #16 on: June 22, 2012, 03:08:01 pm »
What else than just linking sfml-main.lib would I need to do to hide it completely?

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: How you are supposed to close the window correctly?
« Reply #17 on: June 22, 2012, 04:29:09 pm »
subsystem : windows
preprocessor : change _CONSOLE to _WINDOWS

Celtic Minstrel

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: How you are supposed to close the window correctly?
« Reply #18 on: June 22, 2012, 04:30:33 pm »
To hide it completely and not use it at all, I think you'd need to change your build settings to tell it not to use a console. (Or perhaps what Acrobat posted, I dunno; not even sure what he means.) To just hide it temporarily... not sure, probably some Windows API call.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: How you are supposed to close the window correctly?
« Reply #19 on: June 22, 2012, 04:49:16 pm »
std::exit() [...] and the application stops cleanly.
Even if it seems to end cleanly (that is, no error message), std::exit() shouldn't be used in C++ programs because the standard doesn't require this function to perform any cleanup.

Quote from: C++ Standard 2003, §3.6.1/4
Calling the function
void exit(int);
declared in <cstdlib> (18.3) terminates the program without leaving the current block and hence without
destroying any objects with automatic storage duration (12.4). If exit is called to end a program during
the destruction of an object with static storage duration, the program has undefined behavior.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Celtic Minstrel

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: How you are supposed to close the window correctly?
« Reply #20 on: June 22, 2012, 04:53:30 pm »
I only ever use std::exit (with non-zero argument) for exiting with an error, and not often for that; more often I use exceptions.

 

anything