SFML community forums

Help => General => Topic started by: rbfahim on November 25, 2023, 04:40:48 pm

Title: How can I pack my shader.glsl .wav files and sfml dll into exe?
Post by: rbfahim on November 25, 2023, 04:40:48 pm
So, I am compiling this project with two shader files and a sound file in .wav format.

I wanted to include all of them as well as the .dll files into the exe?

I am not sure how to do that? If I include static flag that only works for the dll not for the resource files, I assume.
Title: Re: How can I pack my shader.glsl .wav files and sfml dll into exe?
Post by: Hapax on November 25, 2023, 06:46:22 pm
A few ways you can do it but possibly the simplest is to convert each file into an array (all of the values separated by commas, basically), save that to a header file and include that when building.

Shaders are easier because they're already text. Just add it as a string.

You can then "load from memory" and pass the array/string as the memory.

Note that one of the DLLs cannot be "packed" due to licensing. That is the openal32.DLL, which you need for audio, so that will always be separate.
Title: Re: How can I pack my shader.glsl .wav files and sfml dll into exe?
Post by: rbfahim on November 26, 2023, 06:08:10 pm
Thank you I did that. But now I am confused about how to pack my resources and sounds file with it as well.

This is my makefile

SFML = -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
CC = g++
CFLAGS = -c
DEBUG = -g
objects = boidHelpingFunctions.o boids.o simulation.o main.o
all: FlockingBoids link

FlockingBoids: $(objects)

boidHelpingFunctions.o : FlockingBoids/src/boidHelpingFunctions.cpp FlockingBoids/src/boidHelpingFunctions.h
        $(CC) -IsfmlFiles/include $(CFLAGS) FlockingBoids/src/boidHelpingFunctions.cpp

boids.o : FlockingBoids/src/boids.cpp FlockingBoids/src/boids.h
        $(CC) -IsfmlFiles/include $(CFLAGS) FlockingBoids/src/boids.cpp

simulation.o : FlockingBoids/src/simulation.cpp FlockingBoids/src/simulation.h
        $(CC) -IsfmlFiles/include $(CFLAGS) FlockingBoids/src/simulation.cpp

main.o : FlockingBoids/src/main.cpp
        $(CC) -IsfmlFiles/include $(CFLAGS) FlockingBoids/src/main.cpp

link:
        $(CC) $(objects) -o run -LsfmlFiles/lib $(SFML)

clean:
        rm edit $(objects)
Title: Re: How can I pack my shader.glsl .wav files and sfml dll into exe?
Post by: Hapax on November 27, 2023, 04:11:35 pm
I think it's possible you may have missed my point.

You can convert the files you wish to pack into arrays inside the code and access them directly from memory.

Maybe this will help:
https://en.sfml-dev.org/forums/index.php?topic=17256.msg124157#msg124157
Title: Re: How can I pack my shader.glsl .wav files and sfml dll into exe?
Post by: hdsiria on November 28, 2023, 08:04:59 pm
I know the way in vc++ windows.Import the file in the resource view and then use the LoadResource LockResource function to free up resources,But it seems you can't do that with the g++ compiler