summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-06 15:54:10 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-06 15:54:10 +0200
commitded69f52906990cf975a62c0efbaca4b6cfa5e88 (patch)
treebca2790e5d9d45ccef12e9da6cf4b125912f12db /test
parent896e072d8bd94020c883e994451b86675ecdced7 (diff)
a
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt8
-rw-r--r--test/main.cpp69
2 files changed, 77 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 00000000..2bec4a7c
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,8 @@
+set(self "${PROJECT_NAME}-test")
+file(GLOB sources "*.cpp" CONFIGURE_ARGS)
+
+link_libraries(${PROJECT_NAME})
+link_libraries(Magnum::Application Magnum::Trade)
+
+add_executable(${self} "${sources}" "../main/loader-impl.cpp")
+install(TARGETS ${self} RUNTIME DESTINATION bin)
diff --git a/test/main.cpp b/test/main.cpp
new file mode 100644
index 00000000..f7014255
--- /dev/null
+++ b/test/main.cpp
@@ -0,0 +1,69 @@
+#include <Magnum/Magnum.h>
+#include <Magnum/Platform/Sdl2Application.h>
+#include "compat/assert.hpp"
+#include "tile-atlas.hpp"
+#include "serialize/tile-atlas.hpp"
+#include "serialize/json-helper.hpp"
+#include "loader.hpp"
+#include "serialize/magnum-vector.hpp"
+
+namespace Magnum::Examples {
+
+struct app final : Platform::Application
+{
+ using dpi_policy = Platform::Implementation::Sdl2DpiScalingPolicy;
+
+ explicit app(const Arguments& arguments);
+ ~app();
+ void drawEvent() override;
+ void test();
+};
+
+app::app(const Arguments& arguments):
+ Platform::Application{
+ arguments,
+ Configuration{}
+ .setTitle("Test")
+ .setSize({1024, 768}, dpi_policy::Physical),
+ GLConfiguration{}
+ .setSampleCount(4)
+ //.setFlags(Platform::Sdl2Application::GLConfiguration::Flag::Debug)
+ }
+{
+}
+
+app::~app()
+{
+ loader_::destroy();
+}
+
+void app::drawEvent()
+{
+ test();
+ Platform::Sdl2Application::exit(0);
+}
+
+void app::test() // NOLINT(readability-convert-member-functions-to-static)
+{
+ auto atlas = loader.tile_atlas("../share/game/images/metal1.tga", {2, 2});
+ bool ret = json_helper<std::shared_ptr<tile_atlas>>::to_json(atlas, "f:/dev/game/build/test/atlas.json");
+ ASSERT(ret);
+}
+
+} // namespace Magnum::Examples
+
+using namespace Magnum::Examples;
+
+MAGNUM_APPLICATION_MAIN(Magnum::Examples::app)
+
+#ifdef _MSC_VER
+# include <cstdlib>
+# ifdef __clang__
+# pragma clang diagnostic ignored "-Wmissing-prototypes"
+# pragma clang diagnostic ignored "-Wmain"
+# endif
+
+extern "C" int __stdcall WinMain(void*, void*, void*, int /* nCmdShow */) {
+ return main(__argc, __argv);
+}
+#endif