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:


A helper library for loading, reloading, and unloading bgfx shaders.

Depends on BindBC-bgfx v1.0.0 or higher.


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.


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.ShaderHandles, and the old ones will only be destroyed if no other Shelper-managed bgfx.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.ProgramHandles. 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:
bool unload(bgfx.ProgramHandle program) nothrow @nogc;

Destroys program, and cleans up its underlying bgfx.ShaderHandles if there are no other Shelper-managed bgfx.ProgramHandles using them.

void unloadAllShaderPrograms() nothrow @nogc;

Destroys all bgfx.ProgramHandles managed by Shelper, and cleans up all of their underlying bgfx.ShaderHandles.

  • Aya Partridge
1.0.0 2024-Mar-13
~main 2024-Mar-13
Show all 2 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 0 downloads total

Short URL: