Abubu.js
The WebGL Computational Library
Documentation Installation Textures Texture Float32Texture Int32Texture Uint32Texture ImageTexture CanvasTexture TableTexture copyTexture Solvers Solver Copy setUniformInSolvers setUniformsInSolvers SignalPlot Plot1D Plot2D Tvsx VolumeRayCaster getColormapList Probe TextureReader ProbeRecorder IntervalCaller saveCanvas APD OrbitalCameraControl MouseListener ClickListener DoubleClickListener CtrlClickListener ShiftClickListener CommandClickListener CtrlShiftClickListener ShiftCtrlClickListener LongClickListener Storage saveToXML loadFromXML xorwow random Gui Editor glMatrix

TableTexture (class)

Creates Float32Texture that is initialized by a Float32Array of appropriate size. The minification and the magification filters of the texture are set to 'linear' by default.

Constructor

The class constructor can be called by

var textureInstance = new TableTexture( 
   table, 
   width , 
   height, 
   options ) ;

The arguments are:

  1. table

    A Float32Array of size width*height*4 where each color of the pixel is represented by an element of the array.

    The texture is filled up, row by row, from the bottom up and with RGBA values followed in sequence.

  2. width

    width of the texture to be created.

  3. height

    height of the texture to be created. (Default = 1)

  4. options

object of optional named arguments. If none is provided, the default values will be assumed. The options object's available properties are:

Instance properties

The following properties have read and write permissions and hence can be modified.

Instance methods

Example

The code snippet below shows an example of setting up a table texture.

var width   = 32 ; // number of pixels in the horizontal direction
var height  = 16 ; // number of pixels in the vertical direction

var table = new Float32Array(width*height*4) ;
var p = 0 ; // counter that tracks the pixel index number

for(var j=0; j<height ; j++){     // represents row    numbers
    for(var i=0 ; i<width; i++){  // represents column numbers
        table[p++] = i/width ;    // the red   channel
        table[p++] = j/height ;   // the green channel
        table[p++] = 0. ;         // the blue  channel
        table[p++] = 1. ;         // the alpha channel
    }
}

// texture definition
var texture = new Abubu.TableTexture( table, width, height ) ;
texture.magFilter = 'nearest' ;     // setting magnification filter
texture.minFilter = 'nearest' ;     // setting minification  filter