From 06a79f2fc498d60edff8019a562078eff095ebf0 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Fri, 16 May 2025 16:16:02 +0800 Subject: [PATCH] [Fix] (ShittilyDrawing): Ensure proper VBO binding when syncing VAO attributes. --- MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp b/MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp index f464c60e..40934450 100644 --- a/MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp +++ b/MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp @@ -540,7 +540,13 @@ namespace MG_GL::GL { MG_Util::Debug::LogD("Updating MG VAO %d, dirty attrib", mgid); // Update attrib vao.attribDirty = false; + GLint prevArrayBuffer; + CallAndCheck(::GLES::glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &prevArrayBuffer);) for (auto& [index, attrib] : vao.attribs) { + GLuint buffer = attrib.buffer; + GLuint glBuffer = (buffer != 0) ? s_bufferMap[buffer] : 0; + CallAndCheck(::GLES::glBindBuffer(GL_ARRAY_BUFFER, glBuffer);) + MG_Util::Debug::LogD("attrib #%d: size=%d, type=%s, stride=%d, pointer=%d, %s, isInt=%s", index, attrib.size, MG_Util::Debug::GLEnumToString(attrib.type), attrib.stride, attrib.pointer, (attrib.enabled ? "enabled" : "disabled"), (attrib.isInteger ? "true" : "false")); @@ -561,6 +567,7 @@ namespace MG_GL::GL { CallAndCheck(::GLES::glDisableVertexAttribArray(index);) } } + CallAndCheck(::GLES::glBindBuffer(GL_ARRAY_BUFFER, prevArrayBuffer);) } if (vao.eboDirty) {