jayhf / OpenTkControl

A faster way to use OpenTk in WPF without Forms dependencies
MIT License
30 stars 6 forks source link

Upgraded OpenTK and added a cleanup #8

Open pakillottk opened 4 years ago

pakillottk commented 4 years ago

The OpenTK reference has been upgraded.

Added a cleanup event that it's called when the current OpenGL context it's about to get destroyed. That gives a chance to the application to free any unmanaged resources that requires the OpenGL context to be active (like texture handlers, vbos, etc)

The unloaded event it's not called if the control it's destroyed due to the application shutting down. To prevent any issues or even memory leaks (because of unmanaged resources dependent on the OpenGL's context) the control suscribes to the current application's shutdown event to release all the unmanaged resources and raise the cleanup event, so all the system can be stopped gracefully and the application has always a chance to release unmanaged resources if needed.