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

Author Topic: Are resource managers really necessary?  (Read 2362 times)

0 Members and 2 Guests are viewing this topic.

The Terminator

  • Full Member
  • ***
  • Posts: 224
  • Windows and Mac C++ Developer
    • View Profile
Are resource managers really necessary?
« on: August 13, 2012, 01:47:48 pm »
I've written a resource manager, and I think honestly it's more pain than just using the plain old methods for the individual objects like textures, soundbuffers, etc. Do you guys think that a resource manager is worth it for a smallish game (under 20000) lines? If so, could you explain why?
Current Projects:
Technoport

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: Are resource managers really necessary?
« Reply #1 on: August 13, 2012, 01:58:19 pm »
It completly depends on the game and the code design and not on the line of codes.
If you're able to integrate the resource manager good enough into your code design then it would make a lot of sense, because everything resource related would then get handled by it.
Another reason for a resource manager is if you're using diffrent resources multiple times, so your manager will detect that he's already loaded that reasource and only direct you to the loaded one instead of slowly filling up your memory.

Now for games that run in states where at the beginning one loads all the resources and they get removed as soon as one leaves the state, it won't make much sense to have such a manager, since he'd then only function as resource loading wrapper and can be quite annoying to handle since everything is centralized.
For smaller games/code designs that allows it, it's completly okay to have the resources as member variable of the state it's used int.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mark

  • Guest
Re: Are resource managers really necessary?
« Reply #2 on: December 27, 2013, 08:57:54 pm »
Well, this is quite an old topic... But I got one very related argument against the resource managers for graphics resources too. Besides complicating the code, doesn't they upload multiple textures? And as I know, switching between textures while drawing is a very costly operation.

Wouldn't it be perfect for game to have a single texture with all the graphics the game needs on it to simplify the code and maximize performance?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
AW: Are resource managers really necessary?
« Reply #3 on: December 27, 2013, 09:14:16 pm »
Well there's always a texture size limit, it's especially low on older hardware. ;)

Plus if the game is a bit bigger, you might not want to load all the images at once, but only when it's needed, e.g. if have 20 bosses in your game, you don't want to load all 10 "animated" images of all the 20 bosses, but you'd probably load one animated boss when sgarting the boss level.
« Last Edit: December 27, 2013, 09:21:56 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Are resource managers really necessary?
« Reply #4 on: December 27, 2013, 09:16:49 pm »
Well, this is quite an old topic...
Yes. Generally, prefer to open a new thread and link to the old one.

Besides complicating the code
The idea is to simplify the code. Of course you have to implement resource managers once, but if you've designed them well, the client code that uses the resources will often be simpler.

doesn't they upload multiple textures?
I don't see how this is related to resource managers. If you allocate multiple textures, yes, otherwise, no. This is the same if you directly create the sf::Texture objects and load them.

Wouldn't it be perfect for game to have a single texture with all the graphics the game needs on it to simplify the code and maximize performance?
Code will be more complicated, because you have to determine the texture rect. Furthermore, there is a size limit for textures, so you can't pack infinitely many sprites into one.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Mark

  • Guest
Re: Are resource managers really necessary?
« Reply #5 on: December 27, 2013, 09:21:56 pm »
Thanks. I got the point.
« Last Edit: December 27, 2013, 09:25:40 pm by Mark »

 

anything