bitbrain / braingdx

:video_game: Game jam framework based on libgdx.
Apache License 2.0
84 stars 1 forks source link

Simplify ShaderManager API #158

Closed bitbrain closed 6 years ago

bitbrain commented 6 years ago

It is currently too complicated to configure shaders. Exposing the internal shader via getInternalEffect() is dangerous, since people might not use the decorator effect. Instead, remove the getInternalEffect() method and do this:

public interface Mutator<T> {
   void mutate(T target);
}

And then:

AutoReloadPostprocessorEffect<Blur> effect = shaderManager.createBlur(
   new Mutator<Blur>() {
      @Override
      public void mutate(Blur blur) {
         // mutate blur here
      }
   }
);

Additionally, all effects should have a new method called mutate(Mutator<T> t) which allows setting/changing the internal shader.

This gives us several advantages: