• What is your GameDev Story?

This topic is 4958 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

In creating the sound module of a game engine, I've asked myself whether it would be best to have the engine load sounds directly from files or to create a File Loader which returns a sound file pointer which is then sent the Sound Module. The options would be as follows: Option #1: Snd_Module->loadWav("bleep.wav"); Option #2: SNDFILE *sndf = loadWav("bleep.wav"); Snd_Module->loadSnd(sndf); While the first option seems more straightforward, I have this feeling that the loading of a file should be independent from the sound module. (Or perhaps I should just allow the module to load everything and anything?) Comments are appreciated...

Share on other sites
As long as the file loading/resource management code is well isolated into it's own little chunk, either way should be okay.

Something like this?

                                      file_manager.read("bleep.wav");                                              |#include|sound.LoadSND(bleep_pointer);         resource_manager.load<wav>("bleep.wav");      |#include|                              |#include|           -----------------------------------------                {global} LoadSound(sound,"bleep.wav");

That way the sound module, the resource_manager, and the file_manager can focus on their own specialties. It makes them far far easier to reuse and/or change. The bottom file would be functions to tie the two together [and add logging or game specifics]. It keeps the sound module and the file loading independant while allowing them to work together.

Share on other sites
Most impressive, Telastyn. You both answered my question and gave me some very nice ideas on which to ponder.

The way in which the LoadSound is designed hints at further usage which could be implemented for other modules which require the loading of files. Have you designed an engine before or did you see this style of component use somewhere?

Share on other sites
I've written bits and pieces of an engine before, though 'design' would be generous.

I forget who made the comment, but I remember a little while ago someone responded to a question of mine [something like "why doesn't this function also delete the data?"] with "because if you have one function to delete data, and one function to do [whatever I was asking about] it's easy to put them together. If you have 1 function that does both, it's impossible to take it apart."

Which is rather straightforward. The entire unix design focus "many small apps working together" works off that basis. Unfortunately, it's hard as hell to do well in C++ without learning the genericity that templating and inheritance provides. By then people generally have plenty of bad habits.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• Forum Statistics

• Total Topics
634047
• Total Posts
3015231
×