(framebuffer)
| 1417 | } |
| 1418 | |
| 1419 | recreateFramebufferTextures(framebuffer) { |
| 1420 | const gl = this.GL; |
| 1421 | |
| 1422 | const prevBoundTexture = gl.getParameter(gl.TEXTURE_BINDING_2D); |
| 1423 | const prevBoundFramebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING); |
| 1424 | |
| 1425 | const colorTexture = gl.createTexture(); |
| 1426 | if (!colorTexture) { |
| 1427 | throw new Error('Unable to create color texture'); |
| 1428 | } |
| 1429 | gl.bindTexture(gl.TEXTURE_2D, colorTexture); |
| 1430 | const colorFormat = this._getFramebufferColorFormat(framebuffer); |
| 1431 | gl.texImage2D( |
| 1432 | gl.TEXTURE_2D, |
| 1433 | 0, |
| 1434 | colorFormat.internalFormat, |
| 1435 | framebuffer.width * framebuffer.density, |
| 1436 | framebuffer.height * framebuffer.density, |
| 1437 | 0, |
| 1438 | colorFormat.format, |
| 1439 | colorFormat.type, |
| 1440 | null |
| 1441 | ); |
| 1442 | framebuffer.colorTexture = colorTexture; |
| 1443 | gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer.framebuffer); |
| 1444 | gl.framebufferTexture2D( |
| 1445 | gl.FRAMEBUFFER, |
| 1446 | gl.COLOR_ATTACHMENT0, |
| 1447 | gl.TEXTURE_2D, |
| 1448 | colorTexture, |
| 1449 | 0 |
| 1450 | ); |
| 1451 | |
| 1452 | if (framebuffer.useDepth) { |
| 1453 | // Create the depth texture |
| 1454 | const depthTexture = gl.createTexture(); |
| 1455 | if (!depthTexture) { |
| 1456 | throw new Error('Unable to create depth texture'); |
| 1457 | } |
| 1458 | const depthFormat = this._getFramebufferDepthFormat(framebuffer); |
| 1459 | gl.bindTexture(gl.TEXTURE_2D, depthTexture); |
| 1460 | gl.texImage2D( |
| 1461 | gl.TEXTURE_2D, |
| 1462 | 0, |
| 1463 | depthFormat.internalFormat, |
| 1464 | framebuffer.width * framebuffer.density, |
| 1465 | framebuffer.height * framebuffer.density, |
| 1466 | 0, |
| 1467 | depthFormat.format, |
| 1468 | depthFormat.type, |
| 1469 | null |
| 1470 | ); |
| 1471 | |
| 1472 | gl.framebufferTexture2D( |
| 1473 | gl.FRAMEBUFFER, |
| 1474 | framebuffer.useStencil ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT, |
| 1475 | gl.TEXTURE_2D, |
| 1476 | depthTexture, |
no test coverage detected