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.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| Texture() | Creates a texture, for a subclass. |
Methods
Section titled “Methods”Position and size
Section titled “Position and size”| Returns | Signature | Summary |
|---|---|---|
int | getWidth() | Returns the width, in pixels. |
int | getHeight() | Returns the height, in pixels. |
Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
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. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
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 | Allocates the storage at that size, with every level when mipmapped; does nothing when the size and the levels are already those. |
this | upload(int[] pixels) fluent | Uploads one ARGB pixel per texel and builds the mipmaps. |
void | delete() | Releases the storage; does nothing the second time. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
int | getMaxLevels(int width, int height) hook protected | JOID calls it before each allocation and upload. |
void | allocateStorage(MipmapChain chain) hook abstract protected | JOID calls it from allocate. |
void | uploadPixels(int[] pixels, MipmapChain chain) hook abstract protected | JOID calls it from upload. |
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. |
void | deleteStorage() hook abstract protected | JOID calls it once, from delete(). |
Creation details
Section titled “Creation details”Texture
Section titled “Texture”Texture()
Creates a texture, for a subclass.
Method details
Section titled “Method details”getWidth
Section titled “getWidth”int getWidth()
Returns the width, in pixels.
getHeight
Section titled “getHeight”int getHeight()
Returns the height, in pixels.
isAllocated
Section titled “isAllocated”boolean isAllocated()
If true, the texture has storage and is not deleted.
getLevels
Section titled “getLevels”int getLevels()
Returns the number of allocated levels.
isDeleted
Section titled “isDeleted”boolean isDeleted()
If true, the texture is deleted.
isMipmapped
Section titled “isMipmapped”boolean isMipmapped()
If true, the texture keeps mipmap levels.
mipmap
Section titled “mipmap”this mipmap(boolean mipmap) fluent
Turns the mipmap levels on or off; turning them on for an allocated texture builds them at once.
allocate
Section titled “allocate”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.
upload
Section titled “upload”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.
delete
Section titled “delete”void delete()
Releases the storage; does nothing the second time.
getMaxLevels
Section titled “getMaxLevels”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.
allocateStorage
Section titled “allocateStorage”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.
uploadPixels
Section titled “uploadPixels”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.
generateMipmapLevels
Section titled “generateMipmapLevels”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.
deleteStorage
Section titled “deleteStorage”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
