Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ NamespaceIndentation: All
PenaltyBreakComment: 20
PenaltyExcessCharacter: 5
PointerAlignment: Middle
SortUsingDeclarations: false
SortUsingDeclarations: true
SpaceAfterTemplateKeyword: false
SpaceBeforeCpp11BracedList: true
SpacesBeforeTrailingComments: 1
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- synchronize

jobs:
# Tests disabled because ci doesn't have opengl, need to find a fix for that
# test:
# runs-on: ubuntu-latest

Expand All @@ -25,18 +26,18 @@ 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
# # run: ctest -V

# - name: Test with Coverage
# - name: Test
# working-directory: build
# run: cmake --build ${BUILD_DIR} --target os_test_coverage
# run: ctest -V

# # - name: Test with Coverage
# # working-directory: build
# # run: cmake --build ${BUILD_DIR} --target os_test_coverage

lint:
runs-on: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
]
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"cmake.ctest.testSuiteDelimiter": "\\.",
"cmake.ctest.testExplorerIntegrationEnabled": true
}
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright 2021 Thomas Harrison <automas-dev@vt.edu>
Copyright 2021 Thomas Harrison <theharrisoncrafter@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion external/glm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions external/gtest.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion include/glpp/Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <vector>

namespace glpp {
using std::vector;
using std::shared_ptr;
using std::vector;

/**
* A single array buffer.
Expand Down
2 changes: 1 addition & 1 deletion include/glpp/FrameBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "Texture.hpp"

namespace glpp {
using std::vector;
using std::shared_ptr;
using std::vector;

class RenderBuffer {
public:
Expand Down
2 changes: 1 addition & 1 deletion include/glpp/Shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion include/glpp/Texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <string>

namespace glpp {
using std::string;
using std::shared_ptr;
using std::string;

class TextureLoadException : public std::runtime_error {
public:
Expand Down
2 changes: 1 addition & 1 deletion include/glpp/extra/GeometryBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion include/glpp/extra/Vertex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/extra/Grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ void main() {
})";

namespace glpp::extra {
using std::vector;
using std::make_shared;
using std::vector;

void Grid::updateBuffer() {
vector<glm::vec3> vertices;
Expand Down
2 changes: 1 addition & 1 deletion src/extra/Line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ void main() {
})

namespace glpp::extra {
using std::vector;
using std::make_shared;
using std::vector;

void Line::updateBuffer() {
vector<glm::vec3> vertices = points;
Expand Down
2 changes: 1 addition & 1 deletion src/extra/Marker.cpp
Original file line number Diff line number Diff line change
@@ -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<glm::vec3> & points, const glm::vec4 & color)
: Transform(), line(make_shared<Line>(points, color, Line::Lines)) {}
Expand Down
41 changes: 17 additions & 24 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions tests/glmChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <glm/gtx/string_cast.hpp>
#include <ostream>

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) {
Expand Down
6 changes: 3 additions & 3 deletions tests/test_extra_Transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_glm_compare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions tests/test_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading