Interface ShaderBlock<T>

Type Parameters:
T - The type of object to serialize
All Superinterfaces:
AutoCloseable, org.lwjgl.system.NativeResource
All Known Subinterfaces:
DynamicShaderBlock<T>
All Known Implementing Classes:
DynamicShaderBlockImpl, ShaderBlockImpl, SizedShaderBlockImpl

public interface ShaderBlock<T> extends org.lwjgl.system.NativeResource

Defines a block of memory on the GPU that can be referenced as a uniform block.

update(Object) changes the data in the block of memory.

VeilRenderSystem.bind(CharSequence, ShaderBlock) updates the data if it has previously been changed with update(Object).

The end result is a lazy buffer that only updates contents when the Java data has been changed.

  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> DynamicShaderBlock<T>
    dynamic(int initialSize, BiConsumer<T,ByteBuffer> serializer)
    Creates a new shader block with a dynamically-changing size.
    static <T> DynamicShaderBlock<T>
    dynamic(BiConsumer<T,ByteBuffer> serializer)
    Creates a new shader block with a dynamically-changing size.
     
    void
    set(T value)
    Sets the value of this block.
    default void
    update(T value)
    Sets the value of this block.
    static <T> ShaderBlock<T>
    withSize(int size, BiConsumer<T,ByteBuffer> serializer)
    Creates a new shader block with a fixed size.

    Methods inherited from interface org.lwjgl.system.NativeResource

    close, free
  • Method Details

    • withSize

      static <T> ShaderBlock<T> withSize(int size, BiConsumer<T,ByteBuffer> serializer)
      Creates a new shader block with a fixed size.
      Type Parameters:
      T - The type of data to write
      Parameters:
      size - The size of the buffer in bytes
      serializer - The serializer to fill the buffer
      Returns:
      A new shader block
    • dynamic

      static <T> DynamicShaderBlock<T> dynamic(BiConsumer<T,ByteBuffer> serializer)
      Creates a new shader block with a dynamically-changing size. The initial size is set to 256.
      Type Parameters:
      T - The type of data to write
      Parameters:
      serializer - The serializer to fill the buffer
      Returns:
      A new shader block
    • dynamic

      static <T> DynamicShaderBlock<T> dynamic(int initialSize, BiConsumer<T,ByteBuffer> serializer)
      Creates a new shader block with a dynamically-changing size.
      Type Parameters:
      T - The type of data to write
      Parameters:
      initialSize - The initial size of the buffer
      serializer - The serializer to fill the buffer
      Returns:
      A new shader block
    • update

      default void update(@Nullable T value)
      Sets the value of this block. Data is only updated if the result of equals is false.
      Parameters:
      value - The new value
    • set

      void set(@Nullable T value)
      Sets the value of this block. Sets the value regardless if it has changed or not.
      Parameters:
      value - The new value
    • getValue

      @Nullable T getValue()
      Returns:
      The value stored in this block