Don't bother with OS-specific code, all you want to do is to embed a bunch of bytes into your code and interpret them as a resource file.
1. Convert your resource file to a C++ array (easy to do yourself, or use a dedicated program / website like this http://tools.garry.tv/bin2c/)
2. Paste the generated C++ array into your code
3. Load it with the loadFromMemory functionchar myResource[] =
{
/* the generated array */
};
sf::Texture texture;
texture.loadFromMemory(myResource, sizeof(myResource));
What kind of audio file? Have you tried other tools?
Its seems to work only on a few audio filesMaybe you could describe the error more precisely. What exactly fails, and how?
but i can even use it because i need openAL for sound and i can't static link itYou can't link it statically, unless you comply with the LGPL license (ie. release your own code under a compatible license). What's the problem with dynamic linking?
QuoteIts seems to work only on a few audio filesMaybe you could describe the error more precisely. What exactly fails, and how?Quotebut i can even use it because i need openAL for sound and i can't static link itYou can't link it statically, unless you comply with the LGPL license (ie. release your own code under a compatible license). What's the problem with dynamic linking?
i don't know about that LGPL license can you explain a bit more?Some licenses impose restrictions on derivative work. A common restriction of the LGPL is to force your project to be LGPL too, if it uses the LGPL-licensed dependency statically. This restriction doesn't apply if you link it dynamically. That's why SFML links OpenAL dynamically, sothat you don't have to bother with license issues.
Some audio files just return 0 (mp3) and some .wav. i think it could be because the size is too big.But what returns 0? Where? Your code? The online converter? Please take the time to describe the problem with details.
Quotei don't know about that LGPL license can you explain a bit more?Some licenses impose restrictions on derivative work. A common restriction of the LGPL is to force your project to be LGPL too, if it uses the LGPL-licensed dependency statically. This restriction doesn't apply if you link it dynamically. That's why SFML links OpenAL dynamically, sothat you don't have to bother with license issues.QuoteSome audio files just return 0 (mp3) and some .wav. i think it could be because the size is too big.But what returns 0? Where? Your code? The online converter? Please take the time to describe the problem with details.
Sorry. i meant the online converter.Probably a size limit on upload. Try an offline tool, or write your own program (10 lines of code max).
QuoteSorry. i meant the online converter.Probably a size limit on upload. Try an offline tool, or write your own program (10 lines of code max).
I created a simple one of converters for myself.
I see you're using Visual Studio so I can presume Windows.
Therefore, feel free to use this:
http://www.mediafire.com/file/5ttatyq313bzenb/HppDataArrayFromFileBytes.exe
You can use it via command line or just drag the file you want to convert onto its icon (or shortcut) and it will do it automatically.
The final .hpp file also has extra stuff like an include guard and formatted values. Using the command line (or a switch), you can output the values in hexadecimal instead.
Note that this was built on Visual Studio 2013 so you may require the redistributables for that (https://www.microsoft.com/en-GB/download/details.aspx?id=40784) if you don't have them already.
I hear your pain with the hover. It killed me a couple of times ;D
Best advice I can give is since it's a resource, deal with it once and then hide it and never deal with it again! ;) (you could hide the loading of it in another file, for example).
Is there any sneaky way too avoid the license and just force link it.Release your sources under the LGPL too. Or live with its restrictions. You know, licenses exist to protect people's work, and ensure that they will be used (and not misused) as their author whishes. So it's really wrong to try to "avoid the license" or "force" things as you like.
i may sound a bit stupid here.
QuoteIs there any sneaky way too avoid the license and just force link it.Release your sources under the LGPL too. Or live with its restrictions. You know, licenses exist to protect people's work, and ensure that they will be used (and not misused) as their author whishes. So it's really wrong to try to "avoid the license" or "force" things as you like.
i may sound a bit stupid here.
Steam Audio (https://github.com/ValveSoftware/steam-audio)
1.6 Trademarks. Licensee agrees to place the following notices in the credits for any Licensee Product (replacing xxxx with the current year):
“[Product name] uses the Steam® Audio SDK. Steam® is a trademark or registered trademark of Valve Corporation in the United States of America and elsewhere”
“Steam® Audio, Copyright 2016 – xxxx, Valve Corp. All rights reserved.”