| 28 | } |
| 29 | |
| 30 | void FrameBuffer::Resize() { |
| 31 | #ifdef _WIN32 |
| 32 | glCreateFramebuffers(1, &m_framebuffer_identifier); |
| 33 | glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer_identifier); |
| 34 | |
| 35 | glCreateTextures(GL_TEXTURE_2D, 1, &m_texture_color_attachment_identifier); |
| 36 | glBindTextureUnit(0, m_texture_color_attachment_identifier); |
| 37 | glTextureStorage2D(m_texture_color_attachment_identifier, 1, GL_RGBA8, m_specification.Width, m_specification.Height); |
| 38 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_specification.Width, m_specification.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
| 39 | glTextureParameteri(m_texture_color_attachment_identifier, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 40 | glTextureParameteri(m_texture_color_attachment_identifier, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 41 | |
| 42 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture_color_attachment_identifier, 0); |
| 43 | |
| 44 | if (m_specification.HasStencil && m_specification.HasDepth) { |
| 45 | glCreateTextures(GL_TEXTURE_2D, 1, &m_texture_color_depth_attachment); |
| 46 | glBindTextureUnit(0, m_texture_color_depth_attachment); |
| 47 | glTextureStorage2D(m_texture_color_depth_attachment, 1, GL_DEPTH32F_STENCIL8, m_specification.Width, m_specification.Height); |
| 48 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_texture_color_depth_attachment, 0); |
| 49 | } |
| 50 | #else |
| 51 | glGenFramebuffers(1, &m_framebuffer_identifier); |
| 52 | glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer_identifier); |
| 53 | |
| 54 | glGenTextures(1, &m_texture_color_attachment_identifier); |
| 55 | glBindTexture(GL_TEXTURE_2D, m_texture_color_attachment_identifier); |
| 56 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_specification.Width, m_specification.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
| 57 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 58 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 59 | |
| 60 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture_color_attachment_identifier, 0); |
| 61 | |
| 62 | if (m_specification.HasStencil && m_specification.HasDepth) { |
| 63 | glGenTextures(1, &m_texture_color_depth_attachment); |
| 64 | glBindTexture(GL_TEXTURE_2D, m_texture_color_depth_attachment); |
| 65 | glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_specification.Width, m_specification.Height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL); |
| 66 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_texture_color_depth_attachment, 0); |
| 67 | } |
| 68 | |
| 69 | #endif |
| 70 | |
| 71 | if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { |
| 72 | ZENGINE_CORE_CRITICAL("Framebuffer is incomplete"); |
| 73 | ZENGINE_EXIT_FAILURE(); |
| 74 | } |
| 75 | |
| 76 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 77 | } |
| 78 | |
| 79 | void FrameBuffer::Resize(uint32_t width, uint32_t height) { |
| 80 | m_specification.Width = width; |
no outgoing calls
no test coverage detected