1.1.0 • Published 9 years ago

gl-to-dtype v1.1.0

Weekly downloads
21
License
MIT
Repository
github
Last release
9 years ago

gl-to-dtype

stable

Turns a WebGL constant into a dtype string.

var asDtype = require('gl-to-dtype')
var dtype = require('dtype')

var glType = gl.FLOAT
var type = asDtype(glType)
var array = new (dtype(type))(16)

Converts the following:

gl.FLOAT          -> 'float32'
gl.UNSIGNED_INT   -> 'uint32'
gl.INT            -> 'int32'
gl.UNSIGNED_SHORT -> 'uint16'
gl.SHORT          -> 'int16'
gl.UNSIGNED_BYTE  -> 'uint8'
gl.BYTE           -> 'int8'
gl.UNSIGNED_SHORT_4_4_4_4 -> 'uint16'
gl.UNSIGNED_SHORT_5_5_5_1 -> 'uint16'
gl.UNSIGNED_SHORT_5_6_5 -> 'uint16'

Usage

NPM

require('gl-to-dtype')(glType)

Takes glType constant and returns a string representation aligning with ndarray, dtype and other modules.

Returns null if the flag isn't recognized as a supported type.

License

MIT, see LICENSE.md for details.