In this case, just call this code each time the resolution is changed. For that purpose it is useful to put it into a functiona again (but without a loop!).

If you want to change the resolution with the F5 from default.c, you can use the loop you posted above for that, but remove it when you publish your game.