I once did something similer to this (once sorry cant find that code “it was in my juvinile days”)
I have a way of doing this im not sure if the best (i assume there must be a professional/correct/fast method of changing viewports perhaps by naming them or something)
but as Michael said the last glViewport() call obiously rules. so every time i have i wanted to refresh a view port i drew a new viewport over the old. this may make it more understandable.
glViewPort(parameters); //new veiwport over the old every time a scene is refreshed
and when u wish to draw geometry just cal the appropreate function
as u can c this is a “quick hack” and probably not the way it should be done but it worked for me.
if any 1 has comments about this method i would like to hear them im not to certain about what happens to the old vewports which i have drawn over are they still running and if so r they taking up system resources.
its an answer but its full of holes(sorry i couldn’t do better than that)