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 TypeMethodDescriptionstatic <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.getValue()
void
Sets the value of this block.default void
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.static DynamicShaderBlock
<?> 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
Creates a new shader block with a fixed size.- Type Parameters:
T
- The type of data to write- Parameters:
binding
- The buffer attachment pointsize
- The size of the buffer in bytesserializer
- The serializer to fill the buffer- Returns:
- A new shader block
-
dynamic
Creates a new shader block with a dynamically-changing size. The initial size is set to256
.- Type Parameters:
T
- The type of data to write- Parameters:
binding
- The buffer attachment pointserializer
- 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 pointinitialSize
- The initial size of the bufferserializer
- The serializer to fill the buffer- Returns:
- A new shader block
-
wrapper
Creates a new shader block that points to an existing GL buffer.- Parameters:
binding
- The buffer attachment pointbuffer
- The buffer to bind as a shader block- Returns:
- A new shader block
-
update
Sets the value of this block. Data is only updated if the result of equals isfalse
.- Parameters:
value
- The new value
-
set
Sets the value of this block. Sets the value regardless if it has changed or not.- Parameters:
value
- The new value
-
getValue
- Returns:
- The value stored in this block
-