Class Helios

java.lang.Object
lol.trq.helios.Helios
All Implemented Interfaces:
AutoCloseable

public final class Helios extends Object implements AutoCloseable
One Helios instance per GL context: the backend, the host's state cache, shaders, the framebuffer pool and the renderers. Create it and use it on the render thread, after the context exists.

On Minecraft, MinecraftHelios.create() wires the backend, the GlStateManager cache and the window size.

  • Field Details

    • GLSL_VERSION

      public static final String GLSL_VERSION
      The one GLSL version every shader uses: GLSL 4.10 core, for the OpenGL 4.1 core profile.
      See Also:
    • SHADER_ROOT

      public static final String SHADER_ROOT
      Class path root of the built-in shaders.
      See Also:
    • DEFAULT_FONT

      public static final String DEFAULT_FONT
      Class path location of the bundled font, Inter Regular (SIL Open Font License 1.1).
      See Also:
    • BATCH_CAPACITY

      public static final int BATCH_CAPACITY
      Shapes per draw call in the default batch.
      See Also:
  • Method Details

    • create

      public static Helios create(GlBackend gl, GlStateCache cache, SurfaceSize surface)
      Creates an instance with the built-in shaders.
      Parameters:
      gl - the backend
      cache - the host's state cache
      surface - the window framebuffer size
      Returns:
      the instance
    • create

      public static Helios create(GlBackend gl, GlStateCache cache, SurfaceSize surface, SourceResolver resolver)
      Creates an instance with a custom shader source, for example a source directory first for hot reload.
      Parameters:
      gl - the backend
      cache - the host's state cache
      surface - the window framebuffer size
      resolver - where shader sources come from; must provide the built-in ones
      Returns:
      the instance
    • createWithHotReload

      public static Helios createWithHotReload(GlBackend gl, GlStateCache cache, SurfaceSize surface, Path shaderDir)
      Creates an instance that loads shaders from a source directory first and reloads them when they change. Call tick() once per frame. For development only.
      Parameters:
      gl - the backend
      cache - the host's state cache
      surface - the window framebuffer size
      shaderDir - a copy of the shader sources, laid out like SHADER_ROOT
      Returns:
      the instance
    • tick

      public ShaderHotReload.Result tick()
      Per-frame housekeeping: rotates the streamed vertex buffers of the shapes and meshes and polls shader hot reload when it is on. Call it once per frame, after the frame's Helios drawing.
      Returns:
      what hot reload did, or a result with nothing reloaded
    • builtinShaders

      public static SourceResolver builtinShaders()
      Returns the resolver for the shaders inside the Helios jar.
      Returns:
      the resolver
    • guard

      public StateGuard guard()
      Opens a state guard bound to this instance's backend and cache.
      Returns:
      a new guard; close it when the draw ends
    • gl

      public GlBackend gl()
      Returns the backend.
      Returns:
      the backend
    • shaders

      public ShaderLoader shaders()
      Returns the shader loader.
      Returns:
      the loader
    • meshes

      public MeshRenderer meshes()
      Returns the 3D mesh renderer: coloured quads, anti-aliased lines and textured, lit quads.
      Returns:
      the renderer
    • framebuffers

      public FramebufferPool framebuffers()
      Returns the framebuffer pool.
      Returns:
      the pool
    • shapes

      public ShapeBatch shapes()
      Returns the shape batch.
      Returns:
      the batch
    • passes

      public Passes passes()
      Returns the full-screen passes: screen capture, blur, compositing, custom passes.
      Returns:
      the passes
    • effects

      public Effects effects()
      Returns the screen effects: blur behind a shape, bloom.
      Returns:
      the effects
    • scissor

      public ScissorStack scissor()
      Returns the scissor stack.
      Returns:
      the stack
    • stencil

      public StencilMask stencil()
      Returns the stencil clipping helper.
      Returns:
      the helper
    • text

      public TextRenderer text()
      Returns the text renderer.
      Returns:
      the renderer
    • defaultFont

      public MsdfFont defaultFont()
      Returns the bundled font, Inter Regular, loading it on first use.
      Returns:
      the font
    • postChain

      public PostChain postChain()
      Starts a new post-processing chain.
      Returns:
      an empty chain
    • version

      public static String version()
      Returns the library version from the jar manifest.
      Returns:
      the version, or "dev" when running from classes outside a jar
    • close

      public void close()
      Deletes every GL object this instance owns.
      Specified by:
      close in interface AutoCloseable