Interface ShaderAPI

All Known Implementing Classes:
DistortionShader, InvertShader, LensShader, LightShader, PostProcessShader

public interface ShaderAPI
An interface designed to allow shaders to be instanced and managed.

Implementations of ShaderAPI persist between combat, so make sure you consider local variables to be effectively static for the purposes of memory leaks.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Render order: OBJECT_SPACE, WORLD_SPACE, DISTORTED_SPACE, then SCREEN_SPACE
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    advance(float amount, List<com.fs.starfarer.api.input.InputEventAPI> events)
    This method will be called for multiple shaders in a particular order, dictated by getRenderOrder().
    void
    This method is called when the current instance is destroyed, such as when the settings are reloaded.
    com.fs.starfarer.api.combat.CombatEngineLayers
    This method determines the combat rendering layer in which the shader is run.
    This method determines the order in which the shader is inserted in the rendering queue.
    void
    This method is called at the beginning of each combat instance.
    boolean
    This method returns whether this shader is rendered within a combat layer or not.
    boolean
    This method returns whether this shader is enabled or not.
    void
    renderInScreenCoords(com.fs.starfarer.api.combat.ViewportAPI viewport)
    This method is called before advance() and before the UI is drawn.
    void
    renderInWorldCoords(com.fs.starfarer.api.combat.ViewportAPI viewport)
    This method is called before advance() and before the UI is drawn.
  • Method Details

    • renderInWorldCoords

      void renderInWorldCoords(com.fs.starfarer.api.combat.ViewportAPI viewport)
      This method is called before advance() and before the UI is drawn.

      Parameters:
      viewport - The world-based coordinates to draw with.
    • renderInScreenCoords

      void renderInScreenCoords(com.fs.starfarer.api.combat.ViewportAPI viewport)
      This method is called before advance() and before the UI is drawn. Warning: only called if isCombat() is false!

      Parameters:
      viewport - The screen-based coordinates to draw with.
    • advance

      void advance(float amount, List<com.fs.starfarer.api.input.InputEventAPI> events)
      This method will be called for multiple shaders in a particular order, dictated by getRenderOrder(). Make sure that data updates and bookkeeping are done within an advance() method.

      Parameters:
      amount - The amount of time since the last frame.
      events - A list of general input events.
    • initCombat

      void initCombat()
      This method is called at the beginning of each combat instance.
    • destroy

      void destroy()
      This method is called when the current instance is destroyed, such as when the settings are reloaded.

      Since:
      Alpha 1.6
    • isEnabled

      boolean isEnabled()
      This method returns whether this shader is enabled or not.

      Returns:
      Whether this shader is enabled or not.

      Since:
      Alpha 1.02
    • getCombatLayer

      com.fs.starfarer.api.combat.CombatEngineLayers getCombatLayer()
      This method determines the combat rendering layer in which the shader is run. This method is read every frame. Note that this is only used if isCombat() is true.

      Returns:
      The layer in which the shader will render.

      Since:
      1.4.0
    • isCombat

      boolean isCombat()
      This method returns whether this shader is rendered within a combat layer or not.

      Returns:
      Whether this shader is rendered within a combat layer.

      Since:
      1.4.0
    • getRenderOrder

      ShaderAPI.RenderOrder getRenderOrder()
      This method determines the order in which the shader is inserted in the rendering queue. This method is read every frame. Note that this is only used if isCombat() is false.

      Returns:
      The order by which the shader will render.