Lucky 10,000th viewer!

Published April 20, 2006
Advertisement
You might be the lucky 10,000th viewer of this journal! If so, I have a spare picture of an Xbox 360 from my last competition you may collect!


One thing with my architecture design I'm still having trouble conceptualising is the resource manager. My usual breakdown for game engine design is to lump all the related material together into their own modules: a video manager for the graphics, audio manager for the sound, input manager for the control etc. This helps keep all the hardware related stuff buried behind an interface layer so I don't have to worry about it that much when actually making the game.

However I'm not sure what to do with all the resources a game needs: textures, sounds, music, data files, etc. Do I let all the relevant modules handle their own resources, or do I create a resource manager for handling everything? Given I haven't done that much in memory management programming myself, and there's also aspects like the video card memory to deal with, it's all rather confusing for me. I'd like to have a system where I could just specify how much memory I'd like to use for each resource, and then precache textures and sounds to minimise loading times for computers with more memory, but this requires a way of keeping track of all resources as well as the amount of memory left in the system.

Since I'm unsure about this, I'd like to ask you what your solution was to general resource management. Any suggestions as to how you structured the architecture, or pointers to good articles out there that could explain a good solution to me?
0 likes 5 comments

Comments

Ravuya
Holy carp! I am the 10 000th viewer (and the 10 001th viewer). [grin]
April 20, 2006 10:53 PM
HopeDagger
Lucky 10,005 is all mine. [grin]
April 20, 2006 11:14 PM
Trapper Zoid
We have a winner! [grin]

I bet at least 2,000 of these views are from myself, checking for comments or from minor corrections to my journal entries.
April 20, 2006 11:46 PM
Telastyn
I'm not sure if the resource management I do is particularly good, but it's the best I've made.

A resource manager is nothing more than a [pluggable] factory. I use a common ResourceDefinition class [which in the end is just a string/string pair] which acts as loading instructions for a particular resource. A common templated [C# generic] resource manager handles common code, a common interface, and specifies the factory type via the main virtual function T Load(ResourceDefinition);. Particular managers [for sound objects, images, etc.] then inherit from the resource manager base, and specify handlers to the pluggable factory to interpret the ResourceDefinition commands.

This allows for code re-use as needed for the common parts, but leaving much flexibility in the specific requirements for different resources, and even addition of various loading procedures for resources stored differently.

In the end, this is how it ends up used:

font_manager.Add(new resource_definition("Arial12", "simpletext arial 12"));
font_manager.Alias("ConsoleFont", "Arial12");
ConsoleDisplay = new renderable.ChatBox("ConsoleFont");


April 21, 2006 12:05 AM
Trapper Zoid
Ah, that's a really interesting approach. I hadn't heard of the pluggable factory pattern before. I guess I also hadn't considered using the more advanced features of C++ to shape my architecture design (I really just treat it like C with classes [smile]).
April 21, 2006 01:06 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement