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

@:value({ channels : 1 })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

buffer:Float32Array

@:value(new Vector2())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.

private@:value(0)_length:Int = 0

private@:value(-1)_glFormat:Int = -1

private@:value(-1)_glType:Int = -1

privatebytes:Bytes

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.

Note: The data won't update if there's no gpu texture attached, but will be retained on the buffer for the next update call.

inlinesetFloat(pos:Int, v:Float):Void

inlinegetFloat(pos:Int):Float

inlinesetVector2(pos:Int, v:Vector2):Void

inlinesetVector3(pos:Int, v:Vector3D):Void

inlinesetVector4(pos:Int, v:Vector3D):Void

inlinesetMatrix4(pos:Int, v:Matrix3D):Void

inlinesetArray(pos:Int, v:Array<Float>):Void

inlinegetLength():Int

Returns the width of the buffer texture.

To get the actual length, check buffer

Inherited Variables

Defined by FoxTexture

@:value(null)context:Context3D = null

glTexture:TextureBase

assetsKey:String

read onlyloaded:Bool

Wheter or not this texture is loaded

This property also indicates wheter this texture has a valid glTexture, usually assigned when images load

width:Int

height:Int

@:value(true)__paramsNeedUpdate:Bool = true

private@:value(null)__format:String = null

private@:value(null)__type:String = null

Inherited Methods

Defined by FoxTexture

privateget_loaded():Bool

privateget_width():Int

privateget_height():Int

asBitmapData():BitmapData

resize(width:Int, height:Int):FoxTexture

Resizes this texture. Intended for framebuffer textures,

Note: This will not work with textures that have been wrapped/loaded from a file.

take(bitmap:BitmapData):Void

Instance version of FoxTexture.wrap()

Takes a BitmapData and sets it as the GPU texture

Note: This will not update any extra information of this texture, such as format or type.

takeGL(texture:TextureBase):Void

Instance version of FoxTexture.wrapGL()

Takes a Texture and sets it as the GPU texture

Note: This will not update any extra information of this texture, such as format or type.