UNPKG

wonder.js

Version:
92 lines (76 loc) 3.48 kB
'use strict'; var Caml_option = require("bs-platform/lib/js/caml_option.js"); var MutableHashMapService$WonderCommonlib = require("wonder-commonlib/lib/js/src/MutableHashMapService.js"); var MutableSparseMapService$WonderCommonlib = require("wonder-commonlib/lib/js/src/MutableSparseMapService.js"); function _getLocationAndCache(param, getGlLocationFunc, gl) { var locationMap = param[2]; var name = param[1]; var match = MutableHashMapService$WonderCommonlib.get(name, locationMap); if (match !== undefined) { return Caml_option.valFromOption(match); } else { var pos = getGlLocationFunc(param[0], name, gl); MutableHashMapService$WonderCommonlib.set(name, pos, locationMap); return pos; } } function _getGlAttribLocation(program, name, gl) { return gl.getAttribLocation(program, name); } function _getGlUniformLocation(program, name, gl) { return gl.getUniformLocation(program, name); } function getAttribLocationAndCache(program, name, attributeLocationMap, gl) { return _getLocationAndCache(/* tuple */[ program, name, attributeLocationMap ], _getGlAttribLocation, gl); } function getUniformLocationAndCache(program, name, uniformLocationMap, gl) { return _getLocationAndCache(/* tuple */[ program, name, uniformLocationMap ], _getGlUniformLocation, gl); } function getAttributeLocationMap(shaderIndex, glslLocationRecord) { return MutableSparseMapService$WonderCommonlib.get(shaderIndex, glslLocationRecord[/* attributeLocationMap */0]); } function setAttributeLocationMap(shaderIndex, attributeLocationMap, glslLocationRecord) { MutableSparseMapService$WonderCommonlib.set(shaderIndex, attributeLocationMap, glslLocationRecord[/* attributeLocationMap */0]); return glslLocationRecord; } function getUniformLocationMap(shaderIndex, glslLocationRecord) { return MutableSparseMapService$WonderCommonlib.get(shaderIndex, glslLocationRecord[/* uniformLocationMap */1]); } function setUniformLocationMap(shaderIndex, uniformLocationMap, glslLocationRecord) { MutableSparseMapService$WonderCommonlib.set(shaderIndex, uniformLocationMap, glslLocationRecord[/* uniformLocationMap */1]); return glslLocationRecord; } function clearUniformLocationMap(shaderIndex, glslLocationRecord) { return setUniformLocationMap(shaderIndex, MutableHashMapService$WonderCommonlib.createEmpty(/* () */0), glslLocationRecord); } function createLocationMap(param) { return MutableHashMapService$WonderCommonlib.createEmpty(/* () */0); } function isAttributeLocationExist(pos) { return pos !== -1; } function isUniformLocationExist(pos) { return pos !== null; } exports._getLocationAndCache = _getLocationAndCache; exports._getGlAttribLocation = _getGlAttribLocation; exports._getGlUniformLocation = _getGlUniformLocation; exports.getAttribLocationAndCache = getAttribLocationAndCache; exports.getUniformLocationAndCache = getUniformLocationAndCache; exports.getAttributeLocationMap = getAttributeLocationMap; exports.setAttributeLocationMap = setAttributeLocationMap; exports.getUniformLocationMap = getUniformLocationMap; exports.setUniformLocationMap = setUniformLocationMap; exports.clearUniformLocationMap = clearUniformLocationMap; exports.createLocationMap = createLocationMap; exports.isAttributeLocationExist = isAttributeLocationExist; exports.isUniformLocationExist = isUniformLocationExist; /* No side effect */