()
| 265 | |
| 266 | State s = new State(); |
| 267 | s.name = glGenFramebuffers(); |
| 268 | |
| 269 | if (specification.multisample) { |
| 270 | |
| 271 | s.multisample = glGenFramebuffers(); |
| 272 | |
| 273 | s.msRenderBuffers = new int[specification.num]; |
| 274 | |
| 275 | glBindFramebuffer(GL_FRAMEBUFFER, s.multisample); |
| 276 | |
| 277 | for (int i = 0; i < s.msRenderBuffers.length; i++) { |
| 278 | s.msRenderBuffers[i] = glGenRenderbuffers(); |
| 279 | int converageSamples = 16; |
| 280 | |
| 281 | glBindRenderbuffer(GL_RENDERBUFFER, s.msRenderBuffers[i]); |
| 282 | |
| 283 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, converageSamples, specification.internalFormat, specification.width, specification.height); |
| 284 | |
| 285 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER, s.msRenderBuffers[i]); |
| 286 | |
| 287 | } |
| 288 | |
| 289 | if (specification.depth) { |
| 290 | s.msDepth = glGenRenderbuffers(); |
| 291 | int depthSamples = 16; |
| 292 | |
| 293 | glBindRenderbuffer(GL_RENDERBUFFER, s.msDepth); |
| 294 | |
| 295 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, depthSamples, GL_DEPTH24_STENCIL8, specification.width, specification.height); |
| 296 | |
| 297 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, s.msDepth); |
| 298 | |
| 299 | } |
| 300 | |
| 301 | |
| 302 | int status = glCheckFramebufferStatus(GL_FRAMEBUFFER); |
| 303 | |
| 304 | if (status != GL_FRAMEBUFFER_COMPLETE) |
| 305 | throw new IllegalArgumentException(" bad status, " + status); |
| 306 | } |
| 307 | |
| 308 | GraphicsContext.checkError(); |
| 309 | s.text = new int[specification.num]; |
| 310 | for (int i = 0; i < s.text.length; i++) |
| 311 | if (i == 0 && specification.overrideTextureID != -1) s.text[i] = specification.overrideTextureID; |
| 312 | else s.text[i] = glGenTextures(); |
| 313 | |
| 314 | if (specification.depth) s.depth = glGenRenderbuffers(); |
| 315 | |
| 316 | glBindFramebuffer(GL_FRAMEBUFFER, s.name); |
| 317 | GraphicsContext.checkError(); |
| 318 | |
| 319 | if (specification.layers == 1) { |
| 320 | for (int i = 0; i < s.text.length; i++) { |
| 321 | |
| 322 | if (specification.multisample_raw) { |
| 323 | glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, s.text[i]); |
| 324 |
no test coverage detected