I have a question about placing many 2D elements in an openGL window. I am doing that in my system a lot and so far I was using different glViewPort calls for placing each element in the window and then drawing it according to its own coordinates. It works fine like that but this leads me to the question of how heavy a glViewPort call actually is. I would like to know that since my code is getting full of it due to the number of 2D elements and the fact that they can have children elements so in a hierarchy of children imagine that glViewPort is called for each one in the hierarchy.
From a code point of view using glViewPort is easy and nice but how heavy is it? As an alternative I could have one viewport only for the main window and after that placing all the elements by scaling and translating. I have implemented both drawing methods but I can’t seem to determine how heavy each one is. That’s why I am turning to the community for help.
Might be making a huge mistake of course by considering one of these methods but since I don’t know if I am, I would like your help for that. The way I see it:
[ul][li] Easy to use, just set the viewport to the x,y pos of the 2D Element and the width/height to its width/height and you are done[*]Speed = ???[/ul] [/li]
Scaling and translating advantages:
[ul][li] Allows for floating point coordinates of the elements[*]Speed = ???[/li]Requires one translation and one scaling for each element instead of a glViewPort – which I can’t say if it’s better or worse[/ul]
Thanks in advance!