Class ShaderHotReload

java.lang.Object
lol.trq.helios.shader.ShaderHotReload

public final class ShaderHotReload extends Object
Development hot reload: watches a shader source directory and rebuilds every program of a ShaderLoader when a file changes. A program that fails to rebuild keeps running its last good version.

Call poll() once per frame on the render thread. It scans file modification times at most every intervalMillis, so it is cheap, and never spawns threads.

  • Constructor Details

    • ShaderHotReload

      public ShaderHotReload(ShaderLoader loader, Path dir, long intervalMillis)
      Starts watching.
      Parameters:
      loader - the loader whose programs are rebuilt; it should resolve sources from dir first
      dir - the shader source directory
      intervalMillis - the minimum time between scans
  • Method Details

    • poll

      public ShaderHotReload.Result poll()
      Reloads if a source file changed since the last poll.
      Returns:
      whether a reload ran, and the programs that failed to rebuild