初始化

This commit is contained in:
2025-07-30 13:39:32 +08:00
commit d1f2452b28
253 changed files with 32087 additions and 0 deletions

49
vendor/h264-live-player/Program.ts vendored Normal file
View File

@@ -0,0 +1,49 @@
import Shader from './Shader';
import assert from './utils/assert';
export default class Program {
public readonly program: WebGLProgram | null;
constructor(readonly gl: WebGLRenderingContext) {
this.program = this.gl.createProgram();
}
public attach(shader: Shader): void {
if (!this.program) {
throw Error(`Program type is ${typeof this.program}`);
}
if (!shader.shader) {
throw Error(`Shader type is ${typeof shader.shader}`);
}
this.gl.attachShader(this.program, shader.shader);
}
public link(): void {
if (!this.program) {
throw Error(`Program type is ${typeof this.program}`);
}
this.gl.linkProgram(this.program);
// If creating the shader program failed, alert.
assert(this.gl.getProgramParameter(this.program, this.gl.LINK_STATUS),
'Unable to initialize the shader program.');
}
public use(): void {
this.gl.useProgram(this.program);
}
public getAttributeLocation(name: string): number {
if (!this.program) {
throw Error(`Program type is ${typeof this.program}`);
}
return this.gl.getAttribLocation(this.program, name);
}
public setMatrixUniform(name: string, array: Float32List): void {
if (!this.program) {
throw Error(`Program type is ${typeof this.program}`);
}
const uniform = this.gl.getUniformLocation(this.program, name);
this.gl.uniformMatrix4fv(uniform, false, array);
}
}