From a51d25a606ec6cfa44f0e71461cde20b2dfcf389 Mon Sep 17 00:00:00 2001 From: Thomas Harrison Date: Sun, 30 Nov 2025 17:03:49 -0500 Subject: [PATCH 1/8] Fix email address in license --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 862f8ea..985f30f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright 2021 Thomas Harrison +Copyright 2021 Thomas Harrison Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From a00ac5d1ab8013802c8ac33f07cbe53005273f09 Mon Sep 17 00:00:00 2001 From: Thomas Harrison Date: Sun, 30 Nov 2025 17:04:07 -0500 Subject: [PATCH 2/8] Format cmakelists.txt --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ba65cf..b1a9c44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,10 +6,10 @@ project(glpp LANGUAGES CXX) set(GLPP_IS_MASTER_PROJECT OFF) -if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) set(GLPP_IS_MASTER_PROJECT ON) endif() - + option(GLPP_BUILD_DOCS "Builds the glpp documentation" ${GLPP_IS_MASTER_PROJECT}) option(GLPP_BUILD_EXAMPLES "Builds the glpp examples" ${GLPP_IS_MASTER_PROJECT}) option(GLPP_BUILD_TESTS "Builds the glpp tests" ${GLPP_IS_MASTER_PROJECT}) @@ -43,7 +43,7 @@ endif() include(GNUInstallDirs) # Create config.h with project version numbers -configure_File(cmake/config.h.in include/config.h) +configure_file(cmake/config.h.in include/config.h) include_directories(PRIVATE ${CMAKE_BINARY_DIR}/include) find_package(OpenGL REQUIRED) From b16128aa288a94fbf8fa5bd62e00abeb2c129562 Mon Sep 17 00:00:00 2001 From: Thomas Harrison Date: Sun, 30 Nov 2025 17:04:19 -0500 Subject: [PATCH 3/8] Enable sort using --- .clang-format | 2 +- include/glpp/Buffer.hpp | 2 +- include/glpp/FrameBuffer.hpp | 2 +- include/glpp/Shader.hpp | 2 +- include/glpp/Texture.hpp | 2 +- include/glpp/extra/GeometryBuffer.hpp | 2 +- include/glpp/extra/Vertex.hpp | 2 +- src/extra/Grid.cpp | 2 +- src/extra/Line.cpp | 2 +- src/extra/Marker.cpp | 2 +- tests/glmChecker.cpp | 4 ++-- tests/test_extra_Transform.cpp | 6 +++--- tests/test_glm_compare.cpp | 4 ++-- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.clang-format b/.clang-format index 906e38a..19a9d20 100644 --- a/.clang-format +++ b/.clang-format @@ -40,7 +40,7 @@ NamespaceIndentation: All PenaltyBreakComment: 20 PenaltyExcessCharacter: 5 PointerAlignment: Middle -SortUsingDeclarations: false +SortUsingDeclarations: true SpaceAfterTemplateKeyword: false SpaceBeforeCpp11BracedList: true SpacesBeforeTrailingComments: 1 diff --git a/include/glpp/Buffer.hpp b/include/glpp/Buffer.hpp index 0327cc2..1ab65a6 100644 --- a/include/glpp/Buffer.hpp +++ b/include/glpp/Buffer.hpp @@ -10,8 +10,8 @@ #include namespace glpp { - using std::vector; using std::shared_ptr; + using std::vector; /** * A single array buffer. diff --git a/include/glpp/FrameBuffer.hpp b/include/glpp/FrameBuffer.hpp index e5d3eab..2caa349 100644 --- a/include/glpp/FrameBuffer.hpp +++ b/include/glpp/FrameBuffer.hpp @@ -11,8 +11,8 @@ #include "Texture.hpp" namespace glpp { - using std::vector; using std::shared_ptr; + using std::vector; class RenderBuffer { public: diff --git a/include/glpp/Shader.hpp b/include/glpp/Shader.hpp index 02a10be..5a05137 100644 --- a/include/glpp/Shader.hpp +++ b/include/glpp/Shader.hpp @@ -13,9 +13,9 @@ // https://www.khronos.org/opengl/wiki/Shader_Compilation namespace glpp { + using std::shared_ptr; using std::string; using std::string_view; - using std::shared_ptr; class ShaderCompileException : public std::runtime_error { public: diff --git a/include/glpp/Texture.hpp b/include/glpp/Texture.hpp index d550181..2735864 100644 --- a/include/glpp/Texture.hpp +++ b/include/glpp/Texture.hpp @@ -10,8 +10,8 @@ #include namespace glpp { - using std::string; using std::shared_ptr; + using std::string; class TextureLoadException : public std::runtime_error { public: diff --git a/include/glpp/extra/GeometryBuffer.hpp b/include/glpp/extra/GeometryBuffer.hpp index b746b81..a3d1dbe 100644 --- a/include/glpp/extra/GeometryBuffer.hpp +++ b/include/glpp/extra/GeometryBuffer.hpp @@ -9,8 +9,8 @@ #include "glpp/extra/Vertex.hpp" namespace glpp::extra { - using std::shared_ptr; using glm::uvec2; + using std::shared_ptr; class GeometryBuffer : public FrameBuffer { public: diff --git a/include/glpp/extra/Vertex.hpp b/include/glpp/extra/Vertex.hpp index 746b556..2fc83c1 100644 --- a/include/glpp/extra/Vertex.hpp +++ b/include/glpp/extra/Vertex.hpp @@ -6,8 +6,8 @@ #include "glpp/Buffer.hpp" namespace glpp::extra { - using std::vector; using std::shared_ptr; + using std::vector; /** * A single point in the format accepted by VBO, Mesh and Model. diff --git a/src/extra/Grid.cpp b/src/extra/Grid.cpp index cf6fb1c..ef4b08b 100644 --- a/src/extra/Grid.cpp +++ b/src/extra/Grid.cpp @@ -22,8 +22,8 @@ void main() { })"; namespace glpp::extra { - using std::vector; using std::make_shared; + using std::vector; void Grid::updateBuffer() { vector vertices; diff --git a/src/extra/Line.cpp b/src/extra/Line.cpp index fd0e2fd..398362e 100644 --- a/src/extra/Line.cpp +++ b/src/extra/Line.cpp @@ -28,8 +28,8 @@ void main() { }) namespace glpp::extra { - using std::vector; using std::make_shared; + using std::vector; void Line::updateBuffer() { vector vertices = points; diff --git a/src/extra/Marker.cpp b/src/extra/Marker.cpp index 41514ed..d02f13a 100644 --- a/src/extra/Marker.cpp +++ b/src/extra/Marker.cpp @@ -1,8 +1,8 @@ #include "glpp/extra/Marker.hpp" namespace glpp::extra { - using std::move; using std::make_shared; + using std::move; Mark::Mark(const vector & points, const glm::vec4 & color) : Transform(), line(make_shared(points, color, Line::Lines)) {} diff --git a/tests/glmChecker.cpp b/tests/glmChecker.cpp index 9384901..77185c9 100644 --- a/tests/glmChecker.cpp +++ b/tests/glmChecker.cpp @@ -4,9 +4,9 @@ #include #include -using glm::vec3; -using glm::quat; using glm::mat4; +using glm::quat; +using glm::vec3; using std::ostream; // static ostream & operator<<(ostream & os, const quat & q) { diff --git a/tests/test_extra_Transform.cpp b/tests/test_extra_Transform.cpp index bfeb9c2..fe0308b 100644 --- a/tests/test_extra_Transform.cpp +++ b/tests/test_extra_Transform.cpp @@ -12,10 +12,10 @@ #include "glTest.hpp" namespace { - using glpp::extra::Transform; - using glm::vec3; - using glm::quat; using glm::mat4; + using glm::quat; + using glm::vec3; + using glpp::extra::Transform; /** * Empty constructor should have default position and rotation of 0 with diff --git a/tests/test_glm_compare.cpp b/tests/test_glm_compare.cpp index b769d6b..037054b 100644 --- a/tests/test_glm_compare.cpp +++ b/tests/test_glm_compare.cpp @@ -6,9 +6,9 @@ #include "glTest.hpp" namespace { - using glm::vec3; - using glm::quat; using glm::mat4; + using glm::quat; + using glm::vec3; TEST(GLMTest, VecEqIsExpected) { vec3 a(1, 2, 3); From 1ce8060a079fb4ec63c83735f037fb8f2cec644b Mon Sep 17 00:00:00 2001 From: Thomas Harrison Date: Thu, 19 Mar 2026 20:41:29 -0400 Subject: [PATCH 4/8] Update testing setup --- .vscode/launch.json | 11 +++++++++++ .vscode/settings.json | 4 ++++ Makefile | 5 ++++- external/glm.cmake | 2 +- external/gtest.cmake | 4 ++-- tests/CMakeLists.txt | 41 +++++++++++++++++------------------------ 6 files changed, 39 insertions(+), 28 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json index 5558fa6..ae76d79 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -29,6 +29,17 @@ "ignoreFailures": true } ] + }, + // https://stackoverflow.com/a/76447033 + { + "name": "(ctest) Launch", + "type": "cppdbg", + "cwd": "${cmake.testWorkingDirectory}", + "request": "launch", + "program": "${cmake.testProgram}", + "args": [ + "${cmake.testArgs}" + ] } ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..26ceda5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "cmake.ctest.testSuiteDelimiter": "\\.", + "cmake.ctest.testExplorerIntegrationEnabled": true +} \ No newline at end of file diff --git a/Makefile b/Makefile index 7cf389f..8ce254e 100644 --- a/Makefile +++ b/Makefile @@ -28,4 +28,7 @@ lint: format: @find src include examples tests -name '*.c' -or -name '*.h' -or -name '*.cpp' -or -name '*.hpp' | xargs clang-format -i --Werror --sort-includes -.PHONY: config build install lint format +test: + cmake --build $(PWD)/build --target test + +.PHONY: config build install lint format test diff --git a/external/glm.cmake b/external/glm.cmake index 7bee5b1..5f71fc9 100644 --- a/external/glm.cmake +++ b/external/glm.cmake @@ -3,7 +3,7 @@ include(FetchContent) FetchContent_Declare( glm GIT_REPOSITORY https://github.com/g-truc/glm.git - GIT_TAG 1.0.1 + GIT_TAG 1.0.2 ) set(USE_SYSTEM_GLM ON) diff --git a/external/gtest.cmake b/external/gtest.cmake index 7e285bc..3c9c7bc 100644 --- a/external/gtest.cmake +++ b/external/gtest.cmake @@ -1,11 +1,11 @@ +include(FetchContent) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.12.1 + GIT_TAG v1.15.2 ) -# if(NOT glm_POPULATED) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) set(BUILD_GTEST ON CACHE BOOL "" FORCE) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0a0e7a5..5409183 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,29 +1,22 @@ -set(TARGET tests) +enable_testing() +include(GoogleTest) -macro(define_test name) +file(GLOB_RECURSE SOURCE_LIST ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +file(GLOB_RECURSE HEADER_LIST ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp) - set(SOURCE_LIST - glTest.cpp - glTest.hpp - glmChecker.cpp - glmChecker.hpp - test_${name}.cpp - ) - list(TRANSFORM SOURCE_LIST PREPEND "${${PROJECT_NAME}_SOURCE_DIR}/tests/") +foreach(TEST_SOURCE ${SOURCE_LIST}) + cmake_path(GET TEST_SOURCE STEM test_name) + if(${test_name} MATCHES "^test_") + message("Generate test ${test_name}") - add_executable(${TARGET}_${name} ${SOURCE_LIST}) - target_link_libraries(${TARGET}_${name} PRIVATE gtest gtest_main glpp glfw) + add_executable(${test_name} ${TEST_SOURCE} ${HEADER_LIST} + glTest.cpp + glTest.hpp + glmChecker.cpp + glmChecker.hpp) + target_link_libraries(${test_name} PRIVATE gtest gtest_main glpp glfw) - target_include_directories(${TARGET}_${name} PRIVATE "${${PROJECT_NAME}_SOURCE_DIR}/tests/") + gtest_discover_tests(${test_name}) + endif() +endforeach() - add_test(NAME ${TARGET}_${name} COMMAND ${TARGET}_${name}) -endmacro() - -define_test(shader) -define_test(uniform) -define_test(texture) -define_test(vertex) -define_test(quad) - -define_test(glm_compare) -define_test(extra_Transform) From aa06f92801949be458a4e7398bae9667d96781fb Mon Sep 17 00:00:00 2001 From: Thomas Harrison Date: Thu, 19 Mar 2026 20:45:46 -0400 Subject: [PATCH 5/8] Fix test --- tests/test_shader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_shader.cpp b/tests/test_shader.cpp index f3eae1c..f37cdee 100644 --- a/tests/test_shader.cpp +++ b/tests/test_shader.cpp @@ -135,8 +135,7 @@ namespace { } TEST_F(ShaderTest, defaultShader) { - // TODO: Why did this switch to 0 instead of > 0 - EXPECT_EQ(shader.getProgram(), 0); + EXPECT_GT(shader.getProgram(), 0); } TEST_F(ShaderTest, fromFragmentSource) { From 47827276556bc789540b09b31372f28caf7b1041 Mon Sep 17 00:00:00 2001 From: Thomas Harrison Date: Thu, 19 Mar 2026 20:47:17 -0400 Subject: [PATCH 6/8] Enable ci testing --- .github/workflows/ci.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 988ab3f..e251a33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,31 +12,31 @@ on: - synchronize jobs: - # test: - # runs-on: ubuntu-latest + test: + runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 + steps: + - uses: actions/checkout@v4 - # - name: Install dependencies - # run: sudo apt-get install -y build-essential gcc-multilib g++-multilib + - name: Install dependencies + run: sudo apt-get install -y build-essential gcc-multilib g++-multilib - # - name: Install gcovr - # run: pip install gcovr + - name: Install gcovr + run: pip install gcovr - # - name: Setup project - # run: cmake -S ${TEST_DIR} -B ${BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug + - name: Setup project + run: cmake -S ${TEST_DIR} -B ${BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug - # - name: Build - # run: cmake --build ${BUILD_DIR} + - name: Build + run: cmake --build ${BUILD_DIR} - # # - name: Test - # # working-directory: build - # # run: ctest -V + - name: Test + working-directory: build + run: ctest -V - # - name: Test with Coverage - # working-directory: build - # run: cmake --build ${BUILD_DIR} --target os_test_coverage + # - name: Test with Coverage + # working-directory: build + # run: cmake --build ${BUILD_DIR} --target os_test_coverage lint: runs-on: ubuntu-latest @@ -65,7 +65,7 @@ jobs: secrets: inherit needs: - # - test + - test - lint permissions: From e67efcfc1ee666b21117dcc40b06826f848e660e Mon Sep 17 00:00:00 2001 From: Thomas Harrison Date: Thu, 19 Mar 2026 20:49:06 -0400 Subject: [PATCH 7/8] Fix ci setup for tests --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e251a33..72215e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,10 +25,10 @@ jobs: run: pip install gcovr - name: Setup project - run: cmake -S ${TEST_DIR} -B ${BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug + run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug - name: Build - run: cmake --build ${BUILD_DIR} + run: cmake --build build - name: Test working-directory: build From 96a04da861dee148f7f302d1ca06b0a48c698ecf Mon Sep 17 00:00:00 2001 From: Thomas Harrison Date: Thu, 19 Mar 2026 20:50:26 -0400 Subject: [PATCH 8/8] Disable ci tests --- .github/workflows/ci.yml | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72215e8..3ac36c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,31 +12,32 @@ on: - synchronize jobs: - test: - runs-on: ubuntu-latest + # Tests disabled because ci doesn't have opengl, need to find a fix for that + # test: + # runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 + # steps: + # - uses: actions/checkout@v4 - - name: Install dependencies - run: sudo apt-get install -y build-essential gcc-multilib g++-multilib + # - name: Install dependencies + # run: sudo apt-get install -y build-essential gcc-multilib g++-multilib - - name: Install gcovr - run: pip install gcovr + # - name: Install gcovr + # run: pip install gcovr - - name: Setup project - run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug + # - name: Setup project + # run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug - - name: Build - run: cmake --build build + # - name: Build + # run: cmake --build build - - name: Test - working-directory: build - run: ctest -V + # - name: Test + # working-directory: build + # run: ctest -V - # - name: Test with Coverage - # working-directory: build - # run: cmake --build ${BUILD_DIR} --target os_test_coverage + # # - name: Test with Coverage + # # working-directory: build + # # run: cmake --build ${BUILD_DIR} --target os_test_coverage lint: runs-on: ubuntu-latest @@ -65,7 +66,7 @@ jobs: secrets: inherit needs: - - test + # - test - lint permissions: