選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

615 行
20 KiB

  1. //
  2. // Lol Engine — Fractal tutorial
  3. //
  4. // Copyright © 2011—2016 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // Lol Engine is free software. It comes without any warranty, to
  7. // the extent permitted by applicable law. You can redistribute it
  8. // and/or modify it under the terms of the Do What the Fuck You Want
  9. // to Public License, Version 2, as published by the WTFPL Task Force.
  10. // See http://www.wtfpl.net/ for more details.
  11. //
  12. #if HAVE_CONFIG_H
  13. # include "config.h"
  14. #endif
  15. #include <cstring>
  16. #include <cstdio>
  17. #include <lol/engine.h>
  18. #include "loldebug.h"
  19. #define USE_REAL 0
  20. using namespace lol;
  21. LOLFX_RESOURCE_DECLARE(11_fractal);
  22. class Fractal : public WorldEntity
  23. {
  24. public:
  25. Fractal(ivec2 const &size)
  26. : m_julia(false)
  27. {
  28. /* Ensure texture size is a multiple of 16 for better aligned
  29. * data access. Store the dimensions of a texel for our shader,
  30. * as well as the half-size of the screen. */
  31. m_size = size;
  32. m_size.x = (m_size.x + 15) & ~15;
  33. m_size.y = (m_size.y + 15) & ~15;
  34. m_texel_settings = vec4(1.0, 1.0, 2.0, 2.0) / (vec4)m_size.xyxy;
  35. m_screen_settings = vec4(1.0, 1.0, 0.5, 0.5) * (vec4)m_size.xyxy;
  36. m_controller = new Controller("Default");
  37. m_profile << InputProfile::MouseKey(0, "Left")
  38. << InputProfile::MouseKey(1, "Right")
  39. << InputProfile::MouseKey(2, "Middle")
  40. << InputProfile::Keyboard(3, "Space");
  41. m_controller->Init(m_profile);
  42. m_mouse = InputDevice::GetMouse();
  43. /* Window size decides the world aspect ratio. For instance, 640×480
  44. * will be mapped to (-0.66,-0.5) - (0.66,0.5). */
  45. #if !defined __native_client__
  46. m_window_size = Video::GetSize();
  47. #else
  48. /* FIXME: it's illegal to call this on the game thread! */
  49. m_window_size = ivec2(640, 480);
  50. #endif
  51. if (m_window_size.y < m_window_size.x)
  52. m_window2world = 0.5 / m_window_size.y;
  53. else
  54. m_window2world = 0.5 / m_window_size.x;
  55. m_texel2world = (dvec2)m_window_size / (dvec2)m_size * m_window2world;
  56. m_oldmouse = ivec2(0, 0);
  57. m_pixels.resize(m_size.x * m_size.y);
  58. m_frame = -1;
  59. m_slices = 4;
  60. for (int i = 0; i < 4; i++)
  61. {
  62. m_deltashift[i] = real("0");
  63. m_deltascale[i] = real("1");
  64. m_dirty[i] = 2;
  65. }
  66. m_view.center = rcmplx(-0.75, 0.0);
  67. m_zoom_speed = 0.0;
  68. m_view.translate = rcmplx(0.0, 0.0);
  69. m_view.radius = 5.0;
  70. m_ready = false;
  71. m_drag = false;
  72. for (int i = 0; i < (MAX_ITERATIONS + 1) * PALETTE_STEP; i++)
  73. {
  74. double f = (double)i / PALETTE_STEP;
  75. vec3 hsv(lol::fmod(i * 0.001f, 1.f),
  76. 0.3 * lol::sin(f * 0.27 + 2.0) + 0.3,
  77. 0.3 * lol::sin(f * 0.21 - 2.6) + 0.6);
  78. vec3 rgb = Color::HSVToRGB(hsv);
  79. if (f < 7.0)
  80. {
  81. rgb *= f < 1.0 ? 0.0 : (f - 1.0) / 6.0;
  82. }
  83. uint8_t red = (uint8_t)(rgb.r * 256);
  84. uint8_t green = (uint8_t)(rgb.g * 256);
  85. uint8_t blue = (uint8_t)(rgb.b * 256);
  86. #if defined __native_client__
  87. m_palette.push(u8vec4(red, green, blue, 255));
  88. #else
  89. m_palette.push(u8vec4(blue, green, red, 255));
  90. #endif
  91. }
  92. #if !defined __native_client__
  93. m_zoomtext = new Text("", "data/font/ascii.png");
  94. m_zoomtext->SetPos(vec3(5, (float)m_window_size.y - 15, 1));
  95. Ticker::Ref(m_zoomtext);
  96. m_centertext = new Text("", "data/font/ascii.png");
  97. m_centertext->SetPos(vec3(5, (float)m_window_size.y - 29, 1));
  98. Ticker::Ref(m_centertext);
  99. m_mousetext = new Text("", "data/font/ascii.png");
  100. m_mousetext->SetPos(vec3(5, (float)m_window_size.y - 43, 1));
  101. Ticker::Ref(m_mousetext);
  102. #endif
  103. m_position = vec3::zero;
  104. m_aabb.aa = m_position;
  105. m_aabb.bb = vec3((vec2)m_window_size, 0);
  106. #if LOL_FEATURE_THREADS
  107. /* Spawn worker threads and wait for their readiness. */
  108. for (int i = 0; i < MAX_THREADS; i++)
  109. m_threads[i] = new thread(std::bind(&Fractal::DoWorkHelper, this, std::placeholders::_1));
  110. for (int i = 0; i < MAX_THREADS; i++)
  111. m_spawnqueue.pop();
  112. #endif
  113. }
  114. ~Fractal()
  115. {
  116. #if LOL_FEATURE_THREADS
  117. /* Signal worker threads for completion and wait for
  118. * them to quit. */
  119. for (int i = 0; i < MAX_THREADS; i++)
  120. m_jobqueue.push(-1);
  121. for (int i = 0; i < MAX_THREADS; i++)
  122. m_donequeue.pop();
  123. #endif
  124. #if !defined __native_client__
  125. Ticker::Unref(m_centertext);
  126. Ticker::Unref(m_mousetext);
  127. Ticker::Unref(m_zoomtext);
  128. #endif
  129. }
  130. inline f128cmplx TexelToWorldOffset(vec2 texel)
  131. {
  132. double dx = (0.5 + texel.x - m_size.x / 2) * m_texel2world.x;
  133. double dy = (0.5 + m_size.y / 2 - texel.y) * m_texel2world.y;
  134. return m_view.radius * f128cmplx(dx, dy);
  135. }
  136. inline f128cmplx ScreenToWorldOffset(vec2 pixel)
  137. {
  138. /* No 0.5 offset here, because we want to be able to position the
  139. * mouse at (0,0) exactly. */
  140. double dx = pixel.x - m_window_size.x / 2;
  141. double dy = m_window_size.y / 2 - pixel.y;
  142. return m_view.radius * m_window2world * f128cmplx(dx, dy);
  143. }
  144. virtual void TickGame(float seconds)
  145. {
  146. WorldEntity::TickGame(seconds);
  147. ivec2 mousepos = m_mouse->GetCursorPixel(0);
  148. int prev_frame = (m_frame + 4) % 4;
  149. m_frame = (m_frame + 1) % 4;
  150. if (m_controller->WasKeyPressedThisFrame(3))
  151. {
  152. m_julia = !m_julia;
  153. if (m_julia)
  154. {
  155. m_saved_view = m_view;
  156. m_view.r0 = m_view.center + rcmplx(ScreenToWorldOffset((vec2)mousepos));
  157. }
  158. else
  159. {
  160. m_view = m_saved_view;
  161. }
  162. for (auto & flag : m_dirty)
  163. flag = 2;
  164. }
  165. rcmplx worldmouse = m_view.center + rcmplx(ScreenToWorldOffset((vec2)mousepos));
  166. if (m_controller->IsKeyPressed(2))
  167. {
  168. if (!m_drag)
  169. {
  170. m_oldmouse = mousepos;
  171. m_drag = true;
  172. }
  173. m_view.translate = rcmplx(ScreenToWorldOffset((vec2)m_oldmouse)
  174. - ScreenToWorldOffset((vec2)mousepos));
  175. /* XXX: the purpose of this hack is to avoid translating by
  176. * an exact number of pixels. If this were to happen, the step()
  177. * optimisation for i915 cards in our shader would behave
  178. * incorrectly because a quarter of the pixels in the image
  179. * would have tied rankings in the distance calculation. */
  180. m_view.translate *= real(1023.0 / 1024.0);
  181. m_oldmouse = mousepos;
  182. }
  183. else
  184. {
  185. m_drag = false;
  186. if (m_view.translate != rcmplx(0.0, 0.0))
  187. {
  188. m_view.translate *= real(std::pow(2.0, -seconds * 5.0));
  189. if ((double)norm(m_view.translate) < m_view.radius * 1e-4)
  190. m_view.translate = rcmplx(0.0, 0.0);
  191. }
  192. }
  193. bool hold_right = m_controller->IsKeyPressed(0);
  194. bool hold_left = m_controller->IsKeyPressed(1);
  195. if ((hold_right || hold_left) && mousepos.x != -1)
  196. {
  197. double zoom = hold_right ? -0.5 : 0.5;
  198. m_zoom_speed += zoom * seconds;
  199. if (m_zoom_speed / zoom > 5e-3f)
  200. m_zoom_speed = zoom * 5e-3f;
  201. }
  202. else if (m_zoom_speed)
  203. {
  204. m_zoom_speed *= std::pow(2.0, -seconds * 5.0);
  205. if (lol::abs(m_zoom_speed) < 1e-5 || m_drag)
  206. m_zoom_speed = 0.0;
  207. }
  208. if (m_zoom_speed || m_view.translate != rcmplx(0.0, 0.0))
  209. {
  210. rcmplx oldcenter = m_view.center;
  211. double oldradius = m_view.radius;
  212. double zoom = std::pow(2.0, seconds * 1e3f * m_zoom_speed);
  213. if (m_view.radius * zoom > 8.0)
  214. {
  215. m_zoom_speed *= -1.0;
  216. zoom = 8.0 / m_view.radius;
  217. }
  218. else if (m_view.radius * zoom < MAX_ZOOM)
  219. {
  220. m_zoom_speed *= -1.0;
  221. zoom = MAX_ZOOM / m_view.radius;
  222. }
  223. m_view.radius *= zoom;
  224. m_view.center += m_view.translate;
  225. m_view.center = (m_view.center - worldmouse) * real(zoom) + worldmouse;
  226. worldmouse = m_view.center
  227. + rcmplx(ScreenToWorldOffset((vec2)mousepos));
  228. /* Store the transformation properties to go from m_frame - 1
  229. * to m_frame. */
  230. m_deltashift[prev_frame] = (m_view.center - oldcenter) / real(oldradius);
  231. m_deltashift[prev_frame].x /= m_size.x * m_texel2world.x;
  232. m_deltashift[prev_frame].y /= m_size.y * m_texel2world.y;
  233. m_deltascale[prev_frame] = m_view.radius / oldradius;
  234. for (auto & flag : m_dirty)
  235. flag = 2;
  236. }
  237. else
  238. {
  239. /* If settings didn't change, set transformation from previous
  240. * frame to identity. */
  241. m_deltashift[prev_frame] = real::R_0();
  242. m_deltascale[prev_frame] = real::R_1();
  243. }
  244. /* Transformation from current frame to current frame is always
  245. * identity. */
  246. m_zoom_settings[m_frame][0] = 0.0f;
  247. m_zoom_settings[m_frame][1] = 0.0f;
  248. m_zoom_settings[m_frame][2] = 1.0f;
  249. /* Compute transformation from other frames to current frame */
  250. for (int i = 0; i < 3; i++)
  251. {
  252. int prev_index = (m_frame + 4 - i) % 4;
  253. int cur_index = (m_frame + 3 - i) % 4;
  254. m_zoom_settings[cur_index][0] = (real)m_zoom_settings[prev_index][0] * m_deltascale[cur_index] + m_deltashift[cur_index].x;
  255. m_zoom_settings[cur_index][1] = (real)m_zoom_settings[prev_index][1] * m_deltascale[cur_index] + m_deltashift[cur_index].y;
  256. m_zoom_settings[cur_index][2] = (real)m_zoom_settings[prev_index][2] * m_deltascale[cur_index];
  257. }
  258. /* Precompute texture offset change instead of doing it in GLSL */
  259. for (int i = 0; i < 4; i++)
  260. {
  261. m_zoom_settings[i][0] += 0.5f * (1.0f - m_zoom_settings[i][2]);
  262. m_zoom_settings[i][1] -= 0.5f * (1.0f - m_zoom_settings[i][2]);
  263. }
  264. #if !defined __native_client__
  265. char buf[256];
  266. std::sprintf(buf, "center: ");
  267. m_view.center.x.sprintf(buf + strlen(buf), 30);
  268. std::sprintf(buf + strlen(buf), " ");
  269. m_view.center.y.sprintf(buf + strlen(buf), 30);
  270. m_centertext->SetText(buf);
  271. std::sprintf(buf, " mouse: ");
  272. worldmouse.x.sprintf(buf + strlen(buf), 30);
  273. std::sprintf(buf + strlen(buf), " ");
  274. worldmouse.y.sprintf(buf + strlen(buf), 30);
  275. m_mousetext->SetText(buf);
  276. std::sprintf(buf, "[%s] zoom: %g", m_julia ? "Julia" : "Mandelbrot", 1.0 / m_view.radius);
  277. m_zoomtext->SetText(buf);
  278. #endif
  279. if (m_dirty[m_frame])
  280. {
  281. m_dirty[m_frame]--;
  282. for (int i = 0; i < m_size.y; i += MAX_LINES * 2)
  283. {
  284. #if LOL_FEATURE_THREADS
  285. m_jobqueue.push(i);
  286. #else
  287. DoWork(i);
  288. #endif
  289. }
  290. }
  291. }
  292. #if LOL_FEATURE_THREADS
  293. void DoWorkHelper(thread *)
  294. {
  295. m_spawnqueue.push(0);
  296. for ( ; ; )
  297. {
  298. int line = m_jobqueue.pop();
  299. if (line == -1)
  300. break;
  301. DoWork(line);
  302. m_donequeue.push(0);
  303. }
  304. m_donequeue.push(0);
  305. };
  306. #endif
  307. void DoWork(int line)
  308. {
  309. double const maxsqlen = 1024;
  310. double const k1 = 1.0 / (1 << 10) / (std::log(maxsqlen) / std::log(2.0));
  311. int jmin = ((m_frame + 1) % 4) / 2 + line;
  312. int jmax = jmin + MAX_LINES * 2;
  313. if (jmax > m_size.y)
  314. jmax = m_size.y;
  315. u8vec4 *pixelstart = &m_pixels[0]
  316. + m_size.x * (m_size.y / 4 * m_frame + line / 4);
  317. #if USE_REAL
  318. rcmplx c = (rcmplx)m_view.center;
  319. rcmplx jr0 = (rcmplx)m_view.r0;
  320. #else
  321. f128cmplx c = (f128cmplx)m_view.center;
  322. f128cmplx jr0 = (f128cmplx)m_view.r0;
  323. #endif
  324. for (int j = jmin; j < jmax; j += 2)
  325. for (int i = m_frame % 2; i < m_size.x; i += 2)
  326. {
  327. #if USE_REAL
  328. real xr, yr, x0, y0, x1, y1, x2, y2, x3, y3;
  329. real sqx0, sqy0, sqx1, sqy1, sqx2, sqy2, sqx3, sqy3;
  330. rcmplx z0 = c + rcmplx(TexelToWorldOffset(vec2(ivec2(i, j))));
  331. rcmplx r0 = m_julia ? jr0 : z0;
  332. #else
  333. ldouble xr, yr, x0, y0, x1, y1, x2, y2, x3, y3;
  334. ldouble sqx0, sqy0, sqx1, sqy1, sqx2, sqy2, sqx3, sqy3;
  335. f128cmplx z0 = c + TexelToWorldOffset(vec2(ivec2(i, j)));
  336. f128cmplx r0 = m_julia ? jr0 : z0;
  337. #endif
  338. x0 = z0.x; y0 = z0.y;
  339. xr = r0.x; yr = r0.y;
  340. sqx0 = x0 * x0; sqy0 = y0 * y0;
  341. int iter = MAX_ITERATIONS - 4;
  342. for (;;)
  343. {
  344. /* Unroll the loop: tests are more expensive to do at each
  345. * iteration than the few extra multiplications, at least
  346. * with floats/doubles. */
  347. x1 = sqx0 - sqy0 + xr; y1 = x0 * y0 + x0 * y0 + yr;
  348. sqx1 = x1 * x1; sqy1 = y1 * y1;
  349. x2 = sqx1 - sqy1 + xr; y2 = x1 * y1 + x1 * y1 + yr;
  350. sqx2 = x2 * x2; sqy2 = y2 * y2;
  351. x3 = sqx2 - sqy2 + xr; y3 = x2 * y2 + x2 * y2 + yr;
  352. sqx3 = x3 * x3; sqy3 = y3 * y3;
  353. x0 = sqx3 - sqy3 + xr; y0 = x3 * y3 + x3 * y3 + yr;
  354. sqx0 = x0 * x0; sqy0 = y0 * y0;
  355. if ((double)sqx0 + (double)sqy0 >= maxsqlen)
  356. break;
  357. iter -= 4;
  358. if (iter < 4)
  359. break;
  360. }
  361. if (iter)
  362. {
  363. double n = (double)sqx0 + (double)sqy0;
  364. if ((double)sqx1 + (double)sqy1 >= maxsqlen)
  365. {
  366. iter += 3; n = (double)sqx1 + (double)sqy1;
  367. }
  368. else if ((double)sqx2 + (double)sqy2 >= maxsqlen)
  369. {
  370. iter += 2; n = (double)sqx2 + (double)sqy2;
  371. }
  372. else if ((double)sqx3 + (double)sqy3 >= maxsqlen)
  373. {
  374. iter += 1; n = (double)sqx3 + (double)sqy3;
  375. }
  376. if (n > maxsqlen * maxsqlen)
  377. n = maxsqlen * maxsqlen;
  378. /* Approximate log(sqrt(n))/log(sqrt(maxsqlen)) */
  379. double f = iter;
  380. union { double n; uint64_t x; } u = { (double)n };
  381. double k = (double)(u.x >> 42) - (((1 << 10) - 1) << 10);
  382. k *= k1;
  383. /* Approximate log2(k) in [1,2]. */
  384. f += (- 0.344847817623168308695977510213252644185 * k
  385. + 2.024664188044341212602376988171727038739) * k
  386. - 1.674876738008591047163498125918330313237;
  387. *pixelstart++ = m_palette[(int)(f * PALETTE_STEP)];
  388. }
  389. else
  390. {
  391. *pixelstart++ = u8vec4(0, 0, 0, 255);
  392. }
  393. }
  394. }
  395. virtual void TickDraw(float seconds, Scene &scene)
  396. {
  397. WorldEntity::TickDraw(seconds, scene);
  398. static float const vertices[] =
  399. {
  400. 1.0f, 1.0f,
  401. -1.0f, 1.0f,
  402. -1.0f, -1.0f,
  403. -1.0f, -1.0f,
  404. 1.0f, -1.0f,
  405. 1.0f, 1.0f,
  406. };
  407. static float const texcoords[] =
  408. {
  409. 1.0f, 1.0f,
  410. 0.0f, 1.0f,
  411. 0.0f, 0.0f,
  412. 0.0f, 0.0f,
  413. 1.0f, 0.0f,
  414. 1.0f, 1.0f,
  415. };
  416. if (!m_ready)
  417. {
  418. /* Create a texture of half the width and twice the height
  419. * so that we can upload four different subimages each frame. */
  420. m_texture = new Texture(ivec2(m_size.x / 2, m_size.y * 2),
  421. PixelFormat::RGBA_8);
  422. /* Ensure the texture data is complete at least once, otherwise
  423. * uploading subimages will not work. */
  424. m_texture->SetData(&m_pixels[0]);
  425. m_shader = Shader::Create(LOLFX_RESOURCE_NAME(11_fractal));
  426. m_vertexattrib = m_shader->GetAttribLocation(VertexUsage::Position, 0);
  427. m_texattrib = m_shader->GetAttribLocation(VertexUsage::TexCoord, 0);
  428. m_texuni = m_shader->GetUniformLocation("u_texture");
  429. m_texeluni = m_shader->GetUniformLocation("u_texel_size");
  430. m_screenuni = m_shader->GetUniformLocation("u_screen_size");
  431. m_zoomuni = m_shader->GetUniformLocation("u_zoom_settings");
  432. m_vdecl =
  433. new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position),
  434. VertexStream<vec2>(VertexUsage::TexCoord));
  435. m_vbo = new VertexBuffer(sizeof(vertices));
  436. m_tbo = new VertexBuffer(sizeof(texcoords));
  437. void *tmp = m_vbo->Lock(0, 0);
  438. memcpy(tmp, vertices, sizeof(vertices));
  439. m_vbo->Unlock();
  440. tmp = m_tbo->Lock(0, 0);
  441. memcpy(tmp, texcoords, sizeof(texcoords));
  442. m_tbo->Unlock();
  443. /* FIXME: this object never cleans up */
  444. m_ready = true;
  445. }
  446. m_texture->Bind();
  447. if (m_dirty[m_frame])
  448. {
  449. #if LOL_FEATURE_THREADS
  450. for (int i = 0; i < m_size.y; i += MAX_LINES * 2)
  451. m_donequeue.pop();
  452. #endif
  453. m_dirty[m_frame]--;
  454. m_texture->SetSubData(ivec2(0, m_frame * m_size.y / 2),
  455. m_size / 2,
  456. &m_pixels[m_size.x * m_size.y / 4 * m_frame]);
  457. }
  458. m_shader->Bind();
  459. m_shader->SetUniform(m_texuni, m_texture->GetTextureUniform(), 0);
  460. m_shader->SetUniform(m_texeluni, m_texel_settings);
  461. m_shader->SetUniform(m_screenuni, m_screen_settings);
  462. m_shader->SetUniform(m_zoomuni, m_zoom_settings);
  463. m_vdecl->Bind();
  464. m_vdecl->SetStream(m_vbo, m_vertexattrib);
  465. m_vdecl->SetStream(m_tbo, m_texattrib);
  466. m_texture->Bind();
  467. m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 6);
  468. m_vdecl->Unbind();
  469. }
  470. private:
  471. static int const MAX_ITERATIONS = 400;
  472. static int const PALETTE_STEP = 32;
  473. static int const MAX_THREADS = 8;
  474. static int const MAX_LINES = 8;
  475. // 1e-14 for doubles, 1e-17 for long doubles
  476. static double constexpr MAX_ZOOM = 1e-17;
  477. ivec2 m_size, m_window_size, m_oldmouse;
  478. double m_window2world;
  479. dvec2 m_texel2world;
  480. array<u8vec4> m_pixels, m_palette;
  481. Shader *m_shader;
  482. ShaderAttrib m_vertexattrib, m_texattrib;
  483. ShaderUniform m_texuni, m_texeluni, m_screenuni, m_zoomuni;
  484. VertexDeclaration *m_vdecl;
  485. VertexBuffer *m_vbo, *m_tbo;
  486. Texture *m_texture;
  487. int m_frame, m_slices, m_dirty[4];
  488. bool m_ready, m_drag;
  489. struct view_settings
  490. {
  491. rcmplx center, translate, r0;
  492. double radius;
  493. };
  494. view_settings m_view, m_saved_view;
  495. rcmplx m_deltashift[4];
  496. real m_deltascale[4];
  497. double m_zoom_speed;
  498. bool m_julia;
  499. vec4 m_texel_settings, m_screen_settings;
  500. mat4 m_zoom_settings;
  501. // Input support
  502. InputDevice *m_mouse;
  503. Controller *m_controller;
  504. InputProfile m_profile;
  505. #if LOL_FEATURE_THREADS
  506. /* Worker threads */
  507. thread *m_threads[MAX_THREADS];
  508. queue<int> m_spawnqueue, m_jobqueue, m_donequeue;
  509. #endif
  510. #if !defined __native_client__
  511. /* Debug information */
  512. Text *m_centertext, *m_mousetext, *m_zoomtext;
  513. #endif
  514. };
  515. int main(int argc, char **argv)
  516. {
  517. ivec2 window_size(640, 480);
  518. sys::init(argc, argv);
  519. Application app("Tutorial 11: Fractal", window_size, 60.0f);
  520. new DebugFps(5, 5);
  521. new Fractal(window_size);
  522. //new DebugRecord("fractalol.ogm", 60.0f);
  523. app.Run();
  524. return EXIT_SUCCESS;
  525. }