(w: number, h: number, internalFormat: number, format: number, type: number, param: number)
| 701 | const displayMaterial = new Material(baseVertexShader, displayShaderSource); |
| 702 | |
| 703 | function createFBO(w: number, h: number, internalFormat: number, format: number, type: number, param: number): FBO { |
| 704 | gl.activeTexture(gl.TEXTURE0); |
| 705 | const texture = gl.createTexture()!; |
| 706 | gl.bindTexture(gl.TEXTURE_2D, texture); |
| 707 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, param); |
| 708 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, param); |
| 709 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); |
| 710 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); |
| 711 | gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, w, h, 0, format, type, null); |
| 712 | const fbo = gl.createFramebuffer()!; |
| 713 | gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); |
| 714 | gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); |
| 715 | gl.viewport(0, 0, w, h); |
| 716 | gl.clear(gl.COLOR_BUFFER_BIT); |
| 717 | |
| 718 | const texelSizeX = 1 / w; |
| 719 | const texelSizeY = 1 / h; |
| 720 | |
| 721 | return { |
| 722 | texture, |
| 723 | fbo, |
| 724 | width: w, |
| 725 | height: h, |
| 726 | texelSizeX, |
| 727 | texelSizeY, |
| 728 | attach(id: number) { |
| 729 | gl.activeTexture(gl.TEXTURE0 + id); |
| 730 | gl.bindTexture(gl.TEXTURE_2D, texture); |
| 731 | return id; |
| 732 | } |
| 733 | }; |
| 734 | } |
| 735 | |
| 736 | function createDoubleFBO( |
| 737 | w: number, |
no test coverage detected