A FoxTexture that can be used to store and sample data from the CPU to the GPU.
It is intended to be used as a dynamic array, so the width of the texture changes, but the height is always 1.
It only supports 32-bit Float values for now.
Its usage in a FoxFramebuffer is currently unknown.
Limitations: 16384 elements maximum, however some devices could have an even lower limit.
Constructor
new(length:Int, channels:Int = 1)
Creates a new texture buffer to store data. To upload it to the GPU, call updateGPU() afterwards.
Parameters:
length | Specifies the number of elements (pixels) |
|---|---|
channels | The number of channels to use in the texture, they correspond to Red, Green, Blue and Alpha |
Variables
pixelSize:Vector2 = new Vector2()
The pixel size for this texture, useful when sampling the buffer in the shader when texelFetch is not supported,
just pass it as an uniform and multiply the indices by this value.
As of now, pixelSize.y is always 0.
Methods
create(length:Int, channels:Int):Void
Re-allocates the buffer both on the CPU, useful when changing the length of the array is needed.
To upload it to the GPU, call updateGPU() afterwards.
Note: The contents of the previous buffer are lost in favor of the new one, you might want to write your data back.
Parameters:
length | The width of the texture. |
|---|---|
channels | The number of channels to use in the texture, they correspond to Red, Green, Blue and Alpha. |
inlineupdateGPU():Void
Uploads the texture buffer to the GPU.
Call this when you're done writing data to the buffer.
inlinegetLength():Int
Returns the width of the buffer texture.
To get the actual length, check buffer