Class TextureAllocator

java.lang.Object
dev.pfaff.altargui.texture.TextureAllocator
All Implemented Interfaces:
AutoCloseable

public final class TextureAllocator extends Object implements AutoCloseable

Arrays: | 1 | 2 | 3 |
Active: | D | U* | U |

States:

  1. D clean for drawing
  2. U accepting ploads
  3. U* finishing upload

When a buffer with state U* is finished, it transitions to state D, the previous buffer transitions to state U, and the next buffer transitions to state U*. Thanks to this model, the states of all three buffers may be represented using a single 2-bit index.

  • Field Details

    • TBS_COUNT

      public static final int TBS_COUNT
      See Also:
    • MAX_TEXTURE_SIZE

      public static final int MAX_TEXTURE_SIZE
    • UNIT

      public static final int UNIT
      The minimum allocation size in pixels. Herein we often measure in "units" rather than pixels for efficiency.
  • Constructor Details

    • TextureAllocator

      public TextureAllocator(int size, int initialLayers)
      Parameters:
      size - the width and height of each layer.
  • Method Details

    • reset

      public void reset()
    • getTbsAcquire

      public int getTbsAcquire()
    • boundForDraw

      public InfallibleAutoClosable boundForDraw()
    • alloc

      Gets a shader to the given texture. If not loaded, the texture will be loaded and a slot allocated for it.

      This method must only be called from the main thread.

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • dump

      public void dump()