@itwin/core-frontend
Version:
iTwin.js frontend components
44 lines • 2.4 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* 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.Debug = void 0;
const GL_1 = require("./GL");
const System_1 = require("./System");
/** Provides facilities for conditionally executing diagnostic/debug code. By default, all facilities are disabled - they must be explicitly enabled.
* @internal
*/
class Debug {
/** Whether [[Debug.print]] will actually produce output. */
static printEnabled = false;
/** Whether [[Debug.evaluate]] will actually evaluate an expression. */
static evaluateEnabled = false;
/** If [[Debug.printEnabled]] is true, outputs a message using `console.log`.
* @param message A function which returns a string. If [[Debug.printEnabled]] is false, the function is never evaluated.
*/
static print(message) {
if (this.printEnabled)
console.log(message()); // eslint-disable-line no-console
}
/** If [[Debug.evaluate]] is true, executes the supplied function and returns its result; otherwise returns the supplied default value.
* @param evaluate The function to execute
* @param defaultValue The value to return if [[Debug.evaluate]] is false
* @returns The return value of `evaluate` if [[Debug.evaluate]] is true; otherwise, the `defaultValue`.
*/
static evaluate(evaluate, defaultValue) {
return this.evaluateEnabled ? evaluate() : defaultValue;
}
/** If [[Debug.evaluateEnabled]] is true, returns whether the currently-bound framebuffer is complete. */
static get isValidFrameBuffer() { return GL_1.GL.FrameBuffer.Status.Complete === this.checkFrameBufferStatus(); }
/** If [[Debug.evaluateEnabled]] is true, returns the status of the currently-bound framebuffer. */
static checkFrameBufferStatus() {
return this.evaluate(() => System_1.System.instance.context.checkFramebufferStatus(GL_1.GL.FrameBuffer.TARGET), GL_1.GL.FrameBuffer.Status.Complete);
}
}
exports.Debug = Debug;
//# sourceMappingURL=Diagnostics.js.map