Skip to content
Snippets Groups Projects
Commit de3c9eda authored by Armin Co's avatar Armin Co
Browse files

Cleanup

parent 310fc44c
No related branches found
No related tags found
No related merge requests found
...@@ -5,23 +5,25 @@ cmake_minimum_required(VERSION 3.2) ...@@ -5,23 +5,25 @@ cmake_minimum_required(VERSION 3.2)
## Options ## Options
option(test "Build all tests." OFF) option(create_test "Build all tests." OFF)
option(release_type "Set the type of the releas (Debug/Release)." Release) option(release_type "Set the type of the releas (Debug/Release)." Release)
## Use modern C++! ## Use modern C++!
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
## PkgConfig
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
message(" - Build type is set to ${CMAKE_BUILD_TYPE}")
# @todo Check versions of glib etc. librarys. # @todo Check versions of glib etc. librarys.
# On Ubuntu 19.10 there are warnings which are not present in Ubuntu 18.04 # On Ubuntu 19.10 there are warnings which are not present in Ubuntu 18.04
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") # set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
# Add qpong lib # Add qpong lib for core qpong functionality
add_subdirectory(qpong_core) add_subdirectory(qpong_core)
include_directories(qpong_core) include_directories(qpong_core)
...@@ -32,7 +34,7 @@ add_subdirectory(gtk_qpong_app) ...@@ -32,7 +34,7 @@ add_subdirectory(gtk_qpong_app)
# Add some unit tests # Add some unit tests
# not many yet ^^ # not many yet ^^
if (test) if (create_test)
add_subdirectory(libs/googletest) add_subdirectory(libs/googletest)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
# Specific settings for macOS
if(APPLE) if(APPLE)
link_directories("/usr/local/lib") link_directories("/usr/local/lib")
message("ATTENTION: You probably have to export the PKG_CONFIG_PATH.") message("ATTENTION: You probably have to export the PKG_CONFIG_PATH.")
message("For example: export PKG_CONFIG_PATH=\"/usr/local/lib:/usr/local/opt/zlib/lib/pkgconfig\"") message("For example: export PKG_CONFIG_PATH=\"/usr/local/lib:/usr/local/opt/zlib/lib/pkgconfig\"")
endif() endif()
# Setup GTK configuration
pkg_check_modules(GTKMM gtkmm-3.0) pkg_check_modules(GTKMM gtkmm-3.0)
link_directories(${GTKMM_LIBRARY_DIRS}) link_directories(${GTKMM_LIBRARY_DIRS})
# get all GTKMM dependencies and configuration # get all GTKMM dependencies and configuration
include_directories(${GTKMM_INCLUDE_DIRS}) include_directories(${GTKMM_INCLUDE_DIRS})
if(APPLE)
include_directories(/usr/local/include) include_directories(/usr/local/include)
endif()
# create the application # create the application
add_executable( qpong.app add_executable( qpong.app
......
...@@ -41,7 +41,7 @@ void QWindow::simulation() ...@@ -41,7 +41,7 @@ void QWindow::simulation()
// Limit the speed of the simulation. // Limit the speed of the simulation.
auto dt = std::chrono::system_clock::now() - start; auto dt = std::chrono::system_clock::now() - start;
auto dtMillis = std::chrono::duration_cast<std::chrono::milliseconds>(dt).count(); auto dtMillis = std::chrono::duration_cast<std::chrono::milliseconds>(dt).count();
constexpr int propTime = 60; constexpr int propTime = 6;
if (dtMillis < propTime) if (dtMillis < propTime)
{ {
std::this_thread::sleep_for(std::chrono::milliseconds(propTime - dtMillis)); std::this_thread::sleep_for(std::chrono::milliseconds(propTime - dtMillis));
...@@ -58,7 +58,7 @@ void render(QWindow *w) ...@@ -58,7 +58,7 @@ void render(QWindow *w)
{ {
using namespace std::chrono_literals; using namespace std::chrono_literals;
auto start = std::chrono::system_clock::now(); auto start = std::chrono::system_clock::now();
std::this_thread::sleep_for(20ms); std::this_thread::sleep_for(15ms);
w->updateView(); w->updateView();
renderRate = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start).count(); renderRate = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start).count();
} while (true); } while (true);
......
if(APPLE)
include_directories(/usr/local/include) include_directories(/usr/local/include)
endif()
## library for the app should be GTK independent ## library for the app should be GTK independent
## ##
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
namespace QPong namespace QPong
{ {
constexpr int arrayWidth = 256; constexpr int arrayWidth = 384;
constexpr int arrayHeight = 256; constexpr int arrayHeight = 384;
constexpr int numberOfThreads = 8; constexpr int numberOfThreads = 8;
constexpr unsigned arraySize = arrayWidth * arrayHeight; constexpr unsigned arraySize = arrayWidth * arrayHeight;
......
/// ///
/// @file Particle.hpp /// @file Particle.hpp
/// @author Armin Co /// @author Armin Co
///
/// @brief Particle class header. /// @brief Particle class header.
/// ///
...@@ -50,17 +49,6 @@ public: ...@@ -50,17 +49,6 @@ public:
private: private:
std::complex<double> *m_psi;
fftw_plan m_planForward;
fftw_plan m_planBackward;
bool m_ready;
std::map<Player::Id, std::shared_ptr<Player>> m_players;
ImageBuffer *m_bufPositionRepresentation;
ImageBuffer *m_bufMomentumRepresentation;
/// @brief Update the array at the ArrayCanvas /// @brief Update the array at the ArrayCanvas
/// ///
void updateMomentumImage(); void updateMomentumImage();
...@@ -83,6 +71,19 @@ private: ...@@ -83,6 +71,19 @@ private:
double removeParticle(int index, double cx); double removeParticle(int index, double cx);
std::complex<double> *m_psi;
fftw_plan m_planForward;
fftw_plan m_planBackward;
bool m_ready;
std::map<Player::Id, std::shared_ptr<Player>> m_players;
ImageBuffer *m_bufPositionRepresentation;
ImageBuffer *m_bufMomentumRepresentation;
Particle() = delete; Particle() = delete;
}; };
......
enable_testing() enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
add_executable(runUnitTests test_qpong.cpp) add_executable(runUnitTests test_qpong.cpp)
target_link_libraries(runUnitTests gtest gtest_main) target_link_libraries(runUnitTests gtest gtest_main)
target_link_libraries(runUnitTests qpong_core) target_link_libraries(runUnitTests qpong_core)
add_test(NAME a-test COMMAND runUnitTests) add_test(NAME a-test COMMAND ./tests/runUnitTests)
...@@ -43,16 +43,20 @@ TEST(ImageBuffer, getValue) ...@@ -43,16 +43,20 @@ TEST(ImageBuffer, getValue)
} }
TEST(addInts, addNumbers) TEST(addInts, positiveValues)
{ {
int a {1}; int a {1};
int b {3}; int b {3};
EXPECT_EQ(4, addInts(a,b)); ASSERT_EQ(addInts(a, b), 4);
EXPECT_EQ(4, addInts(a,b));
EXPECT_EQ(4, addInts(a,b));
EXPECT_EQ(4, addInts(a,b));
EXPECT_EQ(4, addInts(a,b));
} }
TEST(addInts, shouldBreak)
{
EXPECT_NE(3+1, 0) << "Yes yes, because it is just a test!";
}
TEST(addInts, negativeValues)
{
ASSERT_EQ(-3 + -5, -8);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment