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

Author Topic: Does SFML check errors ?  (Read 1175 times)

0 Members and 1 Guest are viewing this topic.

valenciano

  • Newbie
  • *
  • Posts: 16
    • View Profile
Does SFML check errors ?
« on: September 08, 2018, 12:14:45 pm »
Greetings everyone,

I would like to know if SFML2 automatically checks if the window and renderer successfully initialized like you could do with SDL2 by checking if a pointer is null and then send a message via the stderr flux ?

Is there a built-in "check-error" function that does it in SFML2 ?

Thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Does SFML check errors ?
« Reply #1 on: September 08, 2018, 12:52:03 pm »
In most scenarios these system calls shouldn't fail, which is why we don't have like a boolean returned from the create function.
In case there was something wrong with the window, which again shouldn't really happen, then isOpen() will return false and some error message will be written to sf::err().
If an OpenGL context couldn't be created as requested, SFML again will write an error message to sf::err().

We don't write very defensively to cover all and every possible case, but instead we make reasonable assumption. So if your system doesn't have a window manager or can't handle OpenGL, then SFML applications may simply crash.

On the other hand when you get an SFML class instance, then you know, you can start working with it and don't need to double check if everything is working fine. Which is part of RAII (Resource Allocation Is Initialization).
« Last Edit: September 08, 2018, 12:53:44 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything