webGLPipelineContext.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 vertexCompilationError: Nullable<string> = null;
  15. public fragmentCompilationError: Nullable<string> = null;
  16. public programLinkError: Nullable<string> = null;
  17. public programValidationError: Nullable<string> = null;
  18. public get isAsync() {
  19. return this.isParallelCompiled;
  20. }
  21. public get isReady(): boolean {
  22. if (this.program) {
  23. if (this.isParallelCompiled) {
  24. return this.engine._isRenderingStateCompiled(this);
  25. }
  26. return true;
  27. }
  28. return false;
  29. }
  30. public _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void {
  31. if (onCompiled && this.program) {
  32. onCompiled(this.program);
  33. }
  34. }
  35. }