Skip to content

Texture

abstract class Texture
Implements: ITexture
Known subtypes: GlTexture, VulkanTexture
Package: dev.joid.lib.bridge.render.texture · Module: core · Source: Texture.java

The base class of a texture owned by JOID, which checks every call and leaves the storage, the upload and the mipmaps to its subclass.

ReturnsSignatureSummary
Texture()Creates a texture, for a subclass.

ReturnsSignatureSummary
intgetWidth()Returns the width, in pixels.
intgetHeight()Returns the height, in pixels.
ReturnsSignatureSummary
booleanisAllocated()If true, the texture has storage and is not deleted.
intgetLevels()Returns the number of allocated levels.
booleanisDeleted()If true, the texture is deleted.
booleanisMipmapped()If true, the texture keeps mipmap levels.
ReturnsSignatureSummary
thismipmap(boolean mipmap) fluentTurns the mipmap levels on or off; turning them on for an allocated texture builds them at once.
thisallocate(int width, int height) fluentAllocates the storage at that size, with every level when mipmapped; does nothing when the size and the levels are already those.
thisupload(int[] pixels) fluentUploads one ARGB pixel per texel and builds the mipmaps.
voiddelete()Releases the storage; does nothing the second time.
ReturnsSignatureSummary
intgetMaxLevels(int width, int height) hook protectedJOID calls it before each allocation and upload.
voidallocateStorage(MipmapChain chain) hook abstract protectedJOID calls it from allocate.
voiduploadPixels(int[] pixels, MipmapChain chain) hook abstract protectedJOID calls it from upload.
voidgenerateMipmapLevels(MipmapChain chain, int allocatedLevels) hook abstract protectedJOID calls it when mipmaps are turned on for an allocated texture, with the number of levels already allocated.
voiddeleteStorage() hook abstract protectedJOID calls it once, from delete().

Texture()

Creates a texture, for a subclass.

int getWidth()

Returns the width, in pixels.

int getHeight()

Returns the height, in pixels.

boolean isAllocated()

If true, the texture has storage and is not deleted.

int getLevels()

Returns the number of allocated levels.

boolean isDeleted()

If true, the texture is deleted.

boolean isMipmapped()

If true, the texture keeps mipmap levels.

this mipmap(boolean mipmap) fluent

Turns the mipmap levels on or off; turning them on for an allocated texture builds them at once.

this allocate(int width, int height) fluent

Throws:

  • IllegalStateException: The texture is deleted, create a new one with IRenderBridge.createTexture()

Allocates the storage at that size, with every level when mipmapped; does nothing when the size and the levels are already those. Throws an IllegalStateException once the texture is deleted.

this upload(int[] pixels) fluent

Throws:

  • IllegalStateException: The texture is deleted, create a new one with IRenderBridge.createTexture()
  • IllegalStateException: The texture is not allocated, call allocate(width, height) before upload(pixels)
  • IllegalArgumentException: The texture of …x… needs … pixels and got …, pass one pixel per texel

Uploads one ARGB pixel per texel and builds the mipmaps. Throws an IllegalStateException before allocate or once deleted, and an IllegalArgumentException with fewer pixels than texels.

void delete()

Releases the storage; does nothing the second time.

int getMaxLevels(int width, int height) hook protected

JOID calls it before each allocation and upload. Return the most levels your API gives a texture of that size; no limit by default.

void allocateStorage(MipmapChain chain) hook abstract protected

JOID calls it from allocate. Allocate every level of the chain; throw an IllegalArgumentException that starts with A texture of <width>x<height> exceeds the maximum size when the size is too large.

void uploadPixels(int[] pixels, MipmapChain chain) hook abstract protected

JOID calls it from upload. Write the pixels into the first level, then build the other levels of the chain.

void generateMipmapLevels(MipmapChain chain, int allocatedLevels) hook abstract protected

JOID calls it when mipmaps are turned on for an allocated texture, with the number of levels already allocated. Allocate the missing levels and build them from the first one.

void deleteStorage() hook abstract protected

JOID calls it once, from delete(). Release the storage.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page