()
| 693 | |
| 694 | |
| 695 | protected void beginRender() { |
| 696 | if (sketch == null) { |
| 697 | sketch = graphics.parent; |
| 698 | } |
| 699 | |
| 700 | pgeomCount = geomCount; |
| 701 | geomCount = 0; |
| 702 | |
| 703 | pclearColor = clearColor; |
| 704 | clearColor = false; |
| 705 | |
| 706 | pclearDepth = clearDepth; |
| 707 | clearDepth = false; |
| 708 | |
| 709 | pclearStencil = clearStencil; |
| 710 | clearStencil = false; |
| 711 | |
| 712 | if (SINGLE_BUFFERED && sketch.frameCount == 1) { |
| 713 | restoreFirstFrame(); |
| 714 | } |
| 715 | |
| 716 | if (fboLayerEnabledReq) { |
| 717 | fboLayerEnabled = true; |
| 718 | fboLayerEnabledReq = false; |
| 719 | } |
| 720 | |
| 721 | if (fboLayerEnabled) { |
| 722 | if (fbolayerResetReq) { |
| 723 | destroyFBOLayer(); |
| 724 | fbolayerResetReq = false; |
| 725 | } |
| 726 | if (!fboLayerCreated) { |
| 727 | createFBOLayer(); |
| 728 | } |
| 729 | |
| 730 | // Draw to the back texture |
| 731 | bindFramebufferImpl(FRAMEBUFFER, glColorFbo.get(0)); |
| 732 | framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0, |
| 733 | TEXTURE_2D, glColorTex.get(backTex), 0); |
| 734 | |
| 735 | if (1 < numSamples) { |
| 736 | bindFramebufferImpl(FRAMEBUFFER, glMultiFbo.get(0)); |
| 737 | } |
| 738 | |
| 739 | if (sketch.frameCount == 0) { |
| 740 | // No need to draw back color buffer because we are in the first frame. |
| 741 | int argb = graphics.backgroundColor; |
| 742 | float ba = ((argb >> 24) & 0xff) / 255.0f; |
| 743 | float br = ((argb >> 16) & 0xff) / 255.0f; |
| 744 | float bg = ((argb >> 8) & 0xff) / 255.0f; |
| 745 | float bb = ((argb) & 0xff) / 255.0f; |
| 746 | clearColor(br, bg, bb, ba); |
| 747 | clear(COLOR_BUFFER_BIT); |
| 748 | } else if (!pclearColor || !sketch.isLooping()) { |
| 749 | // Render previous back texture (now is the front) as background, |
| 750 | // because no background() is being used ("incremental drawing") |
| 751 | int x = 0; |
| 752 | int y = 0; |
no test coverage detected