Mercurial > malikania
comparison examples/image/main.cpp @ 82:ee850a6ab89e
Client: namespace and hierarchy
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 22 Jan 2017 11:07:36 +0100 |
parents | 301599387b40 |
children | f4d23ad4aa27 |
comparison
equal
deleted
inserted
replaced
81:301599387b40 | 82:ee850a6ab89e |
---|---|
17 */ | 17 */ |
18 | 18 |
19 #include <chrono> | 19 #include <chrono> |
20 #include <thread> | 20 #include <thread> |
21 | 21 |
22 #include <malikania/client_resources_loader.hpp> | 22 #include <malikania/client/loader.hpp> |
23 #include <malikania/image.hpp> | 23 #include <malikania/client/image.hpp> |
24 #include <malikania/client/window.hpp> | |
24 #include <malikania/locator.hpp> | 25 #include <malikania/locator.hpp> |
25 #include <malikania/window.hpp> | |
26 | 26 |
27 using namespace std::chrono_literals; | 27 using namespace std::chrono_literals; |
28 | 28 |
29 void draw(mlk::window& window, mlk::client_resources_loader& loader) | 29 void draw(mlk::client::window& window, mlk::client::loader& loader) |
30 { | 30 { |
31 try { | 31 try { |
32 auto image = loader.load_image("images/smiley.png"); | 32 auto image = loader.load_image("images/smiley.png"); |
33 auto x = (400 / 2) - (image.size().width() / 2); | 33 auto x = (400 / 2) - (image.size().width() / 2); |
34 auto y = (400 / 2) - (image.size().height() / 2); | 34 auto y = (400 / 2) - (image.size().height() / 2); |
35 | 35 |
36 window.clear(); | 36 window.clear(); |
37 image.draw(window, mlk::point(x, y)); | 37 image.draw(window, mlk::client::point(x, y)); |
38 window.present(); | 38 window.present(); |
39 | 39 |
40 std::this_thread::sleep_for(3s); | 40 std::this_thread::sleep_for(3s); |
41 } catch (const std::exception &ex) { | 41 } catch (const std::exception &ex) { |
42 std::cerr << ex.what() << std::endl; | 42 std::cerr << ex.what() << std::endl; |
45 } | 45 } |
46 | 46 |
47 int main() | 47 int main() |
48 { | 48 { |
49 try { | 49 try { |
50 mlk::window window(400, 400); | 50 mlk::client::window window(400, 400); |
51 mlk::directory_locator locator(SOURCE_DIRECTORY); | 51 mlk::directory_locator locator(SOURCE_DIRECTORY); |
52 mlk::client_resources_loader loader(locator); | 52 mlk::client::loader loader(locator); |
53 | 53 |
54 draw(window, loader); | 54 draw(window, loader); |
55 } catch (const std::exception& ex) { | 55 } catch (const std::exception& ex) { |
56 std::cerr << ex.what() << std::endl; | 56 std::cerr << ex.what() << std::endl; |
57 return 1; | 57 return 1; |