Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded OpenTK and added a cleanup #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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