"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module WebGL
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClippingProgram = void 0;
exports.createClippingProgram = createClippingProgram;
const core_bentley_1 = require("@itwin/core-bentley");
const System_1 = require("./System");
const Clipping_1 = require("./glsl/Clipping");
function createClippingBuilder(src) {
    const builder = src.clone();
    builder.vert.headerComment += "-Clip";
    builder.frag.headerComment += "-Clip";
    (0, Clipping_1.addClipping)(builder);
    return builder;
}
/** @internal */
class ClippingProgram {
    _program;
    compile() {
        return undefined === this._program || 0 /* CompileStatus.Success */ === this._program.compile();
    }
    constructor(src) {
        const builder = createClippingBuilder(src);
        this._program = builder.buildProgram(System_1.System.instance.context);
    }
    getProgram(numPlanes) {
        return numPlanes > 0 ? this._program : undefined;
    }
    [Symbol.dispose]() {
        this._program = (0, core_bentley_1.dispose)(this._program);
    }
    /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */
    dispose() {
        this[Symbol.dispose]();
    }
}
exports.ClippingProgram = ClippingProgram;
/** @internal */
function createClippingProgram(builder) {
    return new ClippingProgram(builder);
}
//# sourceMappingURL=ClippingProgram.js.map