Class TextureAllocator
java.lang.Object
dev.pfaff.altargui.texture.TextureAllocator
- All Implemented Interfaces:
AutoCloseable
Arrays: | 1 | 2 | 3 |
Active: | D | U* | U |
States:
- D clean for drawing
- U accepting ploads
- 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
The minimum allocation size in pixels. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalloc
(LoadableTexture key) Gets a shader to the given texture.void
close()
void
dump()
int
void
reset()
-
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 UNITThe 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
-
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 interfaceAutoCloseable
-
dump
public void dump()
-