shelper 1.0.0
A helper library for managing bgfx shaders.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Shelper
A helper library for loading, reloading, and unloading bgfx shaders.
Depends on BindBC-bgfx v1.0.0 or higher.
API
The library's shaderPath
variable indicates the location of your shader binaries. By default, it is set to shaders/
.
Shelper expects shaders to have the following file extensions:
*.vert.bin
for vertex shaders.*.frag.bin
for fragment shaders.*.comp.bin
for compute shaders.
Functions
bgfx.ProgramHandle load(string vert, string frag);
Loads two shader files and creates a shader program. vert
and frag
should be only be a file name, without a file extension.
Example:
shaderPath = "shaders/";
myProgram = shelper.load(
"myShader", //will open "shaders/myShader.vert.bin"
"myShader", //will open "shaders/myShader.frag.bin"
);
bgfx.ProgramHandle load(string comp);
Loads a shader file and creates a compute shader program. comp
should be only be a file name, without a file extension.
void reload(ref bgfx.ProgramHandle program);
Reloads program
's shader files afresh from the disk and sets program
to a newly created bgfx.ProgramHandle
.
[!NOTE]\ This function always creates new underlying
bgfx.ShaderHandle
s, and the old ones will only be destroyed if no other Shelper-managedbgfx.ProgramHandle
is using them. Because of this, it's best to use the version of the function below when reloading more than one shader.
void reload(R)(R programs)
if(hasAssignableElements!R && is(ElementType!R == bgfx.ProgramHandle*));
Reloads programs
' shader files afresh from the disk and sets the handles in programs
to newly created bgfx.ProgramHandle
s.
Example:
auto myShader1 = shelper.load("myShaderA", "myShaderA");
auto myShader2 = shelper.load("myShaderA", "myShaderB");
auto myShader3 = shelper.load("myShaderC", "myShaderB");
auto myShader4 = shelper.load("myShaderC", "myShaderA");
//sometime later:
shelper.reload([
&myShader1,
&myShader2,
&myShader3,
&myShader4,
]);
bool unload(bgfx.ProgramHandle program) nothrow @nogc;
Destroys program
, and cleans up its underlying bgfx.ShaderHandle
s if there are no other Shelper-managed bgfx.ProgramHandle
s using them.
void unloadAllShaderPrograms() nothrow @nogc;
Destroys all bgfx.ProgramHandle
s managed by Shelper, and cleans up all of their underlying bgfx.ShaderHandle
s.
- Registered by Aya Partridge
- 1.0.0 released 8 months ago
- ichordev/shelper
- BSL-1.0
- Authors:
- Dependencies:
- bindbc-bgfx
- Versions:
-
2.0.0 2024-Oct-23 1.0.0 2024-Mar-13 ~main 2024-Nov-05 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
2 downloads this month
-
3 downloads total
-
- Score:
- 0.3
- Short URL:
- shelper.dub.pm