(w, h, internalFormat, format, type, param)
| 585 | } |
| 586 | |
| 587 | function createFBO(w, h, internalFormat, format, type, param) { |
| 588 | gl.activeTexture(gl.TEXTURE0); |
| 589 | let texture = gl.createTexture(); |
| 590 | gl.bindTexture(gl.TEXTURE_2D, texture); |
| 591 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, param); |
| 592 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, param); |
| 593 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); |
| 594 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); |
| 595 | gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, w, h, 0, format, type, null); |
| 596 | |
| 597 | let fbo = gl.createFramebuffer(); |
| 598 | gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); |
| 599 | gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); |
| 600 | gl.viewport(0, 0, w, h); |
| 601 | gl.clear(gl.COLOR_BUFFER_BIT); |
| 602 | |
| 603 | let texelSizeX = 1.0 / w; |
| 604 | let texelSizeY = 1.0 / h; |
| 605 | return { |
| 606 | texture, |
| 607 | fbo, |
| 608 | width: w, |
| 609 | height: h, |
| 610 | texelSizeX, |
| 611 | texelSizeY, |
| 612 | attach(id) { |
| 613 | gl.activeTexture(gl.TEXTURE0 + id); |
| 614 | gl.bindTexture(gl.TEXTURE_2D, texture); |
| 615 | return id; |
| 616 | } |
| 617 | }; |
| 618 | } |
| 619 | |
| 620 | function createDoubleFBO(w, h, internalFormat, format, type, param) { |
| 621 | let fbo1 = createFBO(w, h, internalFormat, format, type, param); |
no test coverage detected