ajon542 / GameEngine

Experimenting with OpenTK inside WPF
0 stars 0 forks source link

Closing and opening scene window, scene is lost #13

Closed ajon542 closed 8 years ago

ajon542 commented 8 years ago

If you close and open the scene window, the open gl scene is lost.

ajon542 commented 8 years ago

It is possibly related to the SceneViewModel.cs Initialized method. There is a "loaded" flag that may be preventing the scene from initializing.

The SceneViewModel constructor is only called once but the Initialize method is called multiple times when switching between windows etc.

ajon542 commented 8 years ago

Attempting to add more logging to the project in order to assist in tracking this issue down.

ajon542 commented 8 years ago

Whenever we switch tabs we just get an OpenGLControl.OnLoaded. However, when we close and open the tab, we get the ctor for SceneView and OpenGLControlView, OnHostInitialized, SetupTimer, OnLoaded and then finally a SceneViewModel.Initialized. The problem here is that the SceneViewModel is not shutdown at any point and it thinks it is already initialized. I think the scene is not really handling the shutdown and this may be causing the problem.

ajon542 commented 8 years ago

Essentially we need to handle the close event in the Scene. We need to do our correct cleanup and delete all shader programs as they will be created again in Initialize.