ajon542 / GameEngine

Experimenting with OpenTK inside WPF
0 stars 0 forks source link

Exceptions being thrown unhandled and program continues running #9

Open ajon542 opened 8 years ago

ajon542 commented 8 years ago

I've noticed times when debugging that an exception is thrown or an error occurs somewhere, particularly when compiling or linking shaders and the program continues to run and we get a black screen. I think the project will benefit by assertions when something goes wrong, especially in debug mode.

ajon542 commented 8 years ago

This appears to occur when exceptions are thrown from Update or Render calls.

ajon542 commented 8 years ago

This also occurs if a shader compile fails in LoadShader. The exception appears to not have any effect. Having a look at the call stack, the exception is probably caught in SceneInitialized.Execute or any of the other Execute methods.

ajon542 commented 8 years ago

https://www.benday.com/2015/04/01/automatic-exception-handling-on-icommand-viewmodel-properties/

ajon542 commented 8 years ago

The above link can be implemented in DelegateCommand.Execute. However, the GameEngineException is crashing the program at home. At work it is not crashing... That is weird.

ajon542 commented 8 years ago

image

ajon542 commented 8 years ago

We are inside an event handler, we probably shouldn't be throwing an exception from within here. If we can't compile the shaders then we need to think of an alternate method to allow the user to fix them. This probably ties more into running the game engine and not running the scene until all shader errors are fixed.

ajon542 commented 8 years ago

We could even fallback to default shaders that are known to work and warn the user.