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, LayoutShaderBlockImpl, 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 or shader block.

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

VeilRenderSystem.bind(CharSequence, ShaderBlock) must be called for shaders to access block data.

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

  • Method Details

    • withSize

      static <T> ShaderBlock<T> withSize(ShaderBlock.BufferBinding binding, long 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(ShaderBlock.BufferBinding 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(ShaderBlock.BufferBinding binding, long 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(ShaderBlock.BufferBinding 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