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

Author Topic: Exception Handling  (Read 4093 times)

0 Members and 1 Guest are viewing this topic.

immotus

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Exception Handling
« on: December 20, 2014, 01:24:03 am »
I have been looking through the SFML API but, I don't see anything about exceptions that might be thrown by the API Classes.  Basically, one of the things I am interested in is cases in which the application might lose the device.  In DirectX this would be a DeviceLost Exception which can happen when the user does something like Alt-Tab and gives focus to another window.  When this happens you might have to re-create textures, reset render states, etc...  So, does SFML handle all this under the hood? 

I haven't messed with graphics programming in a long time and I am trying to get a feel for what can go wrong with this library.  Can anyone point me in the right direction?  Thank you.

StormWingDelta

  • Sr. Member
  • ****
  • Posts: 365
    • View Profile
Re: Exception Handling
« Reply #1 on: December 20, 2014, 01:59:51 am »
I think it handles most under the hood but can't quite remember what ones we have to catch ourselves.  If all else fails you could wrap an SFML program in a try/catch and just go to town on it causing any exception you can think of to happen.  This way you can figure out what and where of things like this rather fast.  It would help though if the github actually showed this or the documentation comments showed this, that way we'd know what to catch.
I have many ideas but need the help of others to find way to make use of them.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Exception Handling
« Reply #2 on: December 20, 2014, 09:50:45 am »
SFML doesn't use exceptions at all. SFML 3 probably will, but for error handling only, not for this kind of stuff.
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Exception Handling
« Reply #3 on: December 20, 2014, 10:34:33 am »
As Laurent said, SFML doesn't (yet) use exceptions.
The "device handling" can in OpenGL be compared to context management, which happens "invisible" by SFML.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

immotus

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Exception Handling
« Reply #4 on: December 20, 2014, 12:20:51 pm »
Thanks guys  :)  That was enough to jog the old noodle into thinking about it in the right way!   Almost all of my experience with graphics has been in DirectX.  So, I looked into what OpenGL is doing way down there in the hardware and it appears that it does things in such a way that it never loses the device context or if it does, it keeps the data it needs handy so that it can recover. 

I've got a lot more to learn and, some DirectX baggage I need to discard but, I'm already starting to like what I see in OpenGL.  Thanks for the help.  In the meantime, I looked into exceptions OpenGL might have and I can deal with those easily enough on my own. 

Great library by the way, I really like it. 

Edit*  http://www.glprogramming.com/red/chapter14.html#name1
In case anyone is interested in errors that OpenGL can have.

Oops that's an old one.. try :
https://www.opengl.org/sdk/docs/man4/

Look for glGetError()  to see what errors you can track.
« Last Edit: December 20, 2014, 12:55:08 pm by immotus »