diff options
-rw-r--r-- | .clang-format | 2 | ||||
-rw-r--r-- | .dir-locals.el | 33 | ||||
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | CMakeLists.txt | 29 | ||||
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | docs/Doxyfile | 12 | ||||
-rw-r--r-- | docs/README.md | 2 | ||||
-rw-r--r-- | docs/matrix.dox | 33 | ||||
-rw-r--r-- | include/YAGE/Math/math.h (renamed from include/YAGE/Math/math.hpp) | 8 | ||||
-rw-r--r-- | include/YAGE/Math/matrix.h (renamed from include/YAGE/Math/matrix.hpp) | 159 | ||||
-rw-r--r-- | include/YAGE/Physics/body.h (renamed from include/YAGE/Physics/body.hpp) | 8 | ||||
-rw-r--r-- | include/YAGE/Physics/collider.h (renamed from include/YAGE/Physics/collider.hpp) | 6 | ||||
-rw-r--r-- | include/YAGE/Physics/collisionbody.h (renamed from include/YAGE/Physics/collisionbody.hpp) | 8 | ||||
-rw-r--r-- | include/YAGE/Physics/particlebody.h (renamed from include/YAGE/Physics/particlebody.hpp) | 13 | ||||
-rw-r--r-- | include/YAGE/Physics/physics.h (renamed from include/YAGE/Physics/physics.hpp) | 18 | ||||
-rw-r--r-- | include/YAGE/Physics/rectanglecollider.h (renamed from include/YAGE/Physics/rectanglecollider.hpp) | 10 | ||||
-rw-r--r-- | include/YAGE/Physics/rigidbody.h (renamed from include/YAGE/Physics/rigidbody.hpp) | 12 | ||||
-rw-r--r-- | include/YAGE/camera2d.h (renamed from include/YAGE/camera2d.hpp) | 12 | ||||
-rw-r--r-- | include/YAGE/glslprogram.h (renamed from include/YAGE/glslprogram.hpp) | 8 | ||||
-rw-r--r-- | include/YAGE/imageloader.h (renamed from include/YAGE/imageloader.hpp) | 10 | ||||
-rw-r--r-- | include/YAGE/inputmanager.h (renamed from include/YAGE/inputmanager.hpp) | 8 | ||||
-rw-r--r-- | include/YAGE/iomanager.h (renamed from include/YAGE/iomanager.hpp) | 8 | ||||
-rw-r--r-- | include/YAGE/picopng.h (renamed from include/YAGE/picopng.hpp) | 4 | ||||
-rw-r--r-- | include/YAGE/resourcemanager.h (renamed from include/YAGE/resourcemanager.hpp) | 12 | ||||
-rw-r--r-- | include/YAGE/sprite.h (renamed from include/YAGE/sprite.hpp) | 10 | ||||
-rw-r--r-- | include/YAGE/spritebatch.h (renamed from include/YAGE/spritebatch.hpp) | 8 | ||||
-rw-r--r-- | include/YAGE/texture.h (renamed from include/YAGE/texture.hpp) | 8 | ||||
-rw-r--r-- | include/YAGE/texturecache.h (renamed from include/YAGE/texturecache.hpp) | 10 | ||||
-rw-r--r-- | include/YAGE/vertex.h (renamed from include/YAGE/vertex.hpp) | 8 | ||||
-rw-r--r-- | include/YAGE/window.h (renamed from include/YAGE/window.hpp) | 6 | ||||
-rw-r--r-- | include/YAGE/yage.h | 63 | ||||
-rw-r--r-- | include/YAGE/yage.hpp | 35 | ||||
-rw-r--r-- | src/body.cpp | 16 | ||||
-rw-r--r-- | src/camera2d.cpp | 10 | ||||
-rw-r--r-- | src/glslprogram.cpp | 4 | ||||
-rw-r--r-- | src/imageloader.cpp | 8 | ||||
-rw-r--r-- | src/inputmanager.cpp | 14 | ||||
-rw-r--r-- | src/iomanager.cpp | 4 | ||||
-rw-r--r-- | src/particlebody.cpp | 9 | ||||
-rw-r--r-- | src/picopng.cpp | 26 | ||||
-rw-r--r-- | src/rectanglecollider.cpp | 4 | ||||
-rw-r--r-- | src/resourcemanager.cpp | 4 | ||||
-rw-r--r-- | src/rigidbody.cpp | 4 | ||||
-rw-r--r-- | src/sprite.cpp | 8 | ||||
-rw-r--r-- | src/spritebatch.cpp | 9 | ||||
-rw-r--r-- | src/texturecache.cpp | 6 | ||||
-rw-r--r-- | src/window.cpp | 10 | ||||
-rw-r--r-- | test/matrixtest.cpp | 29 | ||||
-rw-r--r-- | test/particlebodytest.cpp | 6 | ||||
-rw-r--r-- | test/windowtest.cpp | 10 | ||||
-rw-r--r-- | test/yagetest.cpp | 10 |
51 files changed, 428 insertions, 335 deletions
diff --git a/.clang-format b/.clang-format index 13ea9cc7..41283136 100644 --- a/.clang-format +++ b/.clang-format @@ -4,7 +4,9 @@ IndentWidth: 4 --- Language: Cpp AccessModifierOffset: -4 +AllowShortFunctionsOnASingleLine: Inline AlwaysBreakTemplateDeclarations: true BreakBeforeBraces: Linux +UseTab: Never ... diff --git a/.dir-locals.el b/.dir-locals.el index 7f49a89d..40c788b1 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,19 +1,14 @@ -((nil . ((company-clang-arguments . ("-I../include/YAGE/" - "-I../../include/YAGE/" - "-I../../../include/YAGE/" - "-I/usr/include/" - "-I/usr/include/SDL2/" - "-I../googletest/googletest/include/")) - (company-c-headers-path-user . ("../include/YAGE/" - "../../include/YAGE/" - "../../../include/YAGE/" - "/usr/include/" - "/usr/include/SDL2/" - "../googletest/googletest/include/")) - (flycheck-clang-include-path . ("../include/YAGE/" - "../../include/YAGE/" - "../../../include/YAGE/" - "/usr/include/" - "/usr/include/SDL2/" - "../googletest/googletest/include"))))) - +((nil . ((eval . (progn + (require 'projectile) + (setq company-clang-arguments (delete-dups (append + company-clang-arguments + (list (concat "-I" (projectile-project-root) "include"))))) + (setq company-clang-arguments (delete-dups (append + company-clang-arguments + (list (concat "-I" (projectile-project-root) "googletest/googletest/include"))))) + (setq flycheck-clang-include-path (delete-dups (append + flycheck-clang-include-path + (list (concat (projectile-project-root) "include"))))) + (setq flycheck-clang-include-path (delete-dups (append + flycheck-clang-include-path + (list (concat (projectile-project-root) "googletest/googletest/include")))))))))) @@ -5,6 +5,9 @@ build_* CMakeFiles Testing +# specific directory to ignore +/html + # extensions to ignore *.o *.out diff --git a/CMakeLists.txt b/CMakeLists.txt index b92ec79a..5bc84149 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,9 +13,9 @@ project(yage) # set version numbers set(YAGE_MAJOR_VERSION 0) set(YAGE_MINOR_VERSION 1) -set(YAGE_PATCH_VERSION 2) +set(YAGE_PATCH_VERSION 1) set(YAGE_VERSION - ${YAGE_MAJOR_VERSION}.${YAGE_MINOR_VERSION}${YAGE_PATCH_VERSION}) + "v${YAGE_MAJOR_VERSION}.${YAGE_MINOR_VERSION}.${YAGE_PATCH_VERSION}") # set standard set(CMAKE_CXX_STANDARD 14) @@ -26,7 +26,7 @@ set(YAGE_TEST_DIR ${PROJECT_SOURCE_DIR}/test) set(YAGE_LIBRARIES yage) # add include directory -set(YAGE_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include/YAGE) +set(YAGE_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include) # set binary directory set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) @@ -84,18 +84,13 @@ message("${YAGE_LIB_DEP_L}") enable_testing() set(SIMULATION_RUNS 1000) -add_executable(yagetest ${YAGE_TEST_DIR}/yagetest.cpp) -target_link_libraries(yagetest gtest_main ${YAGE_LIB_DEP_L}) -add_test(NAME Yagetest COMMAND yagetest --gtest_repeat=${SIMULATION_RUNS} --gtest_break_on_failure) +function(make_test test_name cycles) + add_executable(${test_name} ${YAGE_TEST_DIR}/${test_name}.cpp) + target_link_libraries(${test_name} gtest_main ${YAGE_LIB_DEP_L}) + add_test(NAME ${test_name} COMMAND ${test_name} --gtest_repeat=${cycles} --gtest_break_on_failure) +endfunction(make_test) -add_executable(matrixtest ${YAGE_TEST_DIR}/matrixtest.cpp) -target_link_libraries(matrixtest gtest_main ${YAGE_LIB_DEP_L}) -add_test(NAME MatrixTest COMMAND matrixtest --gtest_repeat=${SIMULATION_RUNS} --gtest_break_on_failure) - -add_executable(particlebodytest ${YAGE_TEST_DIR}/particlebodytest.cpp) -target_link_libraries(particlebodytest gtest_main ${YAGE_LIB_DEP_L}) -add_test(NAME ParticleBodyTest COMMAND particlebodytest --gtest_repeat=${SIMULATION_RUNS} --gtest_break_on_failure) - -add_executable(windowtest ${YAGE_TEST_DIR}/windowtest.cpp) -target_link_libraries(windowtest gtest_main ${YAGE_LIB_DEP_L}) -add_test(NAME Windowtest COMMAND windowtest --gtest_repeat=${SIMULATION_RUNS} --gtest_break_on_failure) +make_test(yagetest 10) +make_test(matrixtest ${SIMULATION_RUNS}) +make_test(particlebodytest ${SIMULATION_RUNS}) +make_test(windowtest ${SIMULATION_RUNS}) @@ -1,4 +1,4 @@ -YAGE +YAGE {#mainpage} ==== Introduction @@ -8,11 +8,13 @@ YAGE stands for Yet Another Game Engine. It is a game engine that I am developing for a game called [Arider](https://github.com/ymherklotz/Arider). It uses OpenGL and SDL2 for the window creation and management and graphics. +The full documentation can be seen [here](https://www.yannherklotz.com/YAGE). + Installation and usage ---------------------- To use YAGE for your own game, you should link it as a static library and -include the [yage.hpp](/include/YAGE/yage.hpp) header in your project. +include the [yage.h](/include/YAGE/yage.h) header in your project. Build and Testing ----------------- diff --git a/docs/Doxyfile b/docs/Doxyfile index da9cc78b..29c50bdd 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "YAGE" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 0.02 +PROJECT_NUMBER = v0.1.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a @@ -790,7 +790,10 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = +INPUT = docs \ + src \ + include \ + README.md # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -873,7 +876,7 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = +EXCLUDE = docs/README.md # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -889,8 +892,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = */googletest/* \ - */build/* +EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/docs/README.md b/docs/README.md index ce85d85f..f39d0f8e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,4 +1,4 @@ Documentation -================ +============= Visit this [page](https://www.yannherklotz.com/YAGE) for the documentation. diff --git a/docs/matrix.dox b/docs/matrix.dox new file mode 100644 index 00000000..c1c99dde --- /dev/null +++ b/docs/matrix.dox @@ -0,0 +1,33 @@ +/** @class yage::Matrix + +%Matrix Class +============ + +The matrix class is a templated class which implements a mathematical %Matrix. + + +Usage Guide +----------- + +The class can be instantiated + + +Example Code +------------ + +Creating a %Matrix and performing operations on it. + +``` +#include <YAGE/Math/matrix.hpp> + +int main(int, char **) +{ + yage::Matrix<2, 2, int> mat1 {{1, 2, 3, 4}}; + yage::Matrix<2, 2, int> mat2 {{5, 6, 7, 8}}; + + int dot = yage::math::dot(mat1, mat2); + return 0; +} +``` + +*/ diff --git a/include/YAGE/Math/math.hpp b/include/YAGE/Math/math.h index b587cf9f..b729dbe6 100644 --- a/include/YAGE/Math/math.hpp +++ b/include/YAGE/Math/math.h @@ -1,14 +1,14 @@ /* ---------------------------------------------------------------------------- - * math.hpp + * math.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef YAGE_MATH_HPP -#define YAGE_MATH_HPP +#ifndef YAGE_MATH_H +#define YAGE_MATH_H -#include "matrix.hpp" +#include "matrix.h" #endif diff --git a/include/YAGE/Math/matrix.hpp b/include/YAGE/Math/matrix.h index 249edcc7..3992acfe 100644 --- a/include/YAGE/Math/matrix.hpp +++ b/include/YAGE/Math/matrix.h @@ -1,25 +1,16 @@ /* ---------------------------------------------------------------------------- - * matrix.hpp + * matrix.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -/// @file - -/** Templated matrix class - * - * Matrix - * ====== - * - * This is a very general matrix class that can then be inherited by - * vectors and other similar data structures to minimize code - * density. +/** @file */ -#ifndef YAGE_MATH_MATRIX_HPP -#define YAGE_MATH_MATRIX_HPP +#ifndef YAGE_MATH_MATRIX_H +#define YAGE_MATH_MATRIX_H #include <algorithm> #include <exception> @@ -31,27 +22,29 @@ namespace yage { -template <int Rows, int Cols, class Type> class Matrix; +template <int Rows, int Cols, class Type> +class Matrix; /** @internal Namespace for internal details. - * - * Detail Namespace - * ================ - * - * This is the namespace used for implementation detail. - */ + * + * Detail Namespace + * ================ + * + * This is the namespace used for implementation detail. + */ namespace detail { /** @internal Internal Row class used by the Matrix class to return the - * internal data structure of the Matrix. - * - * Row - * === - * - * Internal Row class to return a value in the row of the matrix. - */ -template <int Rows, int Cols, class Type> class Row + * internal data structure of the Matrix. + * + * Row + * === + * + * Internal Row class to return a value in the row of the matrix. + */ +template <int Rows, int Cols, class Type> +class Row { private: Matrix<Rows, Cols, Type> *parent_; @@ -65,7 +58,7 @@ public: Type &operator[](int col) { - // the index is the y-position of the element in the matrix + // The index is the y-position of the element in the matrix return parent_->data_[index_ * Cols + col]; } @@ -75,42 +68,36 @@ public: } }; -} // detail +} // namespace detail /** Base Matrix class used by other similar classes. - * - * Matrix class - * ============ - * - * This is the base matrix class that can be used by all the other matrix - * like data structures. - */ -template <int Rows = 4, int Cols = 4, class Type = double> class Matrix + */ +template <int Rows = 4, int Cols = 4, class Type = double> +class Matrix { - // friended with the row class so that it can access protected member data + // friended with the row class so that it can access protected member data. friend class detail::Row<Rows, Cols, Type>; protected: - /// Vector containing the data of the matrix + /// Vector containing the data of the matrix. std::vector<Type> data_; public: - /// Initializes the size of the data_ vector + /// Initializes the size of the data_ vector. Matrix<Rows, Cols, Type>() : data_(Rows * Cols) {} Matrix<Rows, Cols, Type>(const std::vector<Type> &data) : data_(data) {} - /// Returns the row size of the Matrix + /// Returns the row size of the Matrix. int rowSize() const { return Rows; } - /// Returns the column size of the Matrixxs + /// Returns the column size of the Matrix. int colSize() const { return Cols; } - /** Return the row specified row as a Matrix with only one row - * - * @param row Row number to be returned - * - * Returns the row that is specified by the row variables. - */ + /** Return the row specified row as a Matrix with only one row. + * + * @param row Row number to be returned. + * @return The row that is specified by the row variables. + */ Matrix<1, Cols, Type> getRow(int row) const { Matrix<1, Cols, Type> rowMatrix; @@ -120,7 +107,11 @@ public: return rowMatrix; } - // returns the column in a column matrix + /** Get a specific column in a column vector. + * + * @param col Column number to be returned. + * @return Column Matrix of the selected column. + */ Matrix<Rows, 1, Type> getCol(int col) const { Matrix<Rows, 1, Type> colMatrix; @@ -130,15 +121,24 @@ public: return colMatrix; } - /// iterator support for begin + /** Iterator support for the start. + * + * @return Iterator pointing to the start of the data. + */ typename std::vector<Type>::iterator begin() { return data_.begin(); } - /// iterator support for end + /** Iterator support for the end. + * + * @return Iterator pointing to the end of the data. + */ typename std::vector<Type>::iterator end() { return data_.end(); } - /** prints out the matrix, but can also be implemented by other classes to - * print data differently - */ + /** Prints out the matrix, but can also be implemented by other classes to + * print data differently. + * + * @bug When printing certain matrices, it omits a row or column. Still + * need to determine under which conditions. + */ virtual std::string toString() const { std::stringstream ss; @@ -165,7 +165,6 @@ public: detail::Row<Rows, Cols, Type> operator[](int row) const { - // @todo got to fix this return detail::Row<Rows, Cols, Type>((Matrix<Rows, Cols, Type> *)this, row); } @@ -298,6 +297,7 @@ public: : Matrix<Rows, 1, Type>(other) { } + Vector<Rows, Type>(const std::vector<Type> &data) : Matrix<Rows, 1, Type>(data) { @@ -320,10 +320,11 @@ public: }; /** 2D Vector class. - * - * Two dimensional vector class. - */ -template <class Type = double> class Vector2 : public Vector<2, Type> + * + * Two dimensional vector class. + */ +template <class Type = double> +class Vector2 : public Vector<2, Type> { public: Vector2<Type>() : Vector<2, Type>() {} @@ -346,17 +347,22 @@ public: const Type &y() const { return this->data_[1]; } }; -/// Definition of a 2D vector. +/** Definition of a 2D vector. + */ using Vector2d = Vector2<double>; -/** Namespace containing functions that operate on matrices. */ +/** Namespace containing functions that operate on matrices. + * + * Implementations defined here are meant to operate on anything that inherits + * from the base Matrix class. + */ namespace matrix { /** Transposes a matrix and returns the result -* -* \param[in] m input matrix. -*/ + * + * @param m input matrix. + */ template <int M, int N, class T> Matrix<N, M, T> transpose(const Matrix<M, N, T> &m) { @@ -370,9 +376,9 @@ Matrix<N, M, T> transpose(const Matrix<M, N, T> &m) } /** Returns the dot product between two vectors -* -* \param[in] m1,m2 Input matrices. -*/ + * + * @param m1,m2 Input matrices. + */ template <int R, class T> T dot(const Matrix<R, 1, T> &m1, const Matrix<R, 1, T> &m2) { @@ -384,14 +390,15 @@ T dot(const Matrix<R, 1, T> &m1, const Matrix<R, 1, T> &m2) } /** Multiplies two matrices together. -* -* \param[in] m1,m2 Matrix inputs -* -* Requires the two matrices to be compatible with multiplication. -*/ + * + * @param m1,m2 Matrix inputs + * + * Requires the two matrices to be compatible with multiplication. + */ template <int M, int N, int P, int Q, class T> Matrix<M, Q, T> multiply(const Matrix<M, N, T> &m1, const Matrix<P, Q, T> &m2) { + /// @todo Think if this should be a static_assert. if (N != P) { throw std::runtime_error( "Matrices don't have the right dimensions for multiplication"); @@ -399,6 +406,8 @@ Matrix<M, Q, T> multiply(const Matrix<M, N, T> &m1, const Matrix<P, Q, T> &m2) Matrix<M, Q, T> res; + /// Performs multiplication by getting the rows and columns, transposing + /// one of them and then doting the result. for (int i = 0; i < M; ++i) { for (int j = 0; j < Q; ++j) { res[i][j] = dot(transpose(m1.getRow(i)), m2.getCol(j)); @@ -408,8 +417,8 @@ Matrix<M, Q, T> multiply(const Matrix<M, N, T> &m1, const Matrix<P, Q, T> &m2) return res; } -} // matrix +} // namespace matrix -} // yage +} // namespace yage #endif diff --git a/include/YAGE/Physics/body.hpp b/include/YAGE/Physics/body.h index c67d2b12..bd33a9ac 100644 --- a/include/YAGE/Physics/body.hpp +++ b/include/YAGE/Physics/body.h @@ -1,15 +1,15 @@ /* ---------------------------------------------------------------------------- - * body.hpp + * body.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef YAGE_PHYSICS_BODY_HPP -#define YAGE_PHYSICS_BODY_HPP +#ifndef YAGE_PHYSICS_BODY_H +#define YAGE_PHYSICS_BODY_H -#include "Math/matrix.hpp" +#include <YAGE/Math/matrix.h> namespace yage { diff --git a/include/YAGE/Physics/collider.hpp b/include/YAGE/Physics/collider.h index 7b4ff060..2fd2ff89 100644 --- a/include/YAGE/Physics/collider.hpp +++ b/include/YAGE/Physics/collider.h @@ -1,13 +1,13 @@ /* ---------------------------------------------------------------------------- - * collider.hpp + * collider.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef YAGE_PHYSICS_COLLIDER_HPP -#define YAGE_PHYSICS_COLLIDER_HPP +#ifndef YAGE_PHYSICS_COLLIDER_H +#define YAGE_PHYSICS_COLLIDER_H #include <glm/glm.hpp> diff --git a/include/YAGE/Physics/collisionbody.hpp b/include/YAGE/Physics/collisionbody.h index b7403e81..715c4a54 100644 --- a/include/YAGE/Physics/collisionbody.hpp +++ b/include/YAGE/Physics/collisionbody.h @@ -1,15 +1,15 @@ /* ---------------------------------------------------------------------------- - * collisionbody.hpp + * collisionbody.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef YAGE_COLLISION_BODY_HPP -#define YAGE_COLLISION_BODY_HPP +#ifndef YAGE_COLLISION_BODY_H +#define YAGE_COLLISION_BODY_H -#include "Physics/body.hpp" +#include "body.h" namespace yage { diff --git a/include/YAGE/Physics/particlebody.hpp b/include/YAGE/Physics/particlebody.h index a3091773..a0b9bdad 100644 --- a/include/YAGE/Physics/particlebody.hpp +++ b/include/YAGE/Physics/particlebody.h @@ -1,16 +1,17 @@ /* ---------------------------------------------------------------------------- - * particlebody.hpp + * particlebody.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef YAGE_PHYSICS_PARTICLE_BODY_HPP -#define YAGE_PHYSICS_PARTICLE_BODY_HPP +#ifndef YAGE_PHYSICS_PARTICLE_BODY_H +#define YAGE_PHYSICS_PARTICLE_BODY_H -#include "Math/matrix.hpp" -#include "Physics/body.hpp" +#include "body.h" + +#include <YAGE/Math/matrix.h> namespace yage { @@ -27,6 +28,6 @@ public: void update() override; }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/Physics/physics.hpp b/include/YAGE/Physics/physics.h index 8146672a..900f4b6a 100644 --- a/include/YAGE/Physics/physics.hpp +++ b/include/YAGE/Physics/physics.h @@ -1,19 +1,19 @@ /* ---------------------------------------------------------------------------- - * physics.hpp + * physics.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef YAGE_PHYSICS_HPP -#define YAGE_PHYSICS_HPP +#ifndef YAGE_PHYSICS_H +#define YAGE_PHYSICS_H -#include "body.hpp" -#include "collider.hpp" -#include "collisionbody.hpp" -#include "particlebody.hpp" -#include "rectanglecollider.hpp" -#include "rigidbody.hpp" +#include "body.h" +#include "collider.h" +#include "collisionbody.h" +#include "particlebody.h" +#include "rectanglecollider.h" +#include "rigidbody.h" #endif diff --git a/include/YAGE/Physics/rectanglecollider.hpp b/include/YAGE/Physics/rectanglecollider.h index ba1d8384..c009f665 100644 --- a/include/YAGE/Physics/rectanglecollider.hpp +++ b/include/YAGE/Physics/rectanglecollider.h @@ -1,15 +1,15 @@ /* ---------------------------------------------------------------------------- - * rectanglecollider.hpp + * rectanglecollider.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef YAGE_RECTANGLE_COLLIDER_HPP -#define YAGE_RECTANGLE_COLLIDER_HPP +#ifndef YAGE_RECTANGLE_COLLIDER_H +#define YAGE_RECTANGLE_COLLIDER_H -#include "Physics/collider.hpp" +#include "collider.h" #include <glm/glm.hpp> @@ -25,6 +25,6 @@ public: bool inside(const glm::vec2 &point) const override; }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/Physics/rigidbody.hpp b/include/YAGE/Physics/rigidbody.h index 6fc969f5..67ccb4ca 100644 --- a/include/YAGE/Physics/rigidbody.hpp +++ b/include/YAGE/Physics/rigidbody.h @@ -1,17 +1,17 @@ /* ---------------------------------------------------------------------------- - * rigidbody.hpp + * rigidbody.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef YAGE_RIGID_BODY_HPP -#define YAGE_RIGID_BODY_HPP +#ifndef YAGE_RIGID_BODY_H +#define YAGE_RIGID_BODY_H -#include <glm/glm.hpp> +#include "particlebody.h" -#include "particlebody.hpp" +#include <glm/glm.hpp> namespace yage { @@ -23,6 +23,6 @@ public: const Vector2d &velocity = Vector2d(0, 0), bool gravity = true); }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/camera2d.hpp b/include/YAGE/camera2d.h index 89f2f35c..a50544a4 100644 --- a/include/YAGE/camera2d.hpp +++ b/include/YAGE/camera2d.h @@ -1,15 +1,15 @@ /* ---------------------------------------------------------------------------- - * camera2d.hpp + * camera2d.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> * MIT License, see LICENSE file for more details. * ---------------------------------------------------------------------------- */ -#ifndef CAMERA_2D_HPP -#define CAMERA_2D_HPP +#ifndef CAMERA_2D_H +#define CAMERA_2D_H -#include "glslprogram.hpp" +#include "glslprogram.h" #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> @@ -20,7 +20,7 @@ namespace yage class Camera2D { private: - bool matrix_needs_update_ = true; + bool update_matrix_ = true; float scale_ = 1; glm::vec2 position_; glm::mat4 camera_matrix_; @@ -35,6 +35,6 @@ public: void move(const glm::vec2 &direction); }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/glslprogram.hpp b/include/YAGE/glslprogram.h index eaa19c52..fbe5ac5c 100644 --- a/include/YAGE/glslprogram.hpp +++ b/include/YAGE/glslprogram.h @@ -1,13 +1,13 @@ /* ---------------------------------------------------------------------------- - * glslprogram.hpp + * glslprogram.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef GLSL_PROGRAM_HPP -#define GLSL_PROGRAM_HPP +#ifndef GLSL_PROGRAM_H +#define GLSL_PROGRAM_H #include <GL/glew.h> @@ -47,6 +47,6 @@ public: void unuse(); }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/imageloader.hpp b/include/YAGE/imageloader.h index a9c00c4b..8d5c5cd1 100644 --- a/include/YAGE/imageloader.hpp +++ b/include/YAGE/imageloader.h @@ -1,15 +1,15 @@ /* ---------------------------------------------------------------------------- - * imageloader.hpp + * imageloader.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef IMAGE_LOADER_HPP -#define IMAGE_LOADER_HPP +#ifndef IMAGE_LOADER_H +#define IMAGE_LOADER_H -#include "texture.hpp" +#include "texture.h" #include <string> @@ -22,6 +22,6 @@ public: static Texture loadPng(const std::string &file_path); }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/inputmanager.hpp b/include/YAGE/inputmanager.h index 0d5c65e7..84728fff 100644 --- a/include/YAGE/inputmanager.hpp +++ b/include/YAGE/inputmanager.h @@ -1,13 +1,13 @@ /* ---------------------------------------------------------------------------- - * inputmanager.hpp + * inputmanager.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef INPUT_MANAGER_HPP -#define INPUT_MANAGER_HPP +#ifndef INPUT_MANAGER_H +#define INPUT_MANAGER_H #include <unordered_map> @@ -24,5 +24,5 @@ public: void keyReleased(unsigned key); bool isKeyPressed(unsigned key) const; }; -} +} // namespace yage #endif diff --git a/include/YAGE/iomanager.hpp b/include/YAGE/iomanager.h index 35f77e43..95abd652 100644 --- a/include/YAGE/iomanager.hpp +++ b/include/YAGE/iomanager.h @@ -1,13 +1,13 @@ /* ---------------------------------------------------------------------------- - * iomanager.hpp + * iomanager.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef IO_MANAGER_HPP -#define IO_MANAGER_HPP +#ifndef IO_MANAGER_H +#define IO_MANAGER_H #include <string> #include <vector> @@ -22,6 +22,6 @@ public: std::vector<unsigned char> &buffer); }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/picopng.hpp b/include/YAGE/picopng.h index ded8ffa1..095bf68a 100644 --- a/include/YAGE/picopng.hpp +++ b/include/YAGE/picopng.h @@ -1,5 +1,5 @@ /* ---------------------------------------------------------------------------- - * picopng.hpp + * picopng.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details @@ -17,4 +17,4 @@ extern int decodePNG(std::vector<unsigned char> &out_image, const unsigned char *in_png, size_t in_size, bool convert_to_rgba32 = true); -} // yage +} // namespace yage diff --git a/include/YAGE/resourcemanager.hpp b/include/YAGE/resourcemanager.h index 38587dfc..3c5081c4 100644 --- a/include/YAGE/resourcemanager.hpp +++ b/include/YAGE/resourcemanager.h @@ -1,16 +1,16 @@ /* ---------------------------------------------------------------------------- - * resourcemanager.hpp + * resourcemanager.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef RESOURCE_MANAGER_HPP -#define RESOURCE_MANAGER_HPP +#ifndef RESOURCE_MANAGER_H +#define RESOURCE_MANAGER_H -#include "texture.hpp" -#include "texturecache.hpp" +#include "texture.h" +#include "texturecache.h" #include <string> @@ -26,6 +26,6 @@ public: static Texture getTexture(const std::string &texture_path); }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/sprite.hpp b/include/YAGE/sprite.h index 4b5f2489..0f5a0b8a 100644 --- a/include/YAGE/sprite.hpp +++ b/include/YAGE/sprite.h @@ -1,15 +1,15 @@ /* ---------------------------------------------------------------------------- - * sprite.hpp + * sprite.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef SPRITE_HPP -#define SPRITE_HPP +#ifndef SPRITE_H +#define SPRITE_H -#include "texture.hpp" +#include "texture.h" #include <GL/glew.h> @@ -42,6 +42,6 @@ public: void draw(); }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/spritebatch.hpp b/include/YAGE/spritebatch.h index add58b43..7235bd25 100644 --- a/include/YAGE/spritebatch.hpp +++ b/include/YAGE/spritebatch.h @@ -1,15 +1,15 @@ /* ---------------------------------------------------------------------------- - * spritebatch.hpp + * spritebatch.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef YAGE_SPRITE_BATCH_HPP -#define YAGE_SPRITE_BATCH_HPP +#ifndef YAGE_SPRITE_BATCH_H +#define YAGE_SPRITE_BATCH_H -#include "vertex.hpp" +#include "vertex.h" #include <GL/glew.h> #include <glm/glm.hpp> diff --git a/include/YAGE/texture.hpp b/include/YAGE/texture.h index b5fe7acd..d1fdcbf2 100644 --- a/include/YAGE/texture.hpp +++ b/include/YAGE/texture.h @@ -1,13 +1,13 @@ /* ---------------------------------------------------------------------------- - * texture.hpp + * texture.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef GL_TEXTURE_HPP -#define GL_TEXTURE_HPP +#ifndef GL_TEXTURE_H +#define GL_TEXTURE_H #include <GL/glew.h> @@ -20,6 +20,6 @@ struct Texture { int height; }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/texturecache.hpp b/include/YAGE/texturecache.h index 9765b919..414c9ec3 100644 --- a/include/YAGE/texturecache.hpp +++ b/include/YAGE/texturecache.h @@ -1,15 +1,15 @@ /* ---------------------------------------------------------------------------- - * texturecache.hpp + * texturecache.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef TEXTURE_CACHE_HPP -#define TEXTURE_CACHE_HPP +#ifndef TEXTURE_CACHE_H +#define TEXTURE_CACHE_H -#include "texture.hpp" +#include "texture.h" #include <unordered_map> @@ -27,6 +27,6 @@ public: Texture getTexture(const std::string &texture_path); }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/vertex.hpp b/include/YAGE/vertex.h index 9201393b..15b46ed9 100644 --- a/include/YAGE/vertex.hpp +++ b/include/YAGE/vertex.h @@ -1,13 +1,13 @@ /* ---------------------------------------------------------------------------- - * vertex.hpp + * vertex.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef VERTEX_HPP -#define VERTEX_HPP +#ifndef VERTEX_H +#define VERTEX_H #include <GL/glew.h> @@ -79,6 +79,6 @@ struct Vertex { } }; -} // yage +} // namespace yage #endif diff --git a/include/YAGE/window.hpp b/include/YAGE/window.h index 51b217f8..8639e075 100644 --- a/include/YAGE/window.hpp +++ b/include/YAGE/window.h @@ -1,13 +1,13 @@ /* ---------------------------------------------------------------------------- - * window.hpp + * window.h * * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License * See file LICENSE for more details * ---------------------------------------------------------------------------- */ -#ifndef WINDOW_HPP -#define WINDOW_HPP +#ifndef WINDOW_H +#define WINDOW_H #include <SDL2/SDL.h> diff --git a/include/YAGE/yage.h b/include/YAGE/yage.h new file mode 100644 index 00000000..6157e6bf --- /dev/null +++ b/include/YAGE/yage.h @@ -0,0 +1,63 @@ +/* ---------------------------------------------------------------------------- + * yage.h + * + * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License + * See file LICENSE for more details + * ---------------------------------------------------------------------------- + */ + +/** @file Includes all the headers in the main YAGE project. + * + * This does not include + */ + +#ifndef YAGE_YAGE_H +#define YAGE_YAGE_H + +#include "camera2d.h" +#include "glslprogram.h" +#include "imageloader.h" +#include "inputmanager.h" +#include "iomanager.h" +#include "picopng.h" +#include "resourcemanager.h" +#include "spritebatch.h" +#include "texture.h" +#include "vertex.h" +#include "window.h" + +#include <SDL2/SDL.h> + +#include <stdexcept> + +/** Project namespace. + * + * Avoids collision as all the classes and global functions are wrapped in. + * it. + */ +namespace yage +{ + +/** Initializes YAGE. + * + * This is only there to initialize SDL2. + * + * @return Returns true if the initialization was successful. + */ +bool init() +{ + return SDL_Init(SDL_INIT_VIDEO); +} + +/** Quit and cleanup YAGE + * + * SDL2 needs to clean itself up. + */ +void quit() +{ + SDL_Quit(); +} + +} // namespace yage + +#endif diff --git a/include/YAGE/yage.hpp b/include/YAGE/yage.hpp deleted file mode 100644 index b426eed9..00000000 --- a/include/YAGE/yage.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* ---------------------------------------------------------------------------- - * yage.hpp - * - * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License - * See file LICENSE for more details - * ---------------------------------------------------------------------------- - */ - -#ifndef YAGE_HPP -#define YAGE_HPP - -#include "camera2d.hpp" -#include "glslprogram.hpp" -#include "imageloader.hpp" -#include "inputmanager.hpp" -#include "iomanager.hpp" -#include "picopng.hpp" -#include "resourcemanager.hpp" -#include "spritebatch.hpp" -#include "texture.hpp" -#include "vertex.hpp" -#include "window.hpp" - -#include <SDL2/SDL.h> - -#include <stdexcept> - -namespace yage -{ - -bool init() { return SDL_Init(SDL_INIT_VIDEO); } -void quit() { SDL_Quit(); } -}; - -#endif diff --git a/src/body.cpp b/src/body.cpp index 96d01c22..8d38e70a 100644 --- a/src/body.cpp +++ b/src/body.cpp @@ -6,18 +6,24 @@ * ---------------------------------------------------------------------------- */ -#include <utility> +#include <YAGE/Physics/body.h> -#include "Physics/body.hpp" +#include <utility> namespace yage { const double Body::GRAVITY = -9.81; -double Body::xPosition() const { return position_[0]; } +double Body::xPosition() const +{ + return position_[0]; +} -double Body::yPosition() const { return position_[1]; } +double Body::yPosition() const +{ + return position_[1]; +} Body::Body(Vector2d position, double mass, Vector2d velocity, bool gravity) : position_(std::move(position)), mass_(mass), @@ -25,4 +31,4 @@ Body::Body(Vector2d position, double mass, Vector2d velocity, bool gravity) { } -} // yage +} // namespace yage diff --git a/src/camera2d.cpp b/src/camera2d.cpp index 9f210ddc..292f998a 100644 --- a/src/camera2d.cpp +++ b/src/camera2d.cpp @@ -6,7 +6,7 @@ * ---------------------------------------------------------------------------- */ -#include "camera2d.hpp" +#include <YAGE/camera2d.h> #include <GL/glew.h> @@ -22,14 +22,14 @@ Camera2D::Camera2D(int screen_width, int screen_height) void Camera2D::update(GlslProgram &program) { - if (matrix_needs_update_) { + if (update_matrix_) { glm::vec3 translate(-position_.x, -position_.y, 0.f); glm::vec3 scale(scale_, scale_, 0.f); camera_matrix_ = glm::translate(ortho_matrix_, translate); camera_matrix_ = glm::scale(glm::mat4(1.f), scale) * camera_matrix_; - matrix_needs_update_ = false; + update_matrix_ = false; } GLint matrix_location = program.getUniformLocation("P"); @@ -39,7 +39,7 @@ void Camera2D::update(GlslProgram &program) void Camera2D::move(const glm::vec2 &direction) { position_ += direction; - matrix_needs_update_ = true; + update_matrix_ = true; } -} // yage +} // namespace yage diff --git a/src/glslprogram.cpp b/src/glslprogram.cpp index d77f373d..11a3191e 100644 --- a/src/glslprogram.cpp +++ b/src/glslprogram.cpp @@ -6,7 +6,7 @@ * ---------------------------------------------------------------------------- */ -#include "glslprogram.hpp" +#include <YAGE/glslprogram.h> #include <fstream> #include <stdexcept> @@ -159,4 +159,4 @@ void GlslProgram::unuse() glUseProgram(0); } -} // yage +} // namespace yage diff --git a/src/imageloader.cpp b/src/imageloader.cpp index 95c73021..812110d8 100644 --- a/src/imageloader.cpp +++ b/src/imageloader.cpp @@ -6,9 +6,9 @@ * ---------------------------------------------------------------------------- */ -#include "imageloader.hpp" -#include "iomanager.hpp" -#include "picopng.hpp" +#include <YAGE/imageloader.h> +#include <YAGE/iomanager.h> +#include <YAGE/picopng.h> #include <stdexcept> @@ -57,4 +57,4 @@ Texture ImageLoader::loadPng(const std::string &file_path) return texture; } -} // yage +} // namespace yage diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index cbb9d2df..d429abd7 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -6,14 +6,20 @@ * ---------------------------------------------------------------------------- */ -#include "inputmanager.hpp" +#include <YAGE/inputmanager.h> namespace yage { -void InputManager::keyPressed(unsigned key) { key_map_[key] = true; } +void InputManager::keyPressed(unsigned key) +{ + key_map_[key] = true; +} -void InputManager::keyReleased(unsigned key) { key_map_[key] = false; } +void InputManager::keyReleased(unsigned key) +{ + key_map_[key] = false; +} bool InputManager::isKeyPressed(unsigned key) const { @@ -24,4 +30,4 @@ bool InputManager::isKeyPressed(unsigned key) const return false; } -} // yage +} // namespace yage diff --git a/src/iomanager.cpp b/src/iomanager.cpp index 60cd7201..93ab41c9 100644 --- a/src/iomanager.cpp +++ b/src/iomanager.cpp @@ -6,7 +6,7 @@ * ---------------------------------------------------------------------------- */ -#include "iomanager.hpp" +#include <YAGE/iomanager.h> #include <fstream> #include <stdexcept> @@ -39,4 +39,4 @@ bool IoManager::readFileToBuffer(const std::string &file_path, return true; } -} // yage +} // namespace yage diff --git a/src/particlebody.cpp b/src/particlebody.cpp index 20682368..bdb81eac 100644 --- a/src/particlebody.cpp +++ b/src/particlebody.cpp @@ -6,7 +6,7 @@ * ---------------------------------------------------------------------------- */ -#include "Physics/particlebody.hpp" +#include <YAGE/Physics/particlebody.h> #include <cmath> #include <iostream> @@ -20,7 +20,10 @@ ParticleBody::ParticleBody(const Vector2d &position, double mass, { } -void ParticleBody::applyForce(const Vector2d &force) { force_ += force; } +void ParticleBody::applyForce(const Vector2d &force) +{ + force_ += force; +} void ParticleBody::update() { @@ -48,4 +51,4 @@ void ParticleBody::update() velocity_ += avg_acceleration * time_step; } -} // yage +} // namespace yage diff --git a/src/picopng.cpp b/src/picopng.cpp index 337038ba..dcc4b367 100644 --- a/src/picopng.cpp +++ b/src/picopng.cpp @@ -366,7 +366,7 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, error = 16; return; } // error: somehow an unexisting code appeared. This can - // never happen. + // never happen. } if (bitlen[256] == 0) { error = 64; @@ -493,17 +493,17 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, if ((in[0] * 256 + in[1]) % 31 != 0) { return 24; } // error: 256 * in[0] + in[1] must be a multiple of 31, the - // FCHECK value is supposed to be made that way + // FCHECK value is supposed to be made that way unsigned long CM = in[0] & 15, CINFO = (in[0] >> 4) & 15, FDICT = (in[1] >> 5) & 1; if (CM != 8 || CINFO > 7) { return 25; } // error: only compression method 8: inflate with sliding window - // of 32k is supported by the PNG spec + // of 32k is supported by the PNG spec if (FDICT != 0) { return 26; } // error: the specification of PNG says about the zlib stream: - // "The additional flags shall not specify a preset dictionary." + // "The additional flags shall not specify a preset dictionary." inflator.inflate(out, in, 2); return inflator .error; // note: adler32 checksum was skipped and ignored @@ -542,7 +542,7 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, error = 30; return; } // error: size of the in buffer too small to contain next - // chunk + // chunk size_t chunkLength = read32bitInt(&in[pos]); pos += 4; if (chunkLength > 2147483647) { @@ -553,7 +553,7 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, error = 35; return; } // error: size of the in buffer too small to contain next - // chunk + // chunk if (in[pos + 0] == 'I' && in[pos + 1] == 'D' && in[pos + 2] == 'A' && in[pos + 3] == @@ -593,7 +593,7 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, error = 39; return; } // error: more alpha values given than there are - // palette entries + // palette entries for (size_t i = 0; i < chunkLength; i++) { info.palette[4 * i + 3] = in[pos++]; } @@ -602,7 +602,7 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, error = 40; return; } // error: this chunk must be 2 bytes for greyscale - // image + // image info.key_defined = true; info.key_r = info.key_g = info.key_b = 256 * in[pos] + in[pos + 1]; @@ -630,7 +630,7 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, error = 69; return; } // error: unknown critical chunk (5th bit of first byte - // of chunk type is 0) + // of chunk type is 0) pos += (chunkLength + 4); // skip 4 letters and // uninterpreted data of // unimplemented chunk @@ -745,7 +745,7 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, error = 27; return; } // error: the data length is smaller than the length of the - // header + // header if (in[0] != 137 || in[1] != 80 || in[2] != 78 || in[3] != 71 || in[4] != 13 || in[5] != 10 || in[6] != 26 || in[7] != 10) { error = 28; @@ -765,7 +765,7 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, error = 32; return; } // error: only compression method 0 is allowed in the - // specification + // specification info.filterMethod = in[27]; if (in[27] != 0) { error = 33; @@ -776,7 +776,7 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, error = 34; return; } // error: only interlace methods 0 and 1 exist in the - // specification + // specification error = checkColorValidity(info.colorType, info.bitDepth); } void unFilterScanline(unsigned char *recon, @@ -1115,4 +1115,4 @@ int decodePNG(std::vector<unsigned char> &out_image, unsigned long &image_width, return decoder.error; } -} // yage +} // namespace yage diff --git a/src/rectanglecollider.cpp b/src/rectanglecollider.cpp index 936ac06a..64887278 100644 --- a/src/rectanglecollider.cpp +++ b/src/rectanglecollider.cpp @@ -6,7 +6,7 @@ * ---------------------------------------------------------------------------- */ -#include "Physics/rectanglecollider.hpp" +#include <YAGE/Physics/rectanglecollider.h> namespace yage { @@ -33,4 +33,4 @@ inline bool RectangleCollider::inside(const glm::vec2 &point) const position_.y < point.y && position_.y + size_.y > point.y; } -} // yage +} // namespace yage diff --git a/src/resourcemanager.cpp b/src/resourcemanager.cpp index 8444161f..473ea37e 100644 --- a/src/resourcemanager.cpp +++ b/src/resourcemanager.cpp @@ -6,7 +6,7 @@ * ---------------------------------------------------------------------------- */ -#include "resourcemanager.hpp" +#include <YAGE/resourcemanager.h> namespace yage { @@ -18,4 +18,4 @@ Texture ResourceManager::getTexture(const std::string &texture_path) return texture_cache_.getTexture(texture_path); } -} // yage +} // namespace yage diff --git a/src/rigidbody.cpp b/src/rigidbody.cpp index deb8aee9..dcab5f2f 100644 --- a/src/rigidbody.cpp +++ b/src/rigidbody.cpp @@ -6,7 +6,7 @@ * ---------------------------------------------------------------------------- */ -#include "Physics/rigidbody.hpp" +#include <YAGE/Physics/rigidbody.h> namespace yage { @@ -17,4 +17,4 @@ RigidBody::RigidBody(const Vector2d &position, double mass, { } -} // yage +} // namespace yage diff --git a/src/sprite.cpp b/src/sprite.cpp index 92dd584c..68e08e5d 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -6,9 +6,9 @@ * ---------------------------------------------------------------------------- */ -#include "sprite.hpp" -#include "resourcemanager.hpp" -#include "vertex.hpp" +#include <YAGE/sprite.h> +#include <YAGE/resourcemanager.h> +#include <YAGE/vertex.h> #include <cstddef> @@ -94,4 +94,4 @@ void Sprite::draw() glBindBuffer(GL_ARRAY_BUFFER, 0); } -} // yage +} // namespace yage diff --git a/src/spritebatch.cpp b/src/spritebatch.cpp index efca0b8d..ac98130b 100644 --- a/src/spritebatch.cpp +++ b/src/spritebatch.cpp @@ -6,7 +6,7 @@ * ---------------------------------------------------------------------------- */ -#include "spritebatch.hpp" +#include <YAGE/spritebatch.h> #include <algorithm> #include <stdexcept> @@ -43,7 +43,10 @@ SpriteBatch::~SpriteBatch() } } -void SpriteBatch::init() { createVertexArray(); } +void SpriteBatch::init() +{ + createVertexArray(); +} void SpriteBatch::begin() { @@ -187,4 +190,4 @@ void SpriteBatch::sortGlyphs() }); } -} // yage +} // namespace yage diff --git a/src/texturecache.cpp b/src/texturecache.cpp index 5ce89dc1..fda5fcd9 100644 --- a/src/texturecache.cpp +++ b/src/texturecache.cpp @@ -6,8 +6,8 @@ * ---------------------------------------------------------------------------- */ -#include "texturecache.hpp" -#include "imageloader.hpp" +#include <YAGE/texturecache.h> +#include <YAGE/imageloader.h> namespace yage { @@ -27,4 +27,4 @@ Texture TextureCache::getTexture(const std::string &texture_path) return itr->second; } -} // yage +} // namespace yage diff --git a/src/window.cpp b/src/window.cpp index 14671bf9..143b1d5d 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -6,8 +6,7 @@ * ---------------------------------------------------------------------------- */ -#include "window.hpp" - +#include <YAGE/window.h> #include <GL/glew.h> #include <iostream> @@ -18,7 +17,10 @@ namespace yage Window::Window() = default; -Window::~Window() { SDL_DestroyWindow(window_); } +Window::~Window() +{ + SDL_DestroyWindow(window_); +} void Window::create(const std::string &window_name, int width, int height, unsigned flags) @@ -92,4 +94,4 @@ void Window::clearBuffer() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } -} // yage +} // namespace yage diff --git a/test/matrixtest.cpp b/test/matrixtest.cpp index d388948b..b570f6d4 100644 --- a/test/matrixtest.cpp +++ b/test/matrixtest.cpp @@ -6,24 +6,14 @@ * ---------------------------------------------------------------------------- */ +#include <YAGE/Math/math.h> +#include <gtest/gtest.h> + #include <algorithm> #include <cstdlib> #include <ctime> #include <vector> -#include "Math/math.hpp" - -#include "gtest/gtest.h" - -template <int Size> -int matrixAssign(int number, int i, int j) -{ - yage::Matrix<Size, Size, int> m; - m[j][i] = number; - - return m[j][i]; -} - template <int Size> int matrixAddition(int num1, int num2) { @@ -47,14 +37,21 @@ int vectorDotProduct(const std::vector<int> &vec_contents_f, return x; } -bool matrixMultiplication() { return false; } +bool matrixMultiplication() +{ + return false; +} // TESTS TEST(Matrix, Assign) { - int rand_num = rand(); - ASSERT_EQ(rand_num, matrixAssign<10>(rand_num, 4, 2)); + double rand_num = rand(); + yage::Matrix<5, 5, double> mat1; + mat1[3][2] = rand_num; + ASSERT_EQ(rand_num, mat1[3][2]); + yage::Matrix<2, 2, double> mat2 {{rand_num, rand_num, rand_num, rand_num}}; + ASSERT_EQ(rand_num, mat2[1][0]); } TEST(Matrix, Addition) diff --git a/test/particlebodytest.cpp b/test/particlebodytest.cpp index 65c3885c..b359cb73 100644 --- a/test/particlebodytest.cpp +++ b/test/particlebodytest.cpp @@ -6,12 +6,12 @@ * ---------------------------------------------------------------------------- */ +#include <YAGE/Physics/particlebody.h> +#include <gtest/gtest.h> + #include <cmath> #include <cstdlib> -#include "Physics/particlebody.hpp" -#include "gtest/gtest.h" - double gravityAcceleration(int iterations) { yage::ParticleBody body; diff --git a/test/windowtest.cpp b/test/windowtest.cpp index 73e2f82c..e6739720 100644 --- a/test/windowtest.cpp +++ b/test/windowtest.cpp @@ -6,11 +6,13 @@ * ---------------------------------------------------------------------------- */ -#include "gtest/gtest.h" +#include <YAGE/yage.h> +#include <gtest/gtest.h> -#include "yage.hpp" - -TEST(Window, Open) { ASSERT_TRUE(true); } +TEST(Window, Open) +{ + ASSERT_TRUE(true); +} int main(int argc, char **argv) { diff --git a/test/yagetest.cpp b/test/yagetest.cpp index 90d915a8..8d590b4a 100644 --- a/test/yagetest.cpp +++ b/test/yagetest.cpp @@ -6,11 +6,15 @@ * ---------------------------------------------------------------------------- */ -#include "gtest/gtest.h" +#include <gtest/gtest.h> -#include "yage.hpp" +#include <YAGE/yage.h> -TEST(YAGE, InitQuit) { ASSERT_TRUE(true); } +TEST(YAGE, InitQuit) +{ + ASSERT_TRUE(yage::init()); + yage::quit(); +} int main(int argc, char **argv) { |