GRIM: Fix switching fullscreen crashing with tinygl
GRIM: Reduce code duplication.