Avoid getting repeated tick timers when restarting main loop #69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
I've run into an issue where tick-events fire on my glut windows once for every time I've entered glutMainLoop.
The reason seems to be that there is no way to cancel glut timers so they persist when leaving the main loop. Old timers stick around inside glut until the main loop is entered again. Since the main window always gets the same id (== 1), both old and new tick timers will have the same window id so they will all fire the window's tick-callback.
I was running SBCL on a Mac when I saw this.
I solved the issue by giving each tick-timer a unique id and providing an indirection through a lookup table from tick-timer-id to window-id. That way, I can clear out a window's tick timers by just removing its entries from the lookup table.
Another approach that I guess would work equally as well is to give each window a unique id.
Hope this makes sense.