sdf-2d/src/graphics/rendering/render-pass/render-pass.ts
2020-09-28 16:26:55 +02:00

30 lines
1.1 KiB
TypeScript

import { DrawableDescriptor } from '../../../drawables/drawable-descriptor';
import { FrameBuffer } from '../../graphics-library/frame-buffer/frame-buffer';
import { ParallelCompiler } from '../../graphics-library/parallel-compiler';
import { UniformArrayAutoScalingProgram } from '../../graphics-library/program/uniform-array-autoscaling-program';
import { UniversalRenderingContext } from '../../graphics-library/universal-rendering-context';
/** @internal */
export abstract class RenderPass {
protected program: UniformArrayAutoScalingProgram;
constructor(gl: UniversalRenderingContext, protected frame: FrameBuffer) {
this.program = new UniformArrayAutoScalingProgram(gl);
}
public async initialize(
shaderSources: [string, string],
descriptors: Array<DrawableDescriptor>,
substitutions: { [name: string]: any } = {},
compiler: ParallelCompiler
): Promise<void> {
await this.program.initialize(shaderSources, descriptors, substitutions, compiler);
}
public abstract render(commonUniforms: any, inputTexture?: WebGLTexture): void;
public destroy(): void {
this.frame.destroy();
this.program.destroy();
}
}