From 8bdf990810e248d00c316474ab81064e975fa7b4 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Sat, 21 Feb 2026 22:25:59 +0800 Subject: [PATCH] [Fix] (MG_Test|MG_Bench): Fix compilation. --- MobileGL/MG_Benchmark/Buffer/BufferBench.cpp | 4 +- .../MG_Benchmark/Program/ProgramBench.cpp | 6 +-- .../MG_Test/Backend/DirectVulkan/TestExec.cpp | 44 +++++++------------ MobileGL/MG_Test/Buffer/BufferTest.cpp | 4 +- MobileGL/MG_Test/Program/ProgramTest.cpp | 4 +- MobileGL/MG_Test/Program/ProgramUtilTest.cpp | 2 +- .../MG_Test/VertexArray/VertexArrayTest.cpp | 2 +- 7 files changed, 28 insertions(+), 38 deletions(-) diff --git a/MobileGL/MG_Benchmark/Buffer/BufferBench.cpp b/MobileGL/MG_Benchmark/Buffer/BufferBench.cpp index 251a5b6d..02e7d3e1 100644 --- a/MobileGL/MG_Benchmark/Buffer/BufferBench.cpp +++ b/MobileGL/MG_Benchmark/Buffer/BufferBench.cpp @@ -61,7 +61,7 @@ static void BM_CreateBufferObjectsAndBindBuffer(benchmark::State& state) { BENCHMARK(BM_CreateBufferObjectsAndBindBuffer)->Unit(benchmark::kMillisecond)->UseRealTime(); static void BM_DeleteBufferObjects(benchmark::State& state) { - MG_Initialize(); + Initialize(); std::vector buffers(BUFFER_COUNT); for (auto _ : state) { @@ -179,7 +179,7 @@ static void BM_UpdateDataPartially(benchmark::State& state) { BENCHMARK(BM_UpdateDataPartially)->Unit(benchmark::kMillisecond)->UseRealTime(); int main(int argc, char** argv) { - MG_Initialize(); + Initialize(); benchmark ::MaybeReenterWithoutASLR(argc, argv); char arg0_default[] = "benchmark"; char* args_default = reinterpret_cast(arg0_default); diff --git a/MobileGL/MG_Benchmark/Program/ProgramBench.cpp b/MobileGL/MG_Benchmark/Program/ProgramBench.cpp index 34a927c0..58ab4c01 100644 --- a/MobileGL/MG_Benchmark/Program/ProgramBench.cpp +++ b/MobileGL/MG_Benchmark/Program/ProgramBench.cpp @@ -43,7 +43,7 @@ void main(){ // Use TestMat2 and TestMat3 to prevent optimization vec2 dummy2 = TestMat2[0]; vec3 dummy3 = TestMat3[0]; - + oneTexel = (1.0 * (fIn1 * fIn2 * fIn3 * fIn4 * fIn5 * fIn6)) / InSize; texCoord = Position.xy / OutSize; @@ -221,7 +221,7 @@ static void BM_CompileAndLink(benchmark::State& state) { BENCHMARK(BM_CompileAndLink)->Unit(benchmark::kMillisecond); int main(int argc, char** argv) { - MG_Initialize(); + Initialize(); benchmark ::MaybeReenterWithoutASLR(argc, argv); char arg0_default[] = "benchmark"; char* args_default = reinterpret_cast(arg0_default); @@ -234,4 +234,4 @@ int main(int argc, char** argv) { ::benchmark ::RunSpecifiedBenchmarks(); ::benchmark ::Shutdown(); return 0; -} \ No newline at end of file +} diff --git a/MobileGL/MG_Test/Backend/DirectVulkan/TestExec.cpp b/MobileGL/MG_Test/Backend/DirectVulkan/TestExec.cpp index f20ea2ba..e71f1d4a 100644 --- a/MobileGL/MG_Test/Backend/DirectVulkan/TestExec.cpp +++ b/MobileGL/MG_Test/Backend/DirectVulkan/TestExec.cpp @@ -27,9 +27,9 @@ #endif #include #ifdef _WIN32 - #define GLFW_EXPOSE_NATIVE_WIN32 +#define GLFW_EXPOSE_NATIVE_WIN32 #elif defined(__APPLE__) - #define GLFW_EXPOSE_NATIVE_COCOA +#define GLFW_EXPOSE_NATIVE_COCOA #endif #include @@ -44,8 +44,8 @@ #undef NO_GL_H namespace MobileGL { - void MG_Initialize(); -} + void Initialize(); +} // namespace MobileGL static bool CheckShaderCompile(GLuint shader, const char* label) { GLint status = GL_FALSE; @@ -94,12 +94,7 @@ static bool CheckProgramLink(GLuint program) { int main() { glfwInit(); - static EGLint const attribute_list[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_NONE - }; + static EGLint const attribute_list[] = {EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_NONE}; EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(display, nullptr, nullptr); @@ -134,7 +129,7 @@ int main() { EGLSurface surface = eglCreateWindowSurface(display, config, nativewindow, nullptr); eglMakeCurrent(display, surface, surface, context); - MobileGL::MG_Initialize(); + MobileGL::Initialize(); GLuint offscreenTex = 0; GLuint offscreenFbo = 0; @@ -166,12 +161,8 @@ int main() { GLuint shapeVbo = 0; glGenBuffers(1, &shapeVbo); glBindBuffer(GL_ARRAY_BUFFER, shapeVbo); - glBufferData( - GL_ARRAY_BUFFER, - static_cast((kMaxSegments + 1) * 5 * sizeof(GLfloat)), - nullptr, - GL_DYNAMIC_DRAW - ); + glBufferData(GL_ARRAY_BUFFER, static_cast((kMaxSegments + 1) * 5 * sizeof(GLfloat)), nullptr, + GL_DYNAMIC_DRAW); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, static_cast(5 * sizeof(GLfloat)), nullptr); glEnableVertexAttribArray(0); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, static_cast(5 * sizeof(GLfloat)), @@ -181,12 +172,8 @@ int main() { GLuint shapeIbo = 0; glGenBuffers(1, &shapeIbo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shapeIbo); - glBufferData( - GL_ELEMENT_ARRAY_BUFFER, - static_cast(kMaxSegments * 3 * sizeof(GLushort)), - nullptr, - GL_DYNAMIC_DRAW - ); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast(kMaxSegments * 3 * sizeof(GLushort)), nullptr, + GL_DYNAMIC_DRAW); static constexpr const char* kVertexShaderSource = R"(#version 330 core layout(location = 0) in vec2 aPos; @@ -231,7 +218,7 @@ void main() { std::vector dynamicVertices(static_cast((kMaxSegments + 1) * 5)); std::vector dynamicIndices(static_cast(kMaxSegments * 3)); int i = 0; - while(!glfwWindowShouldClose(window)) { + while (!glfwWindowShouldClose(window)) { glfwPollEvents(); GLint framebufferWidth = kWindowWidth; @@ -247,7 +234,8 @@ void main() { glBindFramebuffer(GL_READ_FRAMEBUFFER, offscreenFbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - glBlitFramebuffer(0, 0, 256, 256, 0, 0, framebufferWidth, framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); + glBlitFramebuffer(0, 0, 256, 256, 0, 0, framebufferWidth, framebufferHeight, GL_COLOR_BUFFER_BIT, + GL_NEAREST); glBindFramebuffer(GL_FRAMEBUFFER, 0); } else { const int segmentCount = std::min(kMaxSegments, 3 + (i / 100)); @@ -287,9 +275,11 @@ void main() { glUseProgram(program); glBindVertexArray(vao); glBindBuffer(GL_ARRAY_BUFFER, shapeVbo); - glBufferSubData(GL_ARRAY_BUFFER, 0, static_cast(vertexFloatCount * sizeof(GLfloat)), dynamicVertices.data()); + glBufferSubData(GL_ARRAY_BUFFER, 0, static_cast(vertexFloatCount * sizeof(GLfloat)), + dynamicVertices.data()); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, shapeIbo); - glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, static_cast(indexCount * sizeof(GLushort)), dynamicIndices.data()); + glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, static_cast(indexCount * sizeof(GLushort)), + dynamicIndices.data()); glDrawElements(GL_TRIANGLES, static_cast(indexCount), GL_UNSIGNED_SHORT, nullptr); } diff --git a/MobileGL/MG_Test/Buffer/BufferTest.cpp b/MobileGL/MG_Test/Buffer/BufferTest.cpp index 681c3652..c065e451 100644 --- a/MobileGL/MG_Test/Buffer/BufferTest.cpp +++ b/MobileGL/MG_Test/Buffer/BufferTest.cpp @@ -19,7 +19,7 @@ using namespace MobileGL; class BufferTest : public ::testing::Test { protected: - void SetUp() override { MobileGL::MG_Initialize(); } + void SetUp() override { MobileGL::Initialize(); } void TearDown() override {} }; @@ -543,4 +543,4 @@ TEST_F(GeneralBufferTest, General_GeneralTest_1) { DeleteBuffers(2, toDelete); EXPECT_EQ(GetError(), GL_NO_ERROR); -} \ No newline at end of file +} diff --git a/MobileGL/MG_Test/Program/ProgramTest.cpp b/MobileGL/MG_Test/Program/ProgramTest.cpp index 78e75180..1da44ad5 100644 --- a/MobileGL/MG_Test/Program/ProgramTest.cpp +++ b/MobileGL/MG_Test/Program/ProgramTest.cpp @@ -18,7 +18,7 @@ using namespace MobileGL::MG_Impl::GLImpl; class ProgramTest : public ::testing::Test { protected: - void SetUp() override { MobileGL::MG_Initialize(); } + void SetUp() override { MobileGL::Initialize(); } void TearDown() override {} }; @@ -54,7 +54,7 @@ void main(){ // Use TestMat2 and TestMat3 to prevent optimization vec2 dummy2 = TestMat2[0]; vec3 dummy3 = TestMat3[0]; - + oneTexel = (1.0 * (fIn1 * fIn2 * fIn3 * fIn4 * fIn5 * fIn6 * fIn0)) / InSize; texCoord = Position.xy / OutSize; diff --git a/MobileGL/MG_Test/Program/ProgramUtilTest.cpp b/MobileGL/MG_Test/Program/ProgramUtilTest.cpp index 76b40623..88068a54 100644 --- a/MobileGL/MG_Test/Program/ProgramUtilTest.cpp +++ b/MobileGL/MG_Test/Program/ProgramUtilTest.cpp @@ -19,7 +19,7 @@ using namespace MobileGL; class ProgramUtilTest : public ::testing::Test { protected: - void SetUp() override { MobileGL::MG_Initialize(); } + void SetUp() override { MobileGL::Initialize(); } void TearDown() override {} }; diff --git a/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp b/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp index c52d4cef..49714eb7 100644 --- a/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp +++ b/MobileGL/MG_Test/VertexArray/VertexArrayTest.cpp @@ -33,7 +33,7 @@ protected: return vbo; } - void SetUp() override { MobileGL::MG_Initialize(); } + void SetUp() override { MobileGL::Initialize(); } void TearDown() override {} };