UNPKG

@awayjs/stage

Version:
38 lines (37 loc) 1.57 kB
import { __extends } from "tslib"; import { SamplerState } from '../base/SamplerState'; var SamplerStateWebGL = /** @class */ (function (_super) { __extends(SamplerStateWebGL, _super); function SamplerStateWebGL(id, type, _context) { var _this = _super.call(this, id, type) || this; _this._context = _context; return _this; } SamplerStateWebGL.prototype.commit = function (textureType, texture) { this.type = textureType; if (this.equals(texture._state)) { return; } texture._state.copyFrom(this); var gl = this._context._gl; var isAllowRepeat = texture.isPOT || this._context.glVersion === 2; if (this.wrap === gl.REPEAT && !isAllowRepeat) { gl.texParameteri(textureType, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(textureType, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); } else { gl.texParameteri(textureType, gl.TEXTURE_WRAP_S, this.wrap); gl.texParameteri(textureType, gl.TEXTURE_WRAP_T, this.wrap); } var targetMip = this.mipfilter; // fallback for texture that not has mip, because invalid mip is black if (!texture._isMipmaped) { targetMip = this.filter; } gl.texParameteri(textureType, gl.TEXTURE_MAG_FILTER, this.filter); gl.texParameteri(textureType, gl.TEXTURE_MIN_FILTER, targetMip); this.boundedTexture = texture; }; return SamplerStateWebGL; }(SamplerState)); export { SamplerStateWebGL };