wonder.js
Version:
94 lines (86 loc) • 4.62 kB
JavaScript
'use strict';
var Caml_option = require("bs-platform/lib/js/caml_option.js");
var TextureSizeService$Wonderjs = require("../../../../../primitive/texture/TextureSizeService.js");
var TextureTypeService$Wonderjs = require("../../../../../primitive/texture/TextureTypeService.js");
var TextureWrapService$Wonderjs = require("../../../../../primitive/texture/TextureWrapService.js");
var BufferTextureService$Wonderjs = require("../../../../../record/main/texture/BufferTextureService.js");
var TextureFormatService$Wonderjs = require("../../../../../primitive/texture/TextureFormatService.js");
var TextureSourceMapService$Wonderjs = require("../../../../../primitive/texture/TextureSourceMapService.js");
var UpdateTextureRenderService$Wonderjs = require("../../UpdateTextureRenderService.js");
var UpdateGLTextureRenderService$Wonderjs = require("../../UpdateGLTextureRenderService.js");
var OperateTypeArrayAllBasicSourceTextureService$Wonderjs = require("../../../../../record/all/texture/source/basic_source/OperateTypeArrayAllBasicSourceTextureService.js");
function _drawTexture(gl, param) {
var glFormat = param[3];
gl.texImage2D(param[0], param[1], glFormat, glFormat, param[4], param[2]);
return /* () */0;
}
function _drawTwoDTexture(gl, param, source) {
return _drawTexture(gl, /* tuple */[
param[0],
0,
source,
param[1],
param[2]
]);
}
var _allocateSourceToTexture = _drawTwoDTexture;
function update(gl, param, param$1) {
var basicSourceTextureRecord = param$1[0];
var browserDetectRecord = param$1[1];
var textureInTypeArray = param[1];
var match = TextureSourceMapService$Wonderjs.getSource(param[0], basicSourceTextureRecord[/* sourceMap */8]);
if (match !== undefined) {
var source = Caml_option.valFromOption(match);
var width = TextureSizeService$Wonderjs.getWidth(source);
var height = TextureSizeService$Wonderjs.getHeight(source);
var glWrapS = TextureWrapService$Wonderjs.getGlWrap(gl, OperateTypeArrayAllBasicSourceTextureService$Wonderjs.getWrapS(textureInTypeArray, basicSourceTextureRecord[/* wrapSs */0]));
var glWrapT = TextureWrapService$Wonderjs.getGlWrap(gl, OperateTypeArrayAllBasicSourceTextureService$Wonderjs.getWrapT(textureInTypeArray, basicSourceTextureRecord[/* wrapTs */1]));
var magFilter = OperateTypeArrayAllBasicSourceTextureService$Wonderjs.getMagFilter(textureInTypeArray, basicSourceTextureRecord[/* magFilters */2]);
var minFilter = OperateTypeArrayAllBasicSourceTextureService$Wonderjs.getMinFilter(textureInTypeArray, basicSourceTextureRecord[/* minFilters */3]);
var glFormat = TextureFormatService$Wonderjs.getGlFormat(gl, OperateTypeArrayAllBasicSourceTextureService$Wonderjs.getFormat(textureInTypeArray, basicSourceTextureRecord[/* formats */4]));
var glType = TextureTypeService$Wonderjs.getGlType(gl, OperateTypeArrayAllBasicSourceTextureService$Wonderjs.getType(textureInTypeArray, basicSourceTextureRecord[/* types */5]));
var flipY = OperateTypeArrayAllBasicSourceTextureService$Wonderjs.isFlipY(textureInTypeArray, basicSourceTextureRecord[/* flipYs */7]);
var target = gl.TEXTURE_2D;
UpdateGLTextureRenderService$Wonderjs.update(/* tuple */[
gl,
textureInTypeArray,
source
], /* tuple */[
width,
height,
glWrapS,
glWrapT,
magFilter,
minFilter,
glFormat,
glType,
flipY,
target,
target
], /* tuple */[
basicSourceTextureRecord[/* isNeedUpdates */6],
browserDetectRecord
], /* tuple */[
_allocateSourceToTexture,
basicSourceTextureRecord[/* setFlipYFunc */10]
]);
return /* tuple */[
basicSourceTextureRecord,
browserDetectRecord
];
} else {
return /* tuple */[
basicSourceTextureRecord,
browserDetectRecord
];
}
}
function isNeedUpdate(textureInTypeArray, basicSourceTextureRecord) {
return UpdateTextureRenderService$Wonderjs.isNeedUpdate(textureInTypeArray, BufferTextureService$Wonderjs.getDefaultIsNeedUpdate(/* () */0), basicSourceTextureRecord[/* isNeedUpdates */6], OperateTypeArrayAllBasicSourceTextureService$Wonderjs.getIsNeedUpdate);
}
exports._drawTexture = _drawTexture;
exports._drawTwoDTexture = _drawTwoDTexture;
exports._allocateSourceToTexture = _allocateSourceToTexture;
exports.update = update;
exports.isNeedUpdate = isNeedUpdate;
/* TextureFormatService-Wonderjs Not a pure module */