()
| 894 | |
| 895 | |
| 896 | private void createFBOLayer() { |
| 897 | float scale = getPixelScale(); |
| 898 | |
| 899 | if (hasNpotTexSupport()) { |
| 900 | fboWidth = (int)(scale * graphics.width); |
| 901 | fboHeight = (int)(scale * graphics.height); |
| 902 | } else { |
| 903 | fboWidth = nextPowerOfTwo((int)(scale * graphics.width)); |
| 904 | fboHeight = nextPowerOfTwo((int)(scale * graphics.height)); |
| 905 | } |
| 906 | |
| 907 | if (hasFboMultisampleSupport()) { |
| 908 | int maxs = maxSamples(); |
| 909 | numSamples = PApplet.min(reqNumSamples, maxs); |
| 910 | } else { |
| 911 | numSamples = 1; |
| 912 | } |
| 913 | boolean multisample = 1 < numSamples; |
| 914 | |
| 915 | boolean packed = hasPackedDepthStencilSupport(); |
| 916 | int depthBits = PApplet.min(REQUESTED_DEPTH_BITS, getDepthBits()); |
| 917 | int stencilBits = PApplet.min(REQUESTED_STENCIL_BITS, getStencilBits()); |
| 918 | |
| 919 | genTextures(2, glColorTex); |
| 920 | for (int i = 0; i < 2; i++) { |
| 921 | bindTexture(TEXTURE_2D, glColorTex.get(i)); |
| 922 | texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, NEAREST); |
| 923 | texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, NEAREST); |
| 924 | texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE); |
| 925 | texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE); |
| 926 | texImage2D(TEXTURE_2D, 0, RGBA, fboWidth, fboHeight, 0, |
| 927 | RGBA, UNSIGNED_BYTE, null); |
| 928 | initTexture(TEXTURE_2D, RGBA, fboWidth, fboHeight, graphics.backgroundColor); |
| 929 | } |
| 930 | bindTexture(TEXTURE_2D, 0); |
| 931 | |
| 932 | backTex = 0; |
| 933 | frontTex = 1; |
| 934 | |
| 935 | genFramebuffers(1, glColorFbo); |
| 936 | bindFramebufferImpl(FRAMEBUFFER, glColorFbo.get(0)); |
| 937 | framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0, TEXTURE_2D, |
| 938 | glColorTex.get(backTex), 0); |
| 939 | |
| 940 | if (!multisample || graphics.getHint(PConstants.ENABLE_BUFFER_READING)) { |
| 941 | // If not multisampled, this is the only depth and stencil buffer. |
| 942 | // If multisampled and depth reading enabled, these are going to |
| 943 | // hold downsampled depth and stencil buffers. |
| 944 | createDepthAndStencilBuffer(false, depthBits, stencilBits, packed); |
| 945 | } |
| 946 | |
| 947 | if (multisample) { |
| 948 | // Creating multisampled FBO |
| 949 | genFramebuffers(1, glMultiFbo); |
| 950 | bindFramebufferImpl(FRAMEBUFFER, glMultiFbo.get(0)); |
| 951 | |
| 952 | // color render buffer... |
| 953 | genRenderbuffers(1, glMultiColor); |
no test coverage detected