glgui: rework render and input loops for better performance