Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How can I pack my shader.glsl .wav files and sfml dll into exe?  (Read 300 times)

0 Members and 1 Guest are viewing this topic.

rbfahim

  • Newbie
  • *
  • Posts: 2
    • View Profile
How can I pack my shader.glsl .wav files and sfml dll into exe?
« 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3339
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How can I pack my shader.glsl .wav files and sfml dll into exe?
« Reply #1 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

rbfahim

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How can I pack my shader.glsl .wav files and sfml dll into exe?
« Reply #2 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)

Hapax

  • Hero Member
  • *****
  • Posts: 3339
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How can I pack my shader.glsl .wav files and sfml dll into exe?
« Reply #3 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
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

hdsiria

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: How can I pack my shader.glsl .wav files and sfml dll into exe?
« Reply #4 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