38 lines
888 B
TypeScript
38 lines
888 B
TypeScript
import type { WebGLCanvas } from "./WebGLCanvas";
|
|
import { WebGLStateAbstract } from "./WebGLStateAbstract";
|
|
|
|
class WebGLState extends WebGLStateAbstract {
|
|
|
|
private statePool: Array<WebGLStateAbstract> = [];
|
|
|
|
private registerState(state: WebGLStateAbstract) {
|
|
this.statePool.push(state);
|
|
}
|
|
|
|
public override contextWillBind(newcanvas: WebGLCanvas) {
|
|
for (const state of this.statePool) {
|
|
state.bindCanvas(newcanvas);
|
|
}
|
|
}
|
|
|
|
public override contextLost() {
|
|
for (const state of this.statePool) {
|
|
state.contextLost();
|
|
}
|
|
}
|
|
|
|
public override resetState() {
|
|
for (const state of this.statePool) {
|
|
state.resetState();
|
|
}
|
|
}
|
|
|
|
public override destroy() {
|
|
for (const state of this.statePool) {
|
|
state.destroy();
|
|
}
|
|
}
|
|
}
|
|
|
|
export { WebGLState };
|