Hello. I'm making hacker roguelike simulator, kinda like uplink + cataclysm-dda. Majority of time player spends in in-game OS hacking something.
Gui of this os consists of several "windows" like terminal, proxies list, resource consumption monitor and so on.
Contents of each window is drawed by in-game processes which are runned and managed by OS class instance.
Problem is, i don't know how to restrict process drawing to specified rectangle of game window.
Right now i have OperatingSystem::Draw(sf::RenderWindow&) method, which draws background and then calls draw-method of every active process with sf::RenderWindow and sf::Rect which is used by process instance to know where to draw it's contents. I don't like that process could potentially draw anywhere it wants, because whole window is passed in and i must manually take care of this. That's error-prone.
So, what options i know of at the moment:
1) sf::View & viewports looks like something related to my problem. Though in tutorials it looked like it just renders same content, but scaled or resized or something. Didn't investigate it further, though.
2) Maybe make os pass only rect to process's draw method, make process's draw method render to texture with size of passed rect and return this texture to OS and make OS take care of rendering the texture to game window in correct position. Possible drawback: rendering to texture, then rendering to window would decrease perfomance. Or not?
I think second approach is the most elegant one. It also abstracts process of window arrangement in OS.
What would you advise?
p.s. english isn't my native language, sorry about mistakes and if you didn't understand something please tell - i'll try to explain better