webGLPipelineContext.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { IPipelineContext } from '../IPipelineContext';
  2. import { Nullable } from '../../types';
  3. import { ThinEngine } from '../thinEngine';
  4. /** @hidden */
  5. export class WebGLPipelineContext implements IPipelineContext {
  6. public engine: ThinEngine;
  7. public program: Nullable<WebGLProgram>;
  8. public context?: WebGLRenderingContext;
  9. public vertexShader?: WebGLShader;
  10. public fragmentShader?: WebGLShader;
  11. public isParallelCompiled: boolean;
  12. public onCompiled?: () => void;
  13. public transformFeedback?: WebGLTransformFeedback | null;
  14. public get isAsync() {
  15. return this.isParallelCompiled;
  16. }
  17. public get isReady(): boolean {
  18. if (this.program) {
  19. if (this.isParallelCompiled) {
  20. return this.engine._isRenderingStateCompiled(this);
  21. }
  22. return true;
  23. }
  24. return false;
  25. }
  26. public _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void {
  27. if (onCompiled && this.program) {
  28. onCompiled(this.program);
  29. }
  30. }
  31. }