Package com.igrium.videolib.render
Class BufferBackedTexture
java.lang.Object
net.minecraft.client.texture.AbstractTexture
com.igrium.videolib.render.BufferBackedTexture
- All Implemented Interfaces:
AutoCloseable
public class BufferBackedTexture
extends net.minecraft.client.texture.AbstractTexture
A texture that is backed by a mutable byte buffer.
-
Field Summary
Fields inherited from class net.minecraft.client.texture.AbstractTexture
bilinear, DEFAULT_ID, glId, mipmap
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance without a backing buffer.BufferBackedTexture
(ByteBuffer buffer, int width, int height, int format) Create a buffer backed texture -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferBackedTexture
create
(int width, int height, int format) Allocate a buffer and create a buffer-backed texture that will free the buffer when it's closed.Get the buffer that this texture uses.int
Get the pixel format of the image.int
Get the height of the image.int
getWidth()
Get the width of the image.void
load
(net.minecraft.resource.ResourceManager manager) void
setBuffer
(ByteBuffer buffer, int width, int height, int format) Set the buffer that this texture uses.void
upload()
Upload the current contents of this buffer to the GPUMethods inherited from class net.minecraft.client.texture.AbstractTexture
bindTexture, clearGlId, close, getGlId, registerTexture, setFilter
-
Constructor Details
-
BufferBackedTexture
Create a buffer backed texture- Parameters:
buffer
- Buffer to use. MAY NOT BE A HEAP BUFFERwidth
- Width of the image.height
- Height of the image.format
- OpenGL format of the pixel data.
-
BufferBackedTexture
public BufferBackedTexture()Create an instance without a backing buffer. Most methods will not work until a buffer is set.
-
-
Method Details
-
create
Allocate a buffer and create a buffer-backed texture that will free the buffer when it's closed.- Parameters:
width
- Width of the image.height
- Height of the image.format
- OpenGL format of the pixel data.- Returns:
- The texture.
-
getBuffer
Get the buffer that this texture uses.- Returns:
- The buffer.
-
setBuffer
Set the buffer that this texture uses.- Parameters:
buffer
- Buffer to use. MAY NOT BE A HEAP BUFFERwidth
- Width of the image.height
- Height of the image.format
- OpenGL format of the pixel data.
-
getWidth
public int getWidth()Get the width of the image.- Returns:
- Texture width.
-
getHeight
public int getHeight()Get the height of the image.- Returns:
- Texture height.
-
getFormat
public int getFormat()Get the pixel format of the image.- Returns:
- OpenGL pixel format.
-
load
- Specified by:
load
in classnet.minecraft.client.texture.AbstractTexture
- Throws:
IOException
-
upload
public void upload()Upload the current contents of this buffer to the GPU
-