All files / src/video-filters passthrough-filter.js

100% Statements 8/8
100% Branches 0/0
100% Functions 4/4
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42            202x                                 33x 33x 33x             10x 10x       14x 14x      
import VERT_SHADER from "./shaders/passthrough.vert.glsl?raw";
import FRAG_SHADER from "./shaders/passthrough.frag.glsl?raw";
import { compileProgram } from "./shader-program.js";
 
export class PassthroughFilter {
    static getDisplayConfig() {
        return {
            name: "RGB Monitor",
            image: "images/cub-monitor.png",
            imageAlt: "A fake CUB computer monitor",
            imageWidth: 896,
            imageHeight: 648,
            canvasLeft: 0,
            canvasTop: 8,
            visibleWidth: 896,
            visibleHeight: 600,
            canvasWidth: 896,
            canvasHeight: 600,
            persistence: { setting: "rgbPersistenceMs", default: 25 },
        };
    }
 
    constructor(gl) {
        this.gl = gl;
        this.program = compileProgram(gl, VERT_SHADER, FRAG_SHADER, "passthrough");
        this.locations = {
            tex: gl.getUniformLocation(this.program, "tex"),
        };
    }
 
    /** Release the GL objects this filter owns. */
    dispose() {
        this.gl.deleteProgram(this.program);
        this.program = null;
    }
 
    setUniforms(_params) {
        const gl = this.gl;
        gl.uniform1i(this.locations.tex, 0);
    }
}