From aabbeac3d9e2ac0f293ab43fec71e56091c823e8 Mon Sep 17 00:00:00 2001 From: hachem Date: Tue, 18 Aug 2026 15:00:34 +0200 Subject: fix: macOS compatibility --- src/platform/opengl/opengl_framebuffer.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/platform/opengl/opengl_framebuffer.cpp') diff --git a/src/platform/opengl/opengl_framebuffer.cpp b/src/platform/opengl/opengl_framebuffer.cpp index c5b8fe2..9040994 100644 --- a/src/platform/opengl/opengl_framebuffer.cpp +++ b/src/platform/opengl/opengl_framebuffer.cpp @@ -19,7 +19,7 @@ namespace Donut static void create_textures(bool multisampled, uint32_t* out_id, uint32_t count) { - glCreateTextures(texture_target(multisampled), count, out_id); + glGenTextures(count, out_id); } static void attach_color_texture(uint32_t id, int samples, GLenum internal_format, GLenum format, uint32_t width, uint32_t height, int index) @@ -31,7 +31,8 @@ namespace Donut } else { - glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, nullptr); + GLenum type = (format == GL_RED_INTEGER) ? GL_INT : GL_UNSIGNED_BYTE; + glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, type, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -52,7 +53,9 @@ namespace Donut } else { - glTexStorage2D(GL_TEXTURE_2D, 1, format, width, height); + GLenum depth_format = (format == GL_DEPTH24_STENCIL8) ? GL_DEPTH_STENCIL : GL_DEPTH_COMPONENT; + GLenum depth_type = (format == GL_DEPTH24_STENCIL8) ? GL_UNSIGNED_INT_24_8 : GL_FLOAT; + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, depth_format, depth_type, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -118,7 +121,7 @@ namespace Donut m_depth_attachment = 0; } - glCreateFramebuffers(1, &m_renderer_id); + glGenFramebuffers(1, &m_renderer_id); glBindFramebuffer(GL_FRAMEBUFFER, m_renderer_id); bool multisample = m_specification.Samples > 1; @@ -230,8 +233,7 @@ namespace Donut void OpenGLFramebuffer::clear_attachment(uint32_t attachment_index, int value) { - auto& spec = m_color_attachment_specifications[attachment_index]; - glClearTexImage(m_color_attachments[attachment_index], 0, - Utils::donut_fb_texture_format_to_gl(spec.texture_format), GL_INT, &value); + glBindFramebuffer(GL_FRAMEBUFFER, m_renderer_id); + glClearBufferiv(GL_COLOR, static_cast(attachment_index), &value); } }; -- cgit v1.3