summaryrefslogtreecommitdiffhomepage
path: root/test/main.cpp
blob: f7014255f1bbfacec5a5d79ecd0551279029e912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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