(boolean multisample, int depthBits,
int stencilBits, boolean packed)
| 1095 | |
| 1096 | |
| 1097 | private void createDepthAndStencilBuffer(boolean multisample, int depthBits, |
| 1098 | int stencilBits, boolean packed) { |
| 1099 | // Creating depth and stencil buffers |
| 1100 | if (packed && depthBits == 24 && stencilBits == 8) { |
| 1101 | // packed depth+stencil buffer |
| 1102 | IntBuffer depthStencilBuf = |
| 1103 | multisample ? glMultiDepthStencil : glDepthStencil; |
| 1104 | genRenderbuffers(1, depthStencilBuf); |
| 1105 | bindRenderbuffer(RENDERBUFFER, depthStencilBuf.get(0)); |
| 1106 | if (multisample) { |
| 1107 | renderbufferStorageMultisample(RENDERBUFFER, numSamples, |
| 1108 | DEPTH24_STENCIL8, fboWidth, fboHeight); |
| 1109 | } else { |
| 1110 | renderbufferStorage(RENDERBUFFER, DEPTH24_STENCIL8, |
| 1111 | fboWidth, fboHeight); |
| 1112 | } |
| 1113 | framebufferRenderbuffer(FRAMEBUFFER, DEPTH_ATTACHMENT, RENDERBUFFER, |
| 1114 | depthStencilBuf.get(0)); |
| 1115 | framebufferRenderbuffer(FRAMEBUFFER, STENCIL_ATTACHMENT, RENDERBUFFER, |
| 1116 | depthStencilBuf.get(0)); |
| 1117 | } else { |
| 1118 | // separate depth and stencil buffers |
| 1119 | if (0 < depthBits) { |
| 1120 | int depthComponent = DEPTH_COMPONENT16; |
| 1121 | if (depthBits == 32) { |
| 1122 | depthComponent = DEPTH_COMPONENT32; |
| 1123 | } else if (depthBits == 24) { |
| 1124 | depthComponent = DEPTH_COMPONENT24; |
| 1125 | //} else if (depthBits == 16) { |
| 1126 | //depthComponent = DEPTH_COMPONENT16; |
| 1127 | } |
| 1128 | |
| 1129 | IntBuffer depthBuf = multisample ? glMultiDepth : glDepth; |
| 1130 | genRenderbuffers(1, depthBuf); |
| 1131 | bindRenderbuffer(RENDERBUFFER, depthBuf.get(0)); |
| 1132 | if (multisample) { |
| 1133 | renderbufferStorageMultisample(RENDERBUFFER, numSamples, |
| 1134 | depthComponent, fboWidth, fboHeight); |
| 1135 | } else { |
| 1136 | renderbufferStorage(RENDERBUFFER, depthComponent, |
| 1137 | fboWidth, fboHeight); |
| 1138 | } |
| 1139 | framebufferRenderbuffer(FRAMEBUFFER, DEPTH_ATTACHMENT, |
| 1140 | RENDERBUFFER, depthBuf.get(0)); |
| 1141 | } |
| 1142 | |
| 1143 | if (0 < stencilBits) { |
| 1144 | int stencilIndex = STENCIL_INDEX1; |
| 1145 | if (stencilBits == 8) { |
| 1146 | stencilIndex = STENCIL_INDEX8; |
| 1147 | } else if (stencilBits == 4) { |
| 1148 | stencilIndex = STENCIL_INDEX4; |
| 1149 | //} else if (stencilBits == 1) { |
| 1150 | //stencilIndex = STENCIL_INDEX1; |
| 1151 | } |
| 1152 | |
| 1153 | IntBuffer stencilBuf = multisample ? glMultiStencil : glStencil; |
| 1154 | genRenderbuffers(1, stencilBuf); |
no test coverage detected