Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: RenderManager, encapsulate sf::RenderWindow  (Read 991 times)

0 Members and 1 Guest are viewing this topic.

xmax3

  • Newbie
  • *
  • Posts: 6
    • View Profile
RenderManager, encapsulate sf::RenderWindow
« on: May 29, 2014, 05:02:18 pm »
Hi ! I'm currently thinking about a "RenderManager" for my game, it would encapsulate a sf::RenderWindow (with method to draw on it, etc, etc) and the video settings (whether the particles, vsync, fullscreen are enabled or not for example).

My question is: Am-I better to recode all access method of my sf::RenderWindow (draw, getView, setMaxFps, etc) and then when I'll draw my game I'll pass the RenderManager to the "object.draw(...)" method ? It's a lot of method to recode though, so I don't know if it's a good thing...

I'm also using TGUI for the controls and it needs the sf::RenderWindow for drawing and probably for other stuffs like cursor position on the window, so I suppose I'm better to code an access method to the sf::RenderWindow, then I'll be able to pass it directly to the tgui::gui ?

I have the felling my questions are a bit simple, but I want to be sure I'm doing it right.
If you have any suggestion, I'm open to it. Thanks ! :)
Hello ! Just to advise you that my first language is french, so my english may not be perfect. I want to improve it, so I prefer to go in the english forums. Thank you!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: RenderManager, encapsulate sf::RenderWindow
« Reply #1 on: May 29, 2014, 05:14:39 pm »
What is your intention? If you build a wrapper that provides all the methods of sf::RenderWindow, then you're not really encapsulating it, so why not use it directly? When you design a new class, only provide the methods you need, not everything that might be useful one day. Keep interfaces small.

If you already have such a class, I'd try to move graphics-specific code into it. In a bigger project, the last thing you want is when every logic class or entity needs to know how to create and render its own sprite... There have been a lot of threads on separation between graphics and logics in this forum, you might be interested in them.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

xmax3

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: RenderManager, encapsulate sf::RenderWindow
« Reply #2 on: May 29, 2014, 05:44:49 pm »
Quote
If you build a wrapper that provides all the methods of sf::RenderWindow, then you're not really encapsulating it, so why not use it directly?
That was my worry. I'm going to rethink about that. If I have any questions I'll post them here.

Quote
There have been a lot of threads on separation between graphics and logics in this forum, you might be interested in them.
Yeah, that's a good idea. I'll be looking for it.

Edit: Just as an help for future viewers of this thread, I found this project on Nexus's git: https://github.com/Bromeon/TemporaryOutbreak
« Last Edit: May 29, 2014, 06:25:05 pm by xmax3 »
Hello ! Just to advise you that my first language is french, so my english may not be perfect. I want to improve it, so I prefer to go in the english forums. Thank you!

 

anything