I think this is not the right answer, but it is too long for comment.
Roughly speaking, you are right - either you have your shaders available at compile time, and with hard coding, or loaded at runtime. I am going to talk about different ways to achieve this. Please note that all of the above can be applied to any other data resource that your program must execute.
Hard coding can be done in a slightly more elegant way: save resources in separate files, but configure your build system so that it automatically generates source files with a hard-coded resource (as a static or dynamic array std::uint8_t or char , for example), and compiles these generated files into your program. Here, you probably need a utility that generates C ++ source files from binary data. I do not know good, recognized programs like this; when I needed it, I wrote my own, as it is quite simple.
You can use many parameters to make loading during boot more portable, but it seems the most important thing is to configure the location of resources in the file system; at runtime or compile time, which is up to you. This may be a compilation flag (i.e., the RUNTIME_RESOURCE_PATH macro that is configured by the build system). This may be a command line option with some reasonable default value.
I have no answer on which path is right . You need to choose a use case.
Hard-coded data simplifies deployment (fewer files, fewer explicit io, fewer errors), and resources in separate files allow you to update them without touching the program itself, including user changes.
source share