MCPcopy Index your code
hub / github.com/benfry/processing4 / createFBOLayer

Method createFBOLayer

core/src/processing/opengl/PGL.java:939–1033  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

937
938
939 private void createFBOLayer() {
940 float scale = getPixelScale();
941
942 if (hasNpotTexSupport()) {
943 fboWidth = (int)(scale * graphics.width);
944 fboHeight = (int)(scale * graphics.height);
945 } else {
946 fboWidth = nextPowerOfTwo((int)(scale * graphics.width));
947 fboHeight = nextPowerOfTwo((int)(scale * graphics.height));
948 }
949
950 if (hasFboMultisampleSupport()) {
951 int maxs = maxSamples();
952 numSamples = PApplet.min(reqNumSamples, maxs);
953 } else {
954 numSamples = 1;
955 }
956 boolean multisample = 1 < numSamples;
957
958 boolean packed = hasPackedDepthStencilSupport();
959 int depthBits = PApplet.min(REQUESTED_DEPTH_BITS, getDepthBits());
960 int stencilBits = PApplet.min(REQUESTED_STENCIL_BITS, getStencilBits());
961
962 genTextures(2, glColorTex);
963 for (int i = 0; i < 2; i++) {
964 bindTexture(TEXTURE_2D, glColorTex.get(i));
965 texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, NEAREST);
966 texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, NEAREST);
967 texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
968 texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
969 texImage2D(TEXTURE_2D, 0, RGBA, fboWidth, fboHeight, 0,
970 RGBA, UNSIGNED_BYTE, null);
971 initTexture(TEXTURE_2D, RGBA, fboWidth, fboHeight, graphics.backgroundColor);
972 }
973 bindTexture(TEXTURE_2D, 0);
974
975 backTex = 0;
976 frontTex = 1;
977
978 genFramebuffers(1, glColorFbo);
979 bindFramebufferImpl(FRAMEBUFFER, glColorFbo.get(0));
980 framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0, TEXTURE_2D,
981 glColorTex.get(backTex), 0);
982
983 if (!multisample || graphics.getHint(PConstants.ENABLE_BUFFER_READING)) {
984 // If not multisampled, this is the only depth and stencil buffer.
985 // If multisampled and depth reading enabled, these are going to
986 // hold downsampled depth and stencil buffers.
987 createDepthAndStencilBuffer(false, depthBits, stencilBits, packed);
988 }
989
990 if (multisample) {
991 // Creating multisampled FBO
992 genFramebuffers(1, glMultiFbo);
993 bindFramebufferImpl(FRAMEBUFFER, glMultiFbo.get(0));
994
995 // color render buffer...
996 genRenderbuffers(1, glMultiColor);

Callers 2

beginRenderMethod · 0.95
endRenderMethod · 0.95

Calls 15

getPixelScaleMethod · 0.95
hasNpotTexSupportMethod · 0.95
nextPowerOfTwoMethod · 0.95
maxSamplesMethod · 0.95
minMethod · 0.95
getDepthBitsMethod · 0.95
getStencilBitsMethod · 0.95
genTexturesMethod · 0.95
bindTextureMethod · 0.95
texParameteriMethod · 0.95

Tested by

no test coverage detected