SFML community forums

General => General discussions => Topic started by: nietaki on March 13, 2012, 11:38:23 pm

Title: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
Post by: nietaki on March 13, 2012, 11:38:23 pm
Just a quick question: is the fact, that Music's loading functions begin with "open" and all the other classes (Image, Font, SoundBuffer) have their corresponding functions beginning with "load" deliberate? Why the inconsistency? Is there a reason behind it I failed to grasp?

By the way: if all the Image, Font, Music... classes inherited the same abstract interface class like "Loadable" it could sometimes save people from writing the repetitive cod for each of them individually - but it might be another thing Laurent thought through and decided against :)
Title: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
Post by: Mjonir on March 13, 2012, 11:51:48 pm
I'm pretty sure it's due to the fact that musics are opened and loaded chunk by chunk, not fully loaded when the function is used like for other resources :)
Title: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
Post by: nietaki on March 13, 2012, 11:59:12 pm
But I still can free the memory (data) after I call Music::openFromMemory(const void * data, std::size_t sizeInBytes ), right?
Title: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
Post by: Mjonir on March 14, 2012, 12:18:29 am
Quote from: "nietaki"
But I still can free the memory (data) after I call Music::openFromMemory(const void * data, std::size_t sizeInBytes ), right?


Hmm, sorry I don't know about that, I never load from memory.

Either wait for Laurent (he's so fast that he'll probably answer before you read this line so you won't wait for long :P), or try it out yourself by loading from memory and then overwriting the data?
Title: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
Post by: nietaki on March 14, 2012, 12:38:39 am
Quote from: "Mjonir"
Either wait for Laurent (he's so fast that he'll probably answer before you read this line so you won't wait for long :P), or try it out yourself by loading from memory and then overwriting the data?


If he doesn't respond by tommorow I'll try it out myself, I've just finished a big chunk of code and gave myself the rest of the day off ;)

Damn, the project I'm writing with SFML is the first one that ever gave me so much insight and fulfillment and we haven't even reached the fun part yet ;)
Title: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
Post by: Laurent on March 14, 2012, 08:07:42 am
Quote
I'm pretty sure it's due to the fact that musics are opened and loaded chunk by chunk, not fully loaded when the function is used like for other resources

Correct.

Quote
But I still can free the memory (data) after I call Music::openFromMemory(const void * data, std::size_t sizeInBytes ), right?

No. Isn't it written in the doc?
Title: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
Post by: nietaki on March 14, 2012, 06:20:08 pm
Quote from: "Laurent"
Quote
But I still can free the memory (data) after I call Music::openFromMemory(const void * data, std::size_t sizeInBytes ), right?

No. Isn't it written in the doc?


It isn't, at least not explicitly - I read it once again and I still wouldn't be sure if not for your answer.
Title: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
Post by: Mjonir on March 14, 2012, 06:25:02 pm
Quote from: "nietaki"
It isn't, at least not explicitly - I read it once again and I still wouldn't be sure if not for your answer.


I agree, I had checked the doc before answering and wasn't 100% sure about the behavior of music opening.

I also think the special status of sf::Music::openFrom* deserves a small mention in the doc of these methods.
Title: Music:::openFromSth() vs EverythingElse::loadFromSth() (2.0)
Post by: Laurent on March 14, 2012, 07:05:52 pm
Sorry, shame on me :(