| 600 | } |
| 601 | |
| 602 | void attach_buffer(int fb, int width, int height) |
| 603 | { |
| 604 | if ((buffer.width != width) || (buffer.height != height)) |
| 605 | { |
| 606 | free_buffer(); |
| 607 | wf::gles::run_in_context_if_gles([&] |
| 608 | { |
| 609 | GL_CALL(glGenTextures(1, &buffer.tex)); |
| 610 | GL_CALL(glBindTexture(GL_TEXTURE_2D, buffer.tex)); |
| 611 | GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, |
| 612 | width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL)); |
| 613 | GL_CALL(glBindTexture(GL_TEXTURE_2D, 0)); |
| 614 | }); |
| 615 | |
| 616 | buffer.width = width; |
| 617 | buffer.height = height; |
| 618 | } |
| 619 | |
| 620 | wf::gles::run_in_context_if_gles([&] |
| 621 | { |
| 622 | GL_CALL(glBindTexture(GL_TEXTURE_2D, buffer.tex)); |
| 623 | GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, fb)); |
| 624 | GL_CALL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, |
| 625 | GL_TEXTURE_2D, buffer.tex, 0)); |
| 626 | GL_CALL(glBindTexture(GL_TEXTURE_2D, 0)); |
| 627 | GL_CALL(glBindFramebuffer(GL_FRAMEBUFFER, 0)); |
| 628 | |
| 629 | currently_attached_fb = fb; |
| 630 | }); |
| 631 | } |
| 632 | }; |
| 633 | |
| 634 | /** |
nothing calls this directly
no test coverage detected