engine.transformFeedback.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { Nullable } from "../../types";
  2. import { Engine } from "../../Engines/engine";
  3. import { _TimeToken } from "../../Instrumentation/timeToken";
  4. import { DataBuffer } from '../../Meshes/dataBuffer';
  5. /** @hidden */
  6. export var _forceTransformFeedbackToBundle = true;
  7. declare module "../../Engines/engine" {
  8. export interface Engine {
  9. /**
  10. * Creates a webGL transform feedback object
  11. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  12. * @returns the webGL transform feedback object
  13. */
  14. createTransformFeedback(): WebGLTransformFeedback;
  15. /**
  16. * Delete a webGL transform feedback object
  17. * @param value defines the webGL transform feedback object to delete
  18. */
  19. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  20. /**
  21. * Bind a webGL transform feedback object to the webgl context
  22. * @param value defines the webGL transform feedback object to bind
  23. */
  24. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  25. /**
  26. * Begins a transform feedback operation
  27. * @param usePoints defines if points or triangles must be used
  28. */
  29. beginTransformFeedback(usePoints: boolean): void;
  30. /**
  31. * Ends a transform feedback operation
  32. */
  33. endTransformFeedback(): void;
  34. /**
  35. * Specify the varyings to use with transform feedback
  36. * @param program defines the associated webGL program
  37. * @param value defines the list of strings representing the varying names
  38. */
  39. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40. /**
  41. * Bind a webGL buffer for a transform feedback operation
  42. * @param value defines the webGL buffer to bind
  43. */
  44. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45. }
  46. }
  47. Engine.prototype.createTransformFeedback = function(): WebGLTransformFeedback {
  48. return this._gl.createTransformFeedback();
  49. };
  50. Engine.prototype.deleteTransformFeedback = function(value: WebGLTransformFeedback): void {
  51. this._gl.deleteTransformFeedback(value);
  52. };
  53. Engine.prototype.bindTransformFeedback = function(value: Nullable<WebGLTransformFeedback>): void {
  54. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  55. };
  56. Engine.prototype.beginTransformFeedback = function(usePoints: boolean = true): void {
  57. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  58. };
  59. Engine.prototype.endTransformFeedback = function(): void {
  60. this._gl.endTransformFeedback();
  61. };
  62. Engine.prototype.setTranformFeedbackVaryings = function(program: WebGLProgram, value: string[]): void {
  63. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  64. };
  65. Engine.prototype.bindTransformFeedbackBuffer = function(value: Nullable<DataBuffer>): void {
  66. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value ? value.underlyingResource : null);
  67. };