SFML community forums

Help => General => Topic started by: Rimdeker on February 21, 2012, 10:25:41 am

Title: Is it possible to put media files into the .exe file?
Post by: Rimdeker on February 21, 2012, 10:25:41 am
[REDACTED]
Title: Is it possible to put media files into the .exe file?
Post by: texus on February 21, 2012, 10:42:17 am
I know that this is possible with Visual Studio, I don't know about Code::Blocks.
What you need is called resources, so if you google something like "codeblocks resources" then you might find out more.
Title: Is it possible to put media files into the .exe file?
Post by: Laurent on February 21, 2012, 10:53:33 am
It can be done in a standard way. All you have to do is to convert your media files to C++ files (using an external tool) that define the data as char arrays, include them into your app and use LoadFromMemory rather than LoadFromFile.
Title: Is it possible to put media files into the .exe file?
Post by: Laurent on February 21, 2012, 11:33:07 am
Quote
Can you recommend a converter?

I don't know them, sorry. But writing one is a straight-forward task.

Quote
Why LoadFromMemory?

Because the file contents are now in RAM (it is loaded when you run your exe), not on your hard drive anymore.
Title: Is it possible to put media files into the .exe file?
Post by: slotdev on February 21, 2012, 03:59:34 pm
You can also use a program like Molebox, which I use all the time.

You just pack your resources into the final exe. It's great :)

http://www.molebox.com/

Ed
Title: Is it possible to put media files into the .exe file?
Post by: Svenstaro on February 21, 2012, 04:29:31 pm
Use QT with qrc. If you need a colorful interface, use qtcreator. This is a cross-platform way.
Title: Is it possible to put media files into the .exe file?
Post by: Laurent on February 21, 2012, 04:31:23 pm
Using Qt (not QT, which is QuickTime) only for their resource system would really be crazy.
Title: Is it possible to put media files into the .exe file?
Post by: Svenstaro on February 21, 2012, 04:37:35 pm
Er why? It's not like there aren't other nice things in Qt worth using. Also, most popular distros already have Qt installed anyway. Windows users usually don't worry about a few extra dlls and neither do Mac folks.

There's lots of good stuff in Qt and the tools are great as well. Throw away Codeblocks and use Qtcreator.
Title: Is it possible to put media files into the .exe file?
Post by: Laurent on February 21, 2012, 04:47:42 pm
Quote
Er why? It's not like there aren't other nice things in Qt worth using.

That's why I said "only for their resource system".

- Qt is a big dependency -- Windows users do worry about it, since DLLs are usually very badly managed.
- It requires pre-build steps to create the resource files, which are difficult to integrate into your preferred IDE if you don't have a dedicated plugin. And switching from your preferred IDE to QtCreator just because you use Qt to embed resources into your executable, doesn't seem like a reasonable choice.
- You must learn the Qt's basics before using it. Even if it's just for resources, there are a few tricks to understand.
- Then you have to use their IO classes if you want to be able to load your resources, but you must then convert them to something else so that you can use SFML's loading functions.
- And... well it's a huge multi-purpose C++ framework, it's insane to use it when the required feature can be written with 10 lines of code.

Let's focus on the requested feature, and not into a "Qt / QtCreator is better than X / Y" discussion please ;)
Title: Re: Is it possible to put media files into the .exe file?
Post by: the_composer on March 06, 2013, 04:09:47 pm
I know that this is possible with Visual Studio, I don't know about Code::Blocks.
What you need is called resources, so if you google something like "codeblocks resources" then you might find out more.
How would you do it in Visual Studio? (I'm using VS 2012)
Title: Re: Is it possible to put media files into the .exe file?
Post by: eXpl0it3r on March 06, 2013, 04:17:47 pm
How would you do it in Visual Studio? (I'm using VS 2012)
Maybe this (http://lmgtfy.com/?q=resources+visual+studio+2012) helps. ;)
Title: Re: Is it possible to put media files into the .exe file?
Post by: FRex on March 06, 2013, 04:24:03 pm
404 Not Found ;D
You forgot a question mark before q.
Title: Re: Is it possible to put media files into the .exe file?
Post by: the_composer on March 06, 2013, 04:25:57 pm
I got the hint. :P

Thanks eXpl0it3r.