SFML community forums

Bindings - other languages => DotNet => Topic started by: immotus on December 20, 2014, 01:24:03 am

Title: Exception Handling
Post by: immotus 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.
Title: Re: Exception Handling
Post by: StormWingDelta 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.
Title: Re: Exception Handling
Post by: Laurent 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.
Title: AW: Exception Handling
Post by: eXpl0it3r 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.
Title: Re: Exception Handling
Post by: immotus 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.