* Begins drawing shapes to the framebuffer. * * `myBuffer.begin()` and myBuffer.end() * allow shapes to be drawn to the framebuffer. `myBuffer.begin()` begins * drawing to the framebuffer and * myBuffer.end() stops
()
| 761 | * } |
| 762 | */ |
| 763 | begin() { |
| 764 | this.prevFramebuffer = this.renderer.activeFramebuffer(); |
| 765 | if (this.prevFramebuffer) { |
| 766 | this.prevFramebuffer._beforeEnd(); |
| 767 | } |
| 768 | this.renderer.activeFramebuffers.push(this); |
| 769 | this._beforeBegin(); |
| 770 | this.renderer.push(); |
| 771 | // Apply the framebuffer's camera. This does almost what |
| 772 | // RendererGL.reset() does, but this does not try to clear any buffers; |
| 773 | // it only sets the camera. |
| 774 | // this.renderer.setCamera(this.defaultCamera); |
| 775 | this.renderer.states.setValue('curCamera', this.defaultCamera); |
| 776 | // set the projection matrix (which is not normally updated each frame) |
| 777 | this.renderer.states.setValue('uPMatrix', this.renderer.states.uPMatrix.clone()); |
| 778 | this.renderer.states.uPMatrix.set(this.defaultCamera.projMatrix); |
| 779 | this.renderer.states.setValue('uViewMatrix', this.renderer.states.uViewMatrix.clone()); |
| 780 | this.renderer.states.uViewMatrix.set(this.defaultCamera.cameraMatrix); |
| 781 | |
| 782 | this.renderer.resetMatrix(); |
| 783 | this.renderer.states.uViewMatrix |
| 784 | .set(this.renderer.states.curCamera.cameraMatrix); |
| 785 | this.renderer.states.uModelMatrix.reset(); |
| 786 | this.renderer._applyStencilTestIfClipping(); |
| 787 | } |
| 788 | |
| 789 | /** |
| 790 | * When making a p5.Framebuffer active so that it may be drawn to, this method |
no test coverage detected