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

    Constructors
    Constructor
    Description
    Create an instance without a backing buffer.
    BufferBackedTexture(ByteBuffer buffer, int width, int height, int format)
    Create a buffer backed texture
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    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 the current contents of this buffer to the GPU

    Methods inherited from class net.minecraft.client.texture.AbstractTexture

    bindTexture, clearGlId, close, getGlId, registerTexture, setFilter

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BufferBackedTexture

      public BufferBackedTexture(ByteBuffer buffer, int width, int height, int format)
      Create a buffer backed texture
      Parameters:
      buffer - Buffer to use. MAY NOT BE A HEAP BUFFER
      width - 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

      public static 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.
      Parameters:
      width - Width of the image.
      height - Height of the image.
      format - OpenGL format of the pixel data.
      Returns:
      The texture.
    • getBuffer

      public ByteBuffer getBuffer()
      Get the buffer that this texture uses.
      Returns:
      The buffer.
    • setBuffer

      public void setBuffer(ByteBuffer buffer, int width, int height, int format)
      Set the buffer that this texture uses.
      Parameters:
      buffer - Buffer to use. MAY NOT BE A HEAP BUFFER
      width - 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

      public void load(net.minecraft.resource.ResourceManager manager) throws IOException
      Specified by:
      load in class net.minecraft.client.texture.AbstractTexture
      Throws:
      IOException
    • upload

      public void upload()
      Upload the current contents of this buffer to the GPU