ts-game-engine
Version:
Simple WebGL game/render engine written in TypeScript
30 lines (29 loc) • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class Texture {
constructor(scene) {
this.context = scene.Game.GraphicsSystem.Context;
this.pipelineState = scene.Game.GraphicsSystem.PipelineState;
const texture = this.context.createTexture();
if (texture === null) {
throw new Error("Unable to create Texture object.");
}
this.texture = texture;
}
get Texture() { return this.texture; }
Dispose() {
this.context.deleteTexture(this.texture);
}
IsPowerOf2(value) {
return (value & (value - 1)) === 0;
}
static DisposeAll() {
for (let texture of this.textures.values()) {
texture.Dispose();
}
this.textures.clear();
}
}
exports.Texture = Texture;
// Texture Manager --------------------------------------------------------------------------------------------------------
Texture.textures = new Map();