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, WrapperShaderBlockImpl

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 binding, int initialSize, BiConsumer<T,ByteBuffer> serializer)
    Creates a new shader block with a dynamically-changing size.
    static <T> DynamicShaderBlock<T>
    dynamic(int binding, 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 binding, int size, BiConsumer<T,ByteBuffer> serializer)
    Creates a new shader block with a fixed size.
    wrapper(int binding, int buffer)
    Creates a new shader block that points to an existing GL buffer.

    Methods inherited from interface org.lwjgl.system.NativeResource

    close, free
  • Method Details

    • withSize

      static <T> ShaderBlock<T> withSize(int binding, 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:
      binding - The buffer attachment point
      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(int binding, 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:
      binding - The buffer attachment point
      serializer - The serializer to fill the buffer
      Returns:
      A new shader block
    • dynamic

      static <T> DynamicShaderBlock<T> dynamic(int binding, 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:
      binding - The buffer attachment point
      initialSize - The initial size of the buffer
      serializer - The serializer to fill the buffer
      Returns:
      A new shader block
    • wrapper

      static DynamicShaderBlock<?> wrapper(int binding, int buffer)
      Creates a new shader block that points to an existing GL buffer.
      Parameters:
      binding - The buffer attachment point
      buffer - The buffer to bind as a shader block
      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