From 2ecba4d70cf21aeb5f2473865aaf45c483d943eb Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Wed, 18 Mar 2026 13:07:57 +0800 Subject: [PATCH] [Fix] (MG_Test/VertexArrayTest): fix VertexArrayTest compilation error --- .../MG_Test/VertexArray/VertexArrayTest.cpp | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp b/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp index 49714eb7..26c2f425 100644 --- a/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp +++ b/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp @@ -21,7 +21,8 @@ using namespace MobileGL; class VertexArrayTest : public ::testing::Test { protected: SharedPtr CreateTestVBO() { - auto bufferNames = MobileGL::MG_State::pGLContext->GenBufferNames(1); + Vector bufferNames; + MobileGL::MG_State::pGLContext->GenBufferNames(1, bufferNames); auto vbo = MobileGL::MG_State::pGLContext->CreateBufferObject(bufferNames[0]); MobileGL::MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Vertex).Bind(vbo); @@ -39,7 +40,8 @@ protected: }; TEST_F(VertexArrayTest, GenerateAndBindVAO) { - auto vaoNames = MobileGL::MG_State::pGLContext->GenVertexArrayNames(2); + Vector vaoNames; + MobileGL::MG_State::pGLContext->GenVertexArrayNames(2, vaoNames); auto vao0 = MobileGL::MG_State::pGLContext->CreateVertexArrayObject(vaoNames[0]); auto vao1 = MobileGL::MG_State::pGLContext->CreateVertexArrayObject(vaoNames[1]); @@ -55,7 +57,8 @@ TEST_F(VertexArrayTest, GenerateAndBindVAO) { } TEST_F(VertexArrayTest, VertexAttributeSetup) { - auto vaoNames = MobileGL::MG_State::pGLContext->GenVertexArrayNames(1); + Vector vaoNames; + MobileGL::MG_State::pGLContext->GenVertexArrayNames(1, vaoNames); auto vao = MobileGL::MG_State::pGLContext->CreateVertexArrayObject(vaoNames[0]); MobileGL::MG_State::pGLContext->BindVertexArray(vaoNames[0]); @@ -86,11 +89,13 @@ TEST_F(VertexArrayTest, VertexAttributeSetup) { } TEST_F(VertexArrayTest, IndexBufferBinding) { - auto vaoNames = MobileGL::MG_State::pGLContext->GenVertexArrayNames(1); + Vector vaoNames; + MobileGL::MG_State::pGLContext->GenVertexArrayNames(1, vaoNames); auto vao = MobileGL::MG_State::pGLContext->CreateVertexArrayObject(vaoNames[0]); MobileGL::MG_State::pGLContext->BindVertexArray(vaoNames[0]); - auto bufferNames = MobileGL::MG_State::pGLContext->GenBufferNames(1); + Vector bufferNames; + MobileGL::MG_State::pGLContext->GenBufferNames(1, bufferNames); auto ebo = MobileGL::MG_State::pGLContext->CreateBufferObject(bufferNames[0]); MobileGL::MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Index).Bind(ebo); @@ -103,14 +108,16 @@ TEST_F(VertexArrayTest, IndexBufferBinding) { MobileGL::MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Index).Bind(ebo); ASSERT_EQ(MobileGL::MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Index).GetBoundObject(), ebo); - auto newEboNames = MobileGL::MG_State::pGLContext->GenBufferNames(1); + Vector newEboNames; + MobileGL::MG_State::pGLContext->GenBufferNames(1, newEboNames); auto newEbo = MobileGL::MG_State::pGLContext->CreateBufferObject(newEboNames[0]); MobileGL::MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Index).Bind(newEbo); ASSERT_EQ(MobileGL::MG_State::pGLContext->GetBufferBindingSlot(BufferTarget::Index).GetBoundObject(), newEbo); } TEST_F(VertexArrayTest, DeleteVAO) { - auto vaoNames = MobileGL::MG_State::pGLContext->GenVertexArrayNames(1); + Vector vaoNames; + MobileGL::MG_State::pGLContext->GenVertexArrayNames(1, vaoNames); auto vao = MobileGL::MG_State::pGLContext->CreateVertexArrayObject(vaoNames[0]); MobileGL::MG_State::pGLContext->BindVertexArray(vaoNames[0]); @@ -125,7 +132,8 @@ TEST_F(VertexArrayTest, DeleteVAO) { TEST_F(VertexArrayTest, ValidateNamesAndObjects) { const Uint count = 5; - auto vaoNames = MobileGL::MG_State::pGLContext->GenVertexArrayNames(count); + Vector vaoNames; + MobileGL::MG_State::pGLContext->GenVertexArrayNames(count, vaoNames); for (Uint i = 0; i < count; i++) { ASSERT_TRUE(MobileGL::MG_State::pGLContext->ValidateVertexArrayName(vaoNames[i])); @@ -144,12 +152,14 @@ TEST_F(VertexArrayTest, ValidateNamesAndObjects) { } TEST_F(VertexArrayTest, MultipleAttributes) { - auto vaoNames = MobileGL::MG_State::pGLContext->GenVertexArrayNames(1); + Vector vaoNames; + MobileGL::MG_State::pGLContext->GenVertexArrayNames(1, vaoNames); auto vao = MobileGL::MG_State::pGLContext->CreateVertexArrayObject(vaoNames[0]); MobileGL::MG_State::pGLContext->BindVertexArray(vaoNames[0]); auto vboPos = CreateTestVBO(); - auto vboNormalNames = MobileGL::MG_State::pGLContext->GenBufferNames(1); + Vector vboNormalNames; + MobileGL::MG_State::pGLContext->GenBufferNames(1, vboNormalNames); auto vboNormal = MobileGL::MG_State::pGLContext->CreateBufferObject(vboNormalNames[0]); Vector normals(12, 0.5f); @@ -187,7 +197,8 @@ TEST_F(VertexArrayTest, MultipleAttributes) { } TEST_F(VertexArrayTest, BoundVAOPreservesState) { - auto vaoNames = MobileGL::MG_State::pGLContext->GenVertexArrayNames(2); + Vector vaoNames; + MobileGL::MG_State::pGLContext->GenVertexArrayNames(2, vaoNames); auto vao1 = MobileGL::MG_State::pGLContext->CreateVertexArrayObject(vaoNames[0]); auto vao2 = MobileGL::MG_State::pGLContext->CreateVertexArrayObject(vaoNames[1]); @@ -216,11 +227,9 @@ using namespace MobileGL::MG_Impl::GLImpl; class GeneralVertexArrayTest : public ::testing::Test { protected: - void SetUp() override { MG_State::pGLContext = new MG_State::GLState::GLContext(); } + void SetUp() override { MG_State::pGLContext = MakeUnique(); } void TearDown() override { - delete MG_State::pGLContext; - MG_State::pGLContext = nullptr; } GLuint CreateVAO() {