Int32Texture (class)
Int32Texture
is a an extension of the Texture class. It is a texture with RGBA colors and signed 32-bit interger format for each color channel. The texture is color renderable but NOT filterable.
The internal format of the texture is 'rgba32i'
, the format is 'rgba_integer'
and the type is int
.
Constructor
The constructor can be called as
var textureInstance = new Abubu.Int32Texture( width, height, options ) ;
The arguments are:
-
width
integer number of pixels in the horizontal direction
-
height
integer number of pixels in the vertical direction
-
options
object of optional named arguments. If none is provided, the default values will be assumed. The options object's available properties are:
-
wrapS
String indicating wrapping in the horizontal direction. Possible values are
'clamp_to_edge' (default) 'repeat' 'mirrored_repeat'
-
wrapT
String indicating wrapping in the vertical direction. Possible values are
'clamp_to_edge' (default) 'repeat' 'mirrored_repeat'
-
data
One dimensional Int32Array of the appropriate size which can be used to initialize the texture from the JavaScript. The array type should match the total size of texture (number of pixels \( \times \) number of color channels (4)).
-
pairable
boolean value representing weather texture should be paired be with a JavaScript Int32Array by default. If this option is true thevalue
property can be used to read the texture into CPU as a one dimensional array.
Default value:false
-
Instance properties
The following properties have read and write permissions and hence can be modified.
-
width
\(^* \) -
height
\(^* \) -
data
-
wrapS
-
wrapT
-
pairable
-
value
\(^\ddagger \)Returns a one dimensional array of the pixel data of the entire texture.
\(^* \)Requires updating new data array as with texture size change the data cannot be automatically mapped.
\(^\dagger\)Dangerous to modify property! Only modify with caution.
\(^\ddagger \)Read-Only property.
For more information on these properties, see the explanations in the constructor section.
Example
Consider the code snippet below:
var my_texture = new Abubu.Int32Texture( 200, 300,
'rgba32f','rgba','float',
{
wrapS : 'mirrored_repeat',
pairable : true
}
) ;
my_texture.wrapT = 'mirrored_repeat' ;
console.log(my_texture.value) ;
It generates a 200 by 300 Int32Texture
. Wrapping in the S
is initially set by the construction options. However, wrapping in the T
direction is changed by setting the instance's wrapT
property to 'mirrored_repeat'
.
Since the texture is pairable, the values of the pixels of the texture can be accessed by the value
property and can be printed to the browser's console.