crown.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #include "crown.h"
  6. #include "memory.h"
  7. #include "console_server.h"
  8. #include "bundle_compiler.h"
  9. #include "device.h"
  10. #include "command_line.h"
  11. #include "json_parser.h"
  12. #include "main.h"
  13. #include "audio.h"
  14. #include "physics.h"
  15. #include "disk_filesystem.h"
  16. #include "config.h"
  17. #include "math_utils.h"
  18. #include "profiler.h"
  19. #include "temp_allocator.h"
  20. #include <bgfx.h>
  21. namespace crown
  22. {
  23. static void help(const char* msg = NULL)
  24. {
  25. if (msg)
  26. {
  27. printf("Error: %s\n", msg);
  28. }
  29. printf(
  30. "Usage: crown [options]\n"
  31. "Options:\n\n"
  32. " -h --help Show this help.\n"
  33. " -v --version Show version informations.\n"
  34. " --bundle-dir <path> Use <path> as the source directory for compiled resources.\n"
  35. " --console-port <port> Set port of the console.\n"
  36. " --parent-window <handle> Set the parent window <handle> of the main window.\n"
  37. " Used only by tools.\n"
  38. "\nAvailable only in debug and development builds:\n\n"
  39. " --source-dir <path> Use <path> as the source directory for resource compilation.\n"
  40. " --project <name> Start the project <name>.\n"
  41. " --compile Do a full compile of the resources.\n"
  42. " --platform <platform> Compile resources for the given <platform>.\n"
  43. " Possible values for <platform> are:\n"
  44. " linux\n"
  45. " windows\n"
  46. " android\n"
  47. " --continue Continue the execution after the resource compilation step.\n"
  48. " --wait-console Wait for a console connection before starting up.\n"
  49. );
  50. }
  51. bool init(const DeviceOptions& opts, Filesystem& fs)
  52. {
  53. profiler_globals::init();
  54. audio_globals::init();
  55. physics_globals::init();
  56. bgfx::init();
  57. device_globals::init(opts, fs);
  58. return true;
  59. }
  60. void update()
  61. {
  62. while (!process_events() && device()->is_running())
  63. {
  64. profiler_globals::clear();
  65. console_server_globals::update();
  66. device()->update();
  67. bgfx::frame();
  68. profiler_globals::flush();
  69. }
  70. }
  71. void shutdown()
  72. {
  73. device_globals::shutdown();
  74. bgfx::shutdown();
  75. physics_globals::shutdown();
  76. audio_globals::shutdown();
  77. profiler_globals::shutdown();
  78. }
  79. } // namespace crown