From fb8197839c0bebc20fd68ee3f280da934c49c473 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Fri, 22 Dec 2017 21:16:02 +0000 Subject: Removing editor and refactoring code. --- .dir-locals.el | 4 +- CMakeLists.txt | 4 + editor/editor.pro | 34 --- editor/editor.pro.user | 336 ---------------------------- editor/editorwindow.cpp | 26 --- editor/editorwindow.h | 25 --- editor/editorwindow.ui | 69 ------ editor/main.cpp | 19 -- examples/CMakeLists.txt | 2 + examples/simplegame/dngn_blood_fountain.png | Bin 0 -> 955 bytes examples/simplegame/main.cpp | 13 +- examples/simplegame/textureshader.frag | 16 ++ examples/simplegame/textureshader.vert | 23 ++ resources/textureshader.frag | 2 +- tests/CMakeLists.txt | 33 ++- tests/active/test.cpp | 46 ++++ tests/activetest.cpp | 46 ---- tests/log/test.cpp | 19 ++ tests/logtest.cpp | 19 -- tests/matrix/test.cpp | 65 ++++++ tests/matrixtest.cpp | 65 ------ tests/particlebody/test.cpp | 41 ++++ tests/particlebodytest.cpp | 41 ---- tests/rendertest.cpp | 13 -- tests/rendertest.h | 19 -- tests/resources/dngn_blood_fountain.png | Bin 955 -> 0 bytes tests/resources/simplegame.frag | 0 tests/resources/simplegame.vert | 0 tests/struct/test.cpp | 57 +++++ tests/structtest.cpp | 57 ----- tests/syncqueue/test.cpp | 53 +++++ tests/syncqueuetest.cpp | 53 ----- tests/thread/test.cpp | 29 +++ tests/threadtest.cpp | 29 --- tests/vector3/test.cpp | 94 ++++++++ tests/vector3test.cpp | 94 -------- tests/vector4/test.cpp | 99 ++++++++ tests/vector4test.cpp | 99 -------- tests/window/test.cpp | 21 ++ tests/windowtest.cpp | 21 -- tests/yage/test.cpp | 26 +++ tests/yagetest.cpp | 26 --- yage/CMakeLists.txt | 3 - yage/core/camera2d.cpp | 6 +- yage/core/camera2d.h | 4 +- 45 files changed, 625 insertions(+), 1126 deletions(-) delete mode 100644 editor/editor.pro delete mode 100644 editor/editor.pro.user delete mode 100644 editor/editorwindow.cpp delete mode 100644 editor/editorwindow.h delete mode 100644 editor/editorwindow.ui delete mode 100644 editor/main.cpp create mode 100644 examples/CMakeLists.txt create mode 100644 examples/simplegame/dngn_blood_fountain.png create mode 100644 examples/simplegame/textureshader.frag create mode 100644 examples/simplegame/textureshader.vert create mode 100644 tests/active/test.cpp delete mode 100644 tests/activetest.cpp create mode 100644 tests/log/test.cpp delete mode 100644 tests/logtest.cpp create mode 100644 tests/matrix/test.cpp delete mode 100644 tests/matrixtest.cpp create mode 100644 tests/particlebody/test.cpp delete mode 100644 tests/particlebodytest.cpp delete mode 100644 tests/rendertest.cpp delete mode 100644 tests/rendertest.h delete mode 100644 tests/resources/dngn_blood_fountain.png delete mode 100644 tests/resources/simplegame.frag delete mode 100644 tests/resources/simplegame.vert create mode 100644 tests/struct/test.cpp delete mode 100644 tests/structtest.cpp create mode 100644 tests/syncqueue/test.cpp delete mode 100644 tests/syncqueuetest.cpp create mode 100644 tests/thread/test.cpp delete mode 100644 tests/threadtest.cpp create mode 100644 tests/vector3/test.cpp delete mode 100644 tests/vector3test.cpp create mode 100644 tests/vector4/test.cpp delete mode 100644 tests/vector4test.cpp create mode 100644 tests/window/test.cpp delete mode 100644 tests/windowtest.cpp create mode 100644 tests/yage/test.cpp delete mode 100644 tests/yagetest.cpp delete mode 100644 yage/CMakeLists.txt diff --git a/.dir-locals.el b/.dir-locals.el index b98c6f58..53a0bded 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1,3 +1,3 @@ ((nil . ((projectile-project-compilation-cmd . "mkdir -p build && cd build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DYAGE_BUILD_TESTS=ON .. && make -j9") - (projectile-project-test-cmd . "cd build && ctest") - (projectile-project-run-cmd . "./bin/simplegame")))) + (projectile-project-test-cmd . "cd build/tests && ctest") + (projectile-project-run-cmd . "./build/bin/simplegame")))) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82910286..d480b31c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ set(CMAKE_CXX_STANDARD 14) # find other libraries from source set(EXTERNAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/") + # GLFW3 set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) @@ -48,6 +50,8 @@ target_link_libraries(yage ${GLFW_LIBRARIES} glad) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples) + if(YAGE_BUILD_TESTS) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests) endif(YAGE_BUILD_TESTS) diff --git a/editor/editor.pro b/editor/editor.pro deleted file mode 100644 index 1cec2824..00000000 --- a/editor/editor.pro +++ /dev/null @@ -1,34 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2017-09-10T12:11:18 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = editor -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which as been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - - -SOURCES += \ - main.cpp \ - editorwindow.cpp - -HEADERS += \ - editorwindow.h - -FORMS += \ - editorwindow.ui diff --git a/editor/editor.pro.user b/editor/editor.pro.user deleted file mode 100644 index 9432df0a..00000000 --- a/editor/editor.pro.user +++ /dev/null @@ -1,336 +0,0 @@ - - - - - - EnvironmentId - {9dce752e-6199-4873-be9d-96711f00400a} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - true - false - 0 - true - true - 0 - 8 - true - 1 - true - true - true - false - - - - ProjectExplorer.Project.PluginSettings - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop - {f5cdc152-9721-42b1-adce-0f96841fccff} - 0 - 0 - 0 - - /home/yannherklotz/Github/YAGE/build-editor-Desktop-Debug - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - true - - - /home/yannherklotz/Github/YAGE/build-editor-Desktop-Release - - - true - qmake - - QtProjectManager.QMakeBuildStep - false - - false - false - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - - /home/yannherklotz/Github/YAGE/build-editor-Desktop-Profile - - - true - qmake - - QtProjectManager.QMakeBuildStep - true - - false - true - false - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - false - - - - 2 - Build - - ProjectExplorer.BuildSteps.Build - - - - true - Make - - Qt4ProjectManager.MakeStep - - -w - -r - - true - clean - - - 1 - Clean - - ProjectExplorer.BuildSteps.Clean - - 2 - false - - Profile - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - true - - 3 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy - - 1 - Deploy locally - - ProjectExplorer.DefaultDeployConfiguration - - 1 - - - false - false - 1000 - - true - - false - false - false - false - true - 0.01 - 10 - true - 1 - 25 - - 1 - true - false - true - valgrind - - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - - 2 - - editor - - Qt4ProjectManager.Qt4RunConfiguration:/home/yannherklotz/Github/YAGE/editor/editor.pro - true - - editor.pro - false - - /home/yannherklotz/Github/YAGE/build-editor-Desktop-Debug - 3768 - false - true - false - false - true - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 18 - - - Version - 18 - - diff --git a/editor/editorwindow.cpp b/editor/editorwindow.cpp deleted file mode 100644 index aad84612..00000000 --- a/editor/editorwindow.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* ---------------------------------------------------------------------------- - * /home/yannherklotz/Github/YAGE/editor/editorwindow.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include "editorwindow.h" -#include "ui_editorwindow.h" - -EditorWindow::EditorWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::EditorWindow) -{ - ui->setupUi(this); -} - -EditorWindow::~EditorWindow() -{ - delete ui; -} - -void EditorWindow::on_openGLWidget_destroyed() -{ -} diff --git a/editor/editorwindow.h b/editor/editorwindow.h deleted file mode 100644 index 1e3e8045..00000000 --- a/editor/editorwindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef EDITORWINDOW_H -#define EDITORWINDOW_H - -#include - -namespace Ui { -class EditorWindow; -} - -class EditorWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit EditorWindow(QWidget *parent = 0); - ~EditorWindow(); - -private slots: - void on_openGLWidget_destroyed(); - -private: - Ui::EditorWindow *ui; -}; - -#endif // EDITORWINDOW_H diff --git a/editor/editorwindow.ui b/editor/editorwindow.ui deleted file mode 100644 index 63fd4940..00000000 --- a/editor/editorwindow.ui +++ /dev/null @@ -1,69 +0,0 @@ - - - EditorWindow - - - - 0 - 0 - 1920 - 1080 - - - - EditorWindow - - - - - - 110 - 80 - 1071 - 431 - - - - - - - - 0 - 0 - 1920 - 22 - - - - - File - - - - - - Edit - - - - - - - - TopToolBarArea - - - false - - - - - - New Game - - - - - - - diff --git a/editor/main.cpp b/editor/main.cpp deleted file mode 100644 index bc80117b..00000000 --- a/editor/main.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* ---------------------------------------------------------------------------- - * /home/yannherklotz/Github/YAGE/editor/main.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include "editorwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - EditorWindow w; - w.show(); - - return a.exec(); -} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..16b20795 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(simplegame simplegame/main.cpp) +target_link_libraries(simplegame yage) diff --git a/examples/simplegame/dngn_blood_fountain.png b/examples/simplegame/dngn_blood_fountain.png new file mode 100644 index 00000000..7214fd47 Binary files /dev/null and b/examples/simplegame/dngn_blood_fountain.png differ diff --git a/examples/simplegame/main.cpp b/examples/simplegame/main.cpp index 04d63ec0..a631e45b 100644 --- a/examples/simplegame/main.cpp +++ b/examples/simplegame/main.cpp @@ -22,16 +22,16 @@ int main() window.create("Simple Game", 800, 640); SpriteBatch sp; - program.compileShadersFromFile("resources/textureshader.vert", "resources/textureshader.frag"); + program.compileShadersFromFile("examples/simplegame/textureshader.vert", + "examples/simplegame/textureshader.frag"); program.linkShaders(); - Texture fountain = - ResourceManager::getTexture("/home/yannherklotz/Github/YAGE/tests/" - "resources/dngn_blood_fountain.png"); + Texture fountain = ResourceManager::getTexture( + "examples/simplegame/dngn_blood_fountain.png"); cout << "texture: " << fountain.width << ", " << fountain.height << '\n'; - Camera2D camera(800, 640); + Camera camera(800, 640); while (!window.shouldClose()) { window.clearBuffer(); @@ -44,7 +44,8 @@ int main() GLint texture_location = program.getUniformLocation("texture_sampler"); glUniform1i(texture_location, 0); - sp.draw({0.f, 0.f, 64.f, 64.f}, {0, 0, 1, 1}, fountain.id, Colour(255, 0, 255, 255), 0); + sp.draw({0.f, 0.f, 64.f, 64.f}, {0, 0, 1, 1}, fountain.id, + Colour(255, 0, 255, 255), 0); sp.render(); glBindTexture(GL_TEXTURE_2D, 0); diff --git a/examples/simplegame/textureshader.frag b/examples/simplegame/textureshader.frag new file mode 100644 index 00000000..ef728b04 --- /dev/null +++ b/examples/simplegame/textureshader.frag @@ -0,0 +1,16 @@ +#version 450 + +layout(location = 0) in vec2 fragment_position; +layout(location = 1) in vec4 fragment_colour; +layout(location = 2) in vec2 fragment_uv; + +out vec4 colour; + +uniform sampler2D texture_sampler; + +void main() +{ + vec4 texture_color = texture(texture_sampler, fragment_uv); + + colour = texture_color * fragment_colour; +} diff --git a/examples/simplegame/textureshader.vert b/examples/simplegame/textureshader.vert new file mode 100644 index 00000000..3277d8b0 --- /dev/null +++ b/examples/simplegame/textureshader.vert @@ -0,0 +1,23 @@ +#version 450 + +layout(location = 0) in vec2 vertex_position; +layout(location = 1) in vec4 vertex_colour; +layout(location = 2) in vec2 vertex_uv; + +layout(location = 0) out vec2 fragment_position; +layout(location = 1) out vec4 fragment_colour; +layout(location = 2) out vec2 fragment_uv; + +uniform mat4 P; + +void main() +{ + gl_Position.xy = (P*vec4(vertex_position, 0.0, 1.0)).xy; + gl_Position.z = 0.0; + gl_Position.w = 1.0; + + fragment_position = vertex_position; + fragment_colour = vertex_colour; + fragment_uv = vec2(vertex_uv.x, 1-vertex_uv.y); + +} diff --git a/resources/textureshader.frag b/resources/textureshader.frag index 37a8a219..ef728b04 100644 --- a/resources/textureshader.frag +++ b/resources/textureshader.frag @@ -12,5 +12,5 @@ void main() { vec4 texture_color = texture(texture_sampler, fragment_uv); - colour = texture_color; + colour = texture_color * fragment_colour; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 613e0bdb..36afa574 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,30 +8,27 @@ set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) # the gtest and gtest_main targets. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/googletest) -add_executable(simplegame simplegame.cpp) -target_link_libraries(simplegame yage) - # enable tests enable_testing() set(SIMULATION_RUNS 1000) function(make_test test_name cycles) - add_executable(${test_name} ${test_name}.cpp) - target_link_libraries(${test_name} + add_executable("${test_name}test" ${test_name}/test.cpp) + target_link_libraries("${test_name}test" gtest_main yage) - add_test(NAME ${test_name} COMMAND ${test_name} --gtest_repeat=${cycles} --gtest_break_on_failure) + add_test(NAME ${test_name} COMMAND "${test_name}test" --gtest_repeat=${cycles} --gtest_break_on_failure) endfunction(make_test) -make_test(yagetest 1) -make_test(matrixtest ${SIMULATION_RUNS}) -make_test(particlebodytest 100) -make_test(windowtest ${SIMULATION_RUNS}) -make_test(spritesheettest ${SIMULATION_RUNS}) -make_test(vector3test ${SIMULATION_RUNS}) -make_test(vector4test ${SIMULATION_RUNS}) -make_test(logtest 1) -make_test(threadtest 1) -make_test(syncqueuetest 1) -make_test(activetest 1) -make_test(structtest ${SIMULATION_RUNS}) +make_test(yage 1) +make_test(matrix ${SIMULATION_RUNS}) +make_test(particlebody 100) +make_test(window ${SIMULATION_RUNS}) +make_test(spritesheet ${SIMULATION_RUNS}) +make_test(vector3 ${SIMULATION_RUNS}) +make_test(vector4 ${SIMULATION_RUNS}) +make_test(log 1) +make_test(thread 1) +make_test(syncqueue 1) +make_test(active 1) +make_test(struct ${SIMULATION_RUNS}) diff --git a/tests/active/test.cpp b/tests/active/test.cpp new file mode 100644 index 00000000..3d561283 --- /dev/null +++ b/tests/active/test.cpp @@ -0,0 +1,46 @@ +/** --------------------------------------------------------------------------- + * @file: activetest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include + +#include + +using namespace yage; + +void print_random() +{ + std::cout << "hello world" + << "\n"; +} + +void print_h() +{ + std::cout << "Helllllllo" + << "\n"; +} + +void flush() +{ + std::cout << "flush" << std::endl; +} + +int main() +{ + auto a = Active::create(); + + a->send(print_random); + a->send(print_h); + a->send(flush); + + std::cout << std::endl; + + for (int i = 0; i < 1000000; i++) { + } + + std::cout << std::endl; +} diff --git a/tests/activetest.cpp b/tests/activetest.cpp deleted file mode 100644 index 3d561283..00000000 --- a/tests/activetest.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: activetest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include - -#include - -using namespace yage; - -void print_random() -{ - std::cout << "hello world" - << "\n"; -} - -void print_h() -{ - std::cout << "Helllllllo" - << "\n"; -} - -void flush() -{ - std::cout << "flush" << std::endl; -} - -int main() -{ - auto a = Active::create(); - - a->send(print_random); - a->send(print_h); - a->send(flush); - - std::cout << std::endl; - - for (int i = 0; i < 1000000; i++) { - } - - std::cout << std::endl; -} diff --git a/tests/log/test.cpp b/tests/log/test.cpp new file mode 100644 index 00000000..e1010754 --- /dev/null +++ b/tests/log/test.cpp @@ -0,0 +1,19 @@ +/** --------------------------------------------------------------------------- + * @file: logtest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include + +#include + +int main() +{ + gLog << "First message"; + + gLog << "Second Message"; + std::cout << "COUT\n"; +} diff --git a/tests/logtest.cpp b/tests/logtest.cpp deleted file mode 100644 index e1010754..00000000 --- a/tests/logtest.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: logtest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include - -#include - -int main() -{ - gLog << "First message"; - - gLog << "Second Message"; - std::cout << "COUT\n"; -} diff --git a/tests/matrix/test.cpp b/tests/matrix/test.cpp new file mode 100644 index 00000000..1e316502 --- /dev/null +++ b/tests/matrix/test.cpp @@ -0,0 +1,65 @@ +/** --------------------------------------------------------------------------- + * @file: matrixtest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include +#include + +#include +#include +#include +#include + +// TESTS + +TEST(Matrix, Assign) +{ + 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) +{ + int rand_x = rand(); + int rand_y = rand(); + yage::Matrix<5, 5, int> m1, m2; + + m1[2][4] = rand_x; + m2[2][4] = rand_y; + + ASSERT_EQ(rand_x + rand_y, (m1 + m2)[2][4]); +} + +TEST(Vector, DotProduct) +{ + std::vector contents_i = {rand() % 100, rand() % 100, rand() % 100}; + std::vector contents_j = {rand() % 100, rand() % 100, rand() % 100}; + yage::Vector<3, int> v1{contents_i}; + yage::Vector<3, int> v2{contents_j}; + + int sum = 0; + for (std::size_t i = 0; i < contents_i.size(); ++i) { + sum += contents_i[i] * contents_j[i]; + } + + ASSERT_EQ(sum, yage::matrix::dot(v1, v2)); +} + +int main(int argc, char **argv) +{ + srand(static_cast(time(nullptr))); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tests/matrixtest.cpp b/tests/matrixtest.cpp deleted file mode 100644 index 1e316502..00000000 --- a/tests/matrixtest.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: matrixtest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include -#include - -#include -#include -#include -#include - -// TESTS - -TEST(Matrix, Assign) -{ - 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) -{ - int rand_x = rand(); - int rand_y = rand(); - yage::Matrix<5, 5, int> m1, m2; - - m1[2][4] = rand_x; - m2[2][4] = rand_y; - - ASSERT_EQ(rand_x + rand_y, (m1 + m2)[2][4]); -} - -TEST(Vector, DotProduct) -{ - std::vector contents_i = {rand() % 100, rand() % 100, rand() % 100}; - std::vector contents_j = {rand() % 100, rand() % 100, rand() % 100}; - yage::Vector<3, int> v1{contents_i}; - yage::Vector<3, int> v2{contents_j}; - - int sum = 0; - for (std::size_t i = 0; i < contents_i.size(); ++i) { - sum += contents_i[i] * contents_j[i]; - } - - ASSERT_EQ(sum, yage::matrix::dot(v1, v2)); -} - -int main(int argc, char **argv) -{ - srand(static_cast(time(nullptr))); - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/particlebody/test.cpp b/tests/particlebody/test.cpp new file mode 100644 index 00000000..09277826 --- /dev/null +++ b/tests/particlebody/test.cpp @@ -0,0 +1,41 @@ +/** --------------------------------------------------------------------------- + * @file: particlebodytest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include +#include + +#include +#include + +double gravityAcceleration(int iterations) +{ + yage::ParticleBody body; + for (int i = 0; i < 60 * iterations; ++i) { + body.update(); + } + + return body.yPosition(); +} + +// Tests + +TEST(ParticleBody, Gravity) +{ + int randomItr = rand() % 10; + double idealPosition = 0.5 * -9.81 * std::pow(randomItr, 2); + + ASSERT_GE(idealPosition * 0.95, gravityAcceleration(randomItr)); + ASSERT_LE(idealPosition * 1.05, gravityAcceleration(randomItr)); +} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + srand(static_cast(time(nullptr))); + return RUN_ALL_TESTS(); +} diff --git a/tests/particlebodytest.cpp b/tests/particlebodytest.cpp deleted file mode 100644 index 09277826..00000000 --- a/tests/particlebodytest.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: particlebodytest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include -#include - -#include -#include - -double gravityAcceleration(int iterations) -{ - yage::ParticleBody body; - for (int i = 0; i < 60 * iterations; ++i) { - body.update(); - } - - return body.yPosition(); -} - -// Tests - -TEST(ParticleBody, Gravity) -{ - int randomItr = rand() % 10; - double idealPosition = 0.5 * -9.81 * std::pow(randomItr, 2); - - ASSERT_GE(idealPosition * 0.95, gravityAcceleration(randomItr)); - ASSERT_LE(idealPosition * 1.05, gravityAcceleration(randomItr)); -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - srand(static_cast(time(nullptr))); - return RUN_ALL_TESTS(); -} diff --git a/tests/rendertest.cpp b/tests/rendertest.cpp deleted file mode 100644 index 74476ef8..00000000 --- a/tests/rendertest.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: rendertest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include "rendertest.h" - -RenderTest::RenderTest(std::string sprite) : sprite_(sprite) {} - -void RenderTest::render() {} diff --git a/tests/rendertest.h b/tests/rendertest.h deleted file mode 100644 index db0e06e2..00000000 --- a/tests/rendertest.h +++ /dev/null @@ -1,19 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: rendertest.h - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include - -class RenderTest -{ -public: - RenderTest(std::string sprite); - void render(); - -private: - std::string sprite_; -}; diff --git a/tests/resources/dngn_blood_fountain.png b/tests/resources/dngn_blood_fountain.png deleted file mode 100644 index 7214fd47..00000000 Binary files a/tests/resources/dngn_blood_fountain.png and /dev/null differ diff --git a/tests/resources/simplegame.frag b/tests/resources/simplegame.frag deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/resources/simplegame.vert b/tests/resources/simplegame.vert deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/struct/test.cpp b/tests/struct/test.cpp new file mode 100644 index 00000000..99752abb --- /dev/null +++ b/tests/struct/test.cpp @@ -0,0 +1,57 @@ +/** --------------------------------------------------------------------------- + * @file: structtest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include +#include + +#include +#include + +TEST(StructTest, ColourDefault) +{ + yage::Colour c; + ASSERT_EQ(c.r, 0); + ASSERT_EQ(c.g, 0); + ASSERT_EQ(c.b, 0); + ASSERT_EQ(c.a, 0); +} + +TEST(StructTest, ColourConstructor) +{ + int r = rand() % 255, g = rand() % 255, b = rand() % 255, a = rand() % 255; + yage::Colour c(r, g, b, a); + + ASSERT_EQ(c.r, r); + ASSERT_EQ(c.g, g); + ASSERT_EQ(c.b, b); + ASSERT_EQ(c.a, a); +} + +TEST(StructTest, TextureDefault) +{ + yage::Texture t; + ASSERT_EQ(t.id, static_cast(0)); + ASSERT_EQ(t.width, 0); + ASSERT_EQ(t.height, 0); +} + +TEST(StructTest, TextureConstructor) +{ + int id = rand(), width = rand(), height = rand(); + yage::Texture t(static_cast(id), width, height); + ASSERT_EQ(t.id, static_cast(id)); + ASSERT_EQ(t.width, width); + ASSERT_EQ(t.height, height); +} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + srand(static_cast(time(nullptr))); + return RUN_ALL_TESTS(); +} diff --git a/tests/structtest.cpp b/tests/structtest.cpp deleted file mode 100644 index 99752abb..00000000 --- a/tests/structtest.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: structtest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include -#include - -#include -#include - -TEST(StructTest, ColourDefault) -{ - yage::Colour c; - ASSERT_EQ(c.r, 0); - ASSERT_EQ(c.g, 0); - ASSERT_EQ(c.b, 0); - ASSERT_EQ(c.a, 0); -} - -TEST(StructTest, ColourConstructor) -{ - int r = rand() % 255, g = rand() % 255, b = rand() % 255, a = rand() % 255; - yage::Colour c(r, g, b, a); - - ASSERT_EQ(c.r, r); - ASSERT_EQ(c.g, g); - ASSERT_EQ(c.b, b); - ASSERT_EQ(c.a, a); -} - -TEST(StructTest, TextureDefault) -{ - yage::Texture t; - ASSERT_EQ(t.id, static_cast(0)); - ASSERT_EQ(t.width, 0); - ASSERT_EQ(t.height, 0); -} - -TEST(StructTest, TextureConstructor) -{ - int id = rand(), width = rand(), height = rand(); - yage::Texture t(static_cast(id), width, height); - ASSERT_EQ(t.id, static_cast(id)); - ASSERT_EQ(t.width, width); - ASSERT_EQ(t.height, height); -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - srand(static_cast(time(nullptr))); - return RUN_ALL_TESTS(); -} diff --git a/tests/syncqueue/test.cpp b/tests/syncqueue/test.cpp new file mode 100644 index 00000000..1d7d8037 --- /dev/null +++ b/tests/syncqueue/test.cpp @@ -0,0 +1,53 @@ +/** --------------------------------------------------------------------------- + * @file: syncqueuetest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include + +#include +#include + +using namespace yage; + +SyncQueue queue; +std::atomic_int j(0); + +void push_to_queue1(int elements) +{ + for (int i = 0; i < elements; i++) { + queue.push(1); + j.fetch_add(1, std::memory_order_relaxed); + } + std::cout << "Done 1\n"; +} + +void push_to_queue2(int elements) +{ + for (int i = 0; i < elements; i++) { + queue.push(2); + j.fetch_add(1, std::memory_order_relaxed); + } + std::cout << "Done 2\n"; +} + +int main() +{ + std::thread first(push_to_queue1, 100000); + std::thread second(push_to_queue2, 100000); + + std::cout << "created threads, now adding in main\n"; + for (int i = 0; i < 1000000; ++i) { + queue.push(i); + j.fetch_add(1, std::memory_order_relaxed); + } + + std::cout << "now joining the threads\n"; + first.join(); + second.join(); + std::cout << "done\n" + << "iterations: " << j << "\n"; +} diff --git a/tests/syncqueuetest.cpp b/tests/syncqueuetest.cpp deleted file mode 100644 index 1d7d8037..00000000 --- a/tests/syncqueuetest.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: syncqueuetest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include - -#include -#include - -using namespace yage; - -SyncQueue queue; -std::atomic_int j(0); - -void push_to_queue1(int elements) -{ - for (int i = 0; i < elements; i++) { - queue.push(1); - j.fetch_add(1, std::memory_order_relaxed); - } - std::cout << "Done 1\n"; -} - -void push_to_queue2(int elements) -{ - for (int i = 0; i < elements; i++) { - queue.push(2); - j.fetch_add(1, std::memory_order_relaxed); - } - std::cout << "Done 2\n"; -} - -int main() -{ - std::thread first(push_to_queue1, 100000); - std::thread second(push_to_queue2, 100000); - - std::cout << "created threads, now adding in main\n"; - for (int i = 0; i < 1000000; ++i) { - queue.push(i); - j.fetch_add(1, std::memory_order_relaxed); - } - - std::cout << "now joining the threads\n"; - first.join(); - second.join(); - std::cout << "done\n" - << "iterations: " << j << "\n"; -} diff --git a/tests/thread/test.cpp b/tests/thread/test.cpp new file mode 100644 index 00000000..0527665a --- /dev/null +++ b/tests/thread/test.cpp @@ -0,0 +1,29 @@ +/** --------------------------------------------------------------------------- + * @file: threadtest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include + +#include +#include + +int main() +{ + int n = 5; + + std::cout << "n before: " << n << "\n"; + + auto f = [&]() { n = 8; }; + + std::thread t1(f); + + std::cout << "n after: " << n << "\n"; + + t1.join(); + + std::cout << "n after thread: " << n << "\n"; +} diff --git a/tests/threadtest.cpp b/tests/threadtest.cpp deleted file mode 100644 index 0527665a..00000000 --- a/tests/threadtest.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: threadtest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include - -#include -#include - -int main() -{ - int n = 5; - - std::cout << "n before: " << n << "\n"; - - auto f = [&]() { n = 8; }; - - std::thread t1(f); - - std::cout << "n after: " << n << "\n"; - - t1.join(); - - std::cout << "n after thread: " << n << "\n"; -} diff --git a/tests/vector3/test.cpp b/tests/vector3/test.cpp new file mode 100644 index 00000000..570a5c10 --- /dev/null +++ b/tests/vector3/test.cpp @@ -0,0 +1,94 @@ +/** --------------------------------------------------------------------------- + * @file: vector3test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +/** --------------------------------------------------------------------------- + * @file: vector3test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +/** --------------------------------------------------------------------------- + * @file: vector3test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +/** --------------------------------------------------------------------------- + * @file: vector3test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +/** --------------------------------------------------------------------------- + * @file: vector3test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include +#include + +#include +#include + +using namespace yage; + +TEST(Vector3, Initialize) +{ + Vector3i vec{{rand(), rand(), rand()}}; + ASSERT_EQ(vec.x, vec[0]); + ASSERT_EQ(vec.y, vec[1]); + ASSERT_EQ(vec.z, vec[2]); +} + +TEST(Vector3, Assigning_x) +{ + Vector3i vec{{rand(), rand(), rand()}}; + ASSERT_EQ(vec.x, vec[0]); + vec.x = rand(); + ASSERT_EQ(vec.x, vec[0]); + vec[0] = rand(); + ASSERT_EQ(vec.x, vec[0]); +} + +TEST(Vector3, Assigning_y) +{ + Vector3i vec{{rand(), rand(), rand()}}; + ASSERT_EQ(vec.y, vec[1]); + vec.x = rand(); + ASSERT_EQ(vec.y, vec[1]); + vec[1] = rand(); + ASSERT_EQ(vec.y, vec[1]); +} + +TEST(Vector3, Assigning_z) +{ + Vector3i vec{{rand(), rand(), rand()}}; + ASSERT_EQ(vec.z, vec[2]); + vec.z = rand(); + ASSERT_EQ(vec.z, vec[2]); + vec[2] = rand(); + ASSERT_EQ(vec.z, vec[2]); +} + +TEST(Vector3, Addition) {} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + srand(time(nullptr)); + return RUN_ALL_TESTS(); +} diff --git a/tests/vector3test.cpp b/tests/vector3test.cpp deleted file mode 100644 index 570a5c10..00000000 --- a/tests/vector3test.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: vector3test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -/** --------------------------------------------------------------------------- - * @file: vector3test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -/** --------------------------------------------------------------------------- - * @file: vector3test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -/** --------------------------------------------------------------------------- - * @file: vector3test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -/** --------------------------------------------------------------------------- - * @file: vector3test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include -#include - -#include -#include - -using namespace yage; - -TEST(Vector3, Initialize) -{ - Vector3i vec{{rand(), rand(), rand()}}; - ASSERT_EQ(vec.x, vec[0]); - ASSERT_EQ(vec.y, vec[1]); - ASSERT_EQ(vec.z, vec[2]); -} - -TEST(Vector3, Assigning_x) -{ - Vector3i vec{{rand(), rand(), rand()}}; - ASSERT_EQ(vec.x, vec[0]); - vec.x = rand(); - ASSERT_EQ(vec.x, vec[0]); - vec[0] = rand(); - ASSERT_EQ(vec.x, vec[0]); -} - -TEST(Vector3, Assigning_y) -{ - Vector3i vec{{rand(), rand(), rand()}}; - ASSERT_EQ(vec.y, vec[1]); - vec.x = rand(); - ASSERT_EQ(vec.y, vec[1]); - vec[1] = rand(); - ASSERT_EQ(vec.y, vec[1]); -} - -TEST(Vector3, Assigning_z) -{ - Vector3i vec{{rand(), rand(), rand()}}; - ASSERT_EQ(vec.z, vec[2]); - vec.z = rand(); - ASSERT_EQ(vec.z, vec[2]); - vec[2] = rand(); - ASSERT_EQ(vec.z, vec[2]); -} - -TEST(Vector3, Addition) {} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - srand(time(nullptr)); - return RUN_ALL_TESTS(); -} diff --git a/tests/vector4/test.cpp b/tests/vector4/test.cpp new file mode 100644 index 00000000..53554a25 --- /dev/null +++ b/tests/vector4/test.cpp @@ -0,0 +1,99 @@ +/** --------------------------------------------------------------------------- + * @file: vector4test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +/** --------------------------------------------------------------------------- + * @file: vector4test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +/** --------------------------------------------------------------------------- + * @file: vector4test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +/** --------------------------------------------------------------------------- + * @file: vector4test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +/** --------------------------------------------------------------------------- + * @file: vector4test.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include +#include + +#include +#include + +using namespace yage; + +TEST(Vector4, Initialize) +{ + Vector4i vec{{rand(), rand(), rand(), rand()}}; + ASSERT_EQ(vec.x, vec[0]); + ASSERT_EQ(vec.y, vec[1]); + ASSERT_EQ(vec.z, vec[2]); + ASSERT_EQ(vec.w, vec[3]); +} + +TEST(Vector4, Assigning_x) +{ + Vector4i vec{{rand(), rand(), rand(), rand()}}; + vec.x = rand(); + ASSERT_EQ(vec.x, vec[0]); + vec[0] = rand(); + ASSERT_EQ(vec.x, vec[0]); +} + +TEST(Vector4, Assigning_y) +{ + Vector4i vec{{rand(), rand(), rand(), rand()}}; + vec.y = rand(); + ASSERT_EQ(vec.y, vec[1]); + vec[1] = rand(); + ASSERT_EQ(vec.y, vec[1]); +} + +TEST(Vector4, Assigning_z) +{ + Vector4i vec{{rand(), rand(), rand(), rand()}}; + vec.z = rand(); + ASSERT_EQ(vec.z, vec[2]); + vec[2] = rand(); + ASSERT_EQ(vec.z, vec[2]); +} + +TEST(Vector4, Assigning_w) +{ + Vector4i vec{{rand(), rand(), rand(), rand()}}; + vec.w = rand(); + ASSERT_EQ(vec.w, vec[3]); + vec[3] = rand(); + ASSERT_EQ(vec.w, vec[3]); +} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + srand(time(nullptr)); + return RUN_ALL_TESTS(); +} diff --git a/tests/vector4test.cpp b/tests/vector4test.cpp deleted file mode 100644 index 53554a25..00000000 --- a/tests/vector4test.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: vector4test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -/** --------------------------------------------------------------------------- - * @file: vector4test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -/** --------------------------------------------------------------------------- - * @file: vector4test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -/** --------------------------------------------------------------------------- - * @file: vector4test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -/** --------------------------------------------------------------------------- - * @file: vector4test.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include -#include - -#include -#include - -using namespace yage; - -TEST(Vector4, Initialize) -{ - Vector4i vec{{rand(), rand(), rand(), rand()}}; - ASSERT_EQ(vec.x, vec[0]); - ASSERT_EQ(vec.y, vec[1]); - ASSERT_EQ(vec.z, vec[2]); - ASSERT_EQ(vec.w, vec[3]); -} - -TEST(Vector4, Assigning_x) -{ - Vector4i vec{{rand(), rand(), rand(), rand()}}; - vec.x = rand(); - ASSERT_EQ(vec.x, vec[0]); - vec[0] = rand(); - ASSERT_EQ(vec.x, vec[0]); -} - -TEST(Vector4, Assigning_y) -{ - Vector4i vec{{rand(), rand(), rand(), rand()}}; - vec.y = rand(); - ASSERT_EQ(vec.y, vec[1]); - vec[1] = rand(); - ASSERT_EQ(vec.y, vec[1]); -} - -TEST(Vector4, Assigning_z) -{ - Vector4i vec{{rand(), rand(), rand(), rand()}}; - vec.z = rand(); - ASSERT_EQ(vec.z, vec[2]); - vec[2] = rand(); - ASSERT_EQ(vec.z, vec[2]); -} - -TEST(Vector4, Assigning_w) -{ - Vector4i vec{{rand(), rand(), rand(), rand()}}; - vec.w = rand(); - ASSERT_EQ(vec.w, vec[3]); - vec[3] = rand(); - ASSERT_EQ(vec.w, vec[3]); -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - srand(time(nullptr)); - return RUN_ALL_TESTS(); -} diff --git a/tests/window/test.cpp b/tests/window/test.cpp new file mode 100644 index 00000000..40b7e664 --- /dev/null +++ b/tests/window/test.cpp @@ -0,0 +1,21 @@ +/** --------------------------------------------------------------------------- + * @file: windowtest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include +#include + +TEST(Window, Open) +{ + ASSERT_TRUE(true); +} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tests/windowtest.cpp b/tests/windowtest.cpp deleted file mode 100644 index 40b7e664..00000000 --- a/tests/windowtest.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: windowtest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include -#include - -TEST(Window, Open) -{ - ASSERT_TRUE(true); -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/tests/yage/test.cpp b/tests/yage/test.cpp new file mode 100644 index 00000000..a599eba2 --- /dev/null +++ b/tests/yage/test.cpp @@ -0,0 +1,26 @@ +/** --------------------------------------------------------------------------- + * @file: yagetest.cpp + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +#include +#include + +TEST(YAGE, InitQuit) +{ + try { + yage::init(); + yage::quit(); + } catch (std::runtime_error e) { + // ASSERT_TRUE(false); + } +} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/tests/yagetest.cpp b/tests/yagetest.cpp deleted file mode 100644 index a599eba2..00000000 --- a/tests/yagetest.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/** --------------------------------------------------------------------------- - * @file: yagetest.cpp - * - * Copyright (c) 2017 Yann Herklotz Grave - * MIT License, see LICENSE file for more details. - * ---------------------------------------------------------------------------- - */ - -#include -#include - -TEST(YAGE, InitQuit) -{ - try { - yage::init(); - yage::quit(); - } catch (std::runtime_error e) { - // ASSERT_TRUE(false); - } -} - -int main(int argc, char **argv) -{ - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/yage/CMakeLists.txt b/yage/CMakeLists.txt deleted file mode 100644 index b28b04f6..00000000 --- a/yage/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/yage/core/camera2d.cpp b/yage/core/camera2d.cpp index 89d41ab5..463dd0d2 100644 --- a/yage/core/camera2d.cpp +++ b/yage/core/camera2d.cpp @@ -14,14 +14,14 @@ namespace yage { -Camera2D::Camera2D(int screen_width, int screen_height) +Camera::Camera(int screen_width, int screen_height) : position_(0.f, 0.f), camera_matrix_(1.f), ortho_matrix_( glm::ortho(0.f, (float)screen_width, 0.f, (float)screen_height)) { } -void Camera2D::update(GlslProgram &program) +void Camera::update(GlslProgram &program) { if (update_matrix_) { glm::vec3 translate(-position_.x, -position_.y, 0.f); @@ -37,7 +37,7 @@ void Camera2D::update(GlslProgram &program) glUniformMatrix4fv(matrix_location, 1, GL_FALSE, &(camera_matrix_[0][0])); } -void Camera2D::move(const glm::vec2 &direction) +void Camera::move(const glm::vec2 &direction) { position_ += direction; update_matrix_ = true; diff --git a/yage/core/camera2d.h b/yage/core/camera2d.h index db941aee..109333d6 100644 --- a/yage/core/camera2d.h +++ b/yage/core/camera2d.h @@ -17,7 +17,7 @@ namespace yage class GlslProgram; -class Camera2D +class Camera { private: bool update_matrix_ = true; @@ -27,7 +27,7 @@ private: glm::mat4 ortho_matrix_; public: - Camera2D(int screen_width = 1280, int screen_height = 720); + Camera(int screen_width = 1280, int screen_height = 720); void update(GlslProgram &program); void move(const glm::vec2 &direction); -- cgit