Skip to content

Conversation

@pakillottk
Copy link

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.

Copy link
Owner

@jayhf jayhf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Thanks for improving the cleanup behavior!

Comment on lines +304 to +310
{
if (!_alreadyLoaded)
return;

_alreadyLoaded = false;
OnUnloaded(sender, new RoutedEventArgs());
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This event handler can be moved to an inner function that's shared with the Unloaded event.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants