Device.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /*
  2. Copyright (c) 2013 Daniele Bartolini, Michele Rossi
  3. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  4. Permission is hereby granted, free of charge, to any person
  5. obtaining a copy of this software and associated documentation
  6. files (the "Software"), to deal in the Software without
  7. restriction, including without limitation the rights to use,
  8. copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the
  10. Software is furnished to do so, subject to the following
  11. conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  16. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. OTHER DEALINGS IN THE SOFTWARE.
  22. OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. #include <cstdlib>
  25. #include <unistd.h>
  26. #include "Config.h"
  27. #include "Device.h"
  28. #include "Accelerometer.h"
  29. #include "Args.h"
  30. #include "ConsoleServer.h"
  31. #include "DebugRenderer.h"
  32. #include "DiskFile.h"
  33. #include "DiskFilesystem.h"
  34. #include "InputManager.h"
  35. #include "JSONParser.h"
  36. #include "Keyboard.h"
  37. #include "Log.h"
  38. #include "LuaEnvironment.h"
  39. #include "Memory.h"
  40. #include "Mouse.h"
  41. #include "OS.h"
  42. #include "OsWindow.h"
  43. #include "Renderer.h"
  44. #include "ResourceManager.h"
  45. #include "StringSetting.h"
  46. #include "StringUtils.h"
  47. #include "TextReader.h"
  48. #include "Touch.h"
  49. #include "Types.h"
  50. #include "Bundle.h"
  51. #include "TempAllocator.h"
  52. #include "ResourcePackage.h"
  53. #include "EventBuffer.h"
  54. #include "SoundRenderer.h"
  55. #if defined(LINUX) || defined(WINDOWS)
  56. #include "BundleCompiler.h"
  57. #endif
  58. #if defined(ANDROID)
  59. #include "ApkFilesystem.h"
  60. #endif
  61. #define MAX_SUBSYSTEMS_HEAP 16 * 1024 * 1024
  62. namespace crown
  63. {
  64. //-----------------------------------------------------------------------------
  65. Device::Device() :
  66. m_allocator(default_allocator(), MAX_SUBSYSTEMS_HEAP),
  67. m_preferred_window_width(1000),
  68. m_preferred_window_height(625),
  69. m_preferred_window_fullscreen(0),
  70. m_parent_window_handle(0),
  71. m_compile(0),
  72. m_continue(0),
  73. m_quit_after_init(0),
  74. m_is_init(false),
  75. m_is_running(false),
  76. m_is_paused(false),
  77. m_is_really_paused(false),
  78. m_frame_count(0),
  79. m_last_time(0),
  80. m_current_time(0),
  81. m_last_delta_time(0.0f),
  82. m_time_since_start(0.0),
  83. m_filesystem(NULL),
  84. m_input_manager(NULL),
  85. m_lua_environment(NULL),
  86. m_renderer(NULL),
  87. m_debug_renderer(NULL),
  88. m_sound_renderer(NULL),
  89. m_bundle_compiler(NULL),
  90. m_resource_manager(NULL),
  91. m_resource_bundle(NULL),
  92. m_console_server(NULL)
  93. {
  94. // Bundle dir is current dir by default.
  95. string::strncpy(m_bundle_dir, os::get_cwd(), MAX_PATH_LENGTH);
  96. string::strncpy(m_source_dir, "", MAX_PATH_LENGTH);
  97. string::strncpy(m_boot_file, "lua/game", MAX_PATH_LENGTH);
  98. }
  99. //-----------------------------------------------------------------------------
  100. Device::~Device()
  101. {
  102. }
  103. //-----------------------------------------------------------------------------
  104. bool Device::init(int argc, char** argv)
  105. {
  106. CE_ASSERT(!is_init(), "Engine already initialized");
  107. parse_command_line(argc, argv);
  108. check_preferred_settings();
  109. // Resource compilation only in debug or development mode and only on linux or windows builds
  110. #if (defined(LINUX) || defined(WINDOWS)) && (defined(CROWN_DEBUG) || defined(CROWN_DEVELOPMENT))
  111. if (m_compile == 1)
  112. {
  113. m_bundle_compiler = CE_NEW(m_allocator, BundleCompiler);
  114. if (!m_bundle_compiler->compile(m_bundle_dir, m_source_dir))
  115. {
  116. CE_DELETE(m_allocator, m_bundle_compiler);
  117. m_allocator.clear();
  118. Log::e("Exiting.");
  119. exit(EXIT_FAILURE);
  120. }
  121. if (!m_continue)
  122. {
  123. CE_DELETE(m_allocator, m_bundle_compiler);
  124. m_allocator.clear();
  125. exit(EXIT_SUCCESS);
  126. }
  127. }
  128. #endif
  129. init();
  130. return true;
  131. }
  132. //-----------------------------------------------------------------------------
  133. void Device::init()
  134. {
  135. // Initialize
  136. Log::i("Initializing Crown Engine %d.%d.%d...", CROWN_VERSION_MAJOR, CROWN_VERSION_MINOR, CROWN_VERSION_MICRO);
  137. // Default bundle filesystem
  138. #if defined (LINUX) || defined(WINDOWS)
  139. m_filesystem = CE_NEW(m_allocator, DiskFilesystem)(m_bundle_dir);
  140. #elif defined(ANDROID)
  141. m_filesystem = CE_NEW(m_allocator, ApkFilesystem)();
  142. #endif
  143. Log::d("Filesystem created.");
  144. // Read settings from crown.config
  145. read_engine_settings();
  146. m_resource_bundle = Bundle::create(m_allocator, *m_filesystem);
  147. // // Read resource seed
  148. // DiskFile* seed_file = (DiskFile*)filesystem()->open(g_default_mountpoint.value(), "seed.ini", FOM_READ);
  149. // TextReader reader(*seed_file);
  150. // char tmp_buf[32];
  151. // reader.read_string(tmp_buf, 32);
  152. // filesystem()->close(seed_file);
  153. // uint32_t seed = string::parse_uint(tmp_buf);
  154. // Create resource manager
  155. m_resource_manager = CE_NEW(m_allocator, ResourceManager)(*m_resource_bundle, 0);
  156. Log::d("Resource manager created.");
  157. Log::d("Resource seed: %d", m_resource_manager->seed());
  158. // Create input manager
  159. m_input_manager = CE_NEW(m_allocator, InputManager)();
  160. Log::d("Input manager created.");
  161. // default_allocator, maybe it needs fix
  162. m_window = CE_NEW(m_allocator, OsWindow)(m_preferred_window_width, m_preferred_window_height, m_parent_window_handle);
  163. CE_ASSERT(m_window != NULL, "Unable to create the window");
  164. // Create main window
  165. m_window->set_title("Crown Game Engine");
  166. Log::d("Window created.");
  167. // Create renderer
  168. m_renderer = CE_NEW(m_allocator, Renderer)(m_allocator);
  169. m_renderer->init();
  170. m_renderer_init_request = false;
  171. Log::d("Renderer created.");
  172. // Create debug renderer
  173. m_debug_renderer = CE_NEW(m_allocator, DebugRenderer)(*m_renderer);
  174. Log::d("Debug renderer created.");
  175. m_lua_environment = CE_NEW(m_allocator, LuaEnvironment)();
  176. m_lua_environment->init();
  177. Log::d("Lua environment created.");
  178. m_sound_renderer = CE_NEW(m_allocator, SoundRenderer)(m_allocator);
  179. m_sound_renderer->init();
  180. Log::d("SoundRenderer created.");
  181. Log::i("Crown Engine initialized.");
  182. Log::i("Initializing Game...");
  183. m_is_init = true;
  184. start();
  185. // Show main window
  186. m_window->show();
  187. // Execute lua boot file
  188. if (m_lua_environment->load_and_execute(m_boot_file))
  189. {
  190. if (!m_lua_environment->call_global("init", 0))
  191. {
  192. pause();
  193. }
  194. }
  195. else
  196. {
  197. pause();
  198. }
  199. Log::d("Total allocated size: %llu", m_allocator.allocated_size());
  200. if (m_quit_after_init == 1)
  201. {
  202. stop();
  203. shutdown();
  204. }
  205. }
  206. //-----------------------------------------------------------------------------
  207. void Device::shutdown()
  208. {
  209. CE_ASSERT(is_init(), "Engine is not initialized");
  210. // Shutdowns the game
  211. m_lua_environment->call_global("shutdown", 0);
  212. Log::i("Releasing ConsoleServer...");
  213. if (m_console_server)
  214. {
  215. //m_console_server->shutdown();
  216. CE_DELETE(m_allocator, m_console_server);
  217. }
  218. Log::d("Releasing SoundRenderer...");
  219. if (m_sound_renderer)
  220. {
  221. m_sound_renderer->shutdown();
  222. // FIXME: replace default_allocator with linear m_allocator
  223. CE_DELETE(m_allocator, m_sound_renderer);
  224. }
  225. Log::i("Releasing LuaEnvironment...");
  226. if (m_lua_environment)
  227. {
  228. m_lua_environment->shutdown();
  229. CE_DELETE(m_allocator, m_lua_environment);
  230. }
  231. Log::i("Releasing InputManager...");
  232. if (m_input_manager)
  233. {
  234. CE_DELETE(m_allocator, m_input_manager);
  235. }
  236. Log::i("Releasing DebugRenderer...");
  237. if (m_debug_renderer)
  238. {
  239. CE_DELETE(m_allocator, m_debug_renderer);
  240. }
  241. Log::i("Releasing Renderer...");
  242. if (m_renderer)
  243. {
  244. m_renderer->shutdown();
  245. CE_DELETE(m_allocator, m_renderer);
  246. }
  247. Log::i("Releasing Window...");
  248. if (m_window)
  249. {
  250. CE_DELETE(m_allocator, m_window);
  251. }
  252. Log::i("Releasing ResourceManager...");
  253. if (m_resource_manager)
  254. {
  255. CE_DELETE(m_allocator, m_resource_manager);
  256. }
  257. if (m_resource_bundle)
  258. {
  259. Bundle::destroy(m_allocator, m_resource_bundle);
  260. }
  261. Log::i("Releasing Filesystem...");
  262. if (m_filesystem)
  263. {
  264. CE_DELETE(m_allocator, m_filesystem);
  265. }
  266. #if (defined(LINUX) || defined(WINDOWS)) && (defined(CROWN_DEBUG) || defined(CROWN_DEVELOPMENT))
  267. Log::i("Releasing BundleCompiler...");
  268. if (m_bundle_compiler)
  269. {
  270. CE_DELETE(m_allocator, m_bundle_compiler);
  271. }
  272. #endif
  273. m_allocator.clear();
  274. m_is_init = false;
  275. }
  276. //-----------------------------------------------------------------------------
  277. bool Device::is_init() const
  278. {
  279. return m_is_init;
  280. }
  281. //-----------------------------------------------------------------------------
  282. bool Device::is_paused() const
  283. {
  284. return m_is_paused;
  285. }
  286. //-----------------------------------------------------------------------------
  287. Filesystem* Device::filesystem()
  288. {
  289. return m_filesystem;
  290. }
  291. //-----------------------------------------------------------------------------
  292. ResourceManager* Device::resource_manager()
  293. {
  294. return m_resource_manager;
  295. }
  296. //-----------------------------------------------------------------------------
  297. InputManager* Device::input_manager()
  298. {
  299. return m_input_manager;
  300. }
  301. //-----------------------------------------------------------------------------
  302. LuaEnvironment* Device::lua_environment()
  303. {
  304. return m_lua_environment;
  305. }
  306. //-----------------------------------------------------------------------------
  307. OsWindow* Device::window()
  308. {
  309. return m_window;
  310. }
  311. //-----------------------------------------------------------------------------
  312. Renderer* Device::renderer()
  313. {
  314. return m_renderer;
  315. }
  316. //-----------------------------------------------------------------------------
  317. DebugRenderer* Device::debug_renderer()
  318. {
  319. return m_debug_renderer;
  320. }
  321. //-----------------------------------------------------------------------------
  322. SoundRenderer* Device::sound_renderer()
  323. {
  324. return m_sound_renderer;
  325. }
  326. //-----------------------------------------------------------------------------
  327. Keyboard* Device::keyboard()
  328. {
  329. return m_input_manager->keyboard();
  330. }
  331. //-----------------------------------------------------------------------------
  332. Mouse* Device::mouse()
  333. {
  334. return m_input_manager->mouse();
  335. }
  336. //-----------------------------------------------------------------------------
  337. Touch* Device::touch()
  338. {
  339. return m_input_manager->touch();
  340. }
  341. //-----------------------------------------------------------------------------
  342. Accelerometer* Device::accelerometer()
  343. {
  344. return m_input_manager->accelerometer();
  345. }
  346. //-----------------------------------------------------------------------------
  347. ConsoleServer* Device::console_server()
  348. {
  349. return m_console_server;
  350. }
  351. //-----------------------------------------------------------------------------
  352. void Device::start()
  353. {
  354. CE_ASSERT(m_is_init, "Cannot start uninitialized engine.");
  355. m_is_running = true;
  356. m_last_time = os::milliseconds();
  357. }
  358. //-----------------------------------------------------------------------------
  359. void Device::stop()
  360. {
  361. CE_ASSERT(m_is_init, "Cannot stop uninitialized engine.");
  362. m_is_running = false;
  363. }
  364. //-----------------------------------------------------------------------------
  365. void Device::pause()
  366. {
  367. m_is_paused = true;
  368. Log::d("Engine paused");
  369. }
  370. //-----------------------------------------------------------------------------
  371. void Device::unpause()
  372. {
  373. m_is_paused = false;
  374. m_is_really_paused = false;
  375. Log::d("Engine unpaused");
  376. }
  377. //-----------------------------------------------------------------------------
  378. bool Device::is_running() const
  379. {
  380. return m_is_running;
  381. }
  382. //-----------------------------------------------------------------------------
  383. uint64_t Device::frame_count() const
  384. {
  385. return m_frame_count;
  386. }
  387. //-----------------------------------------------------------------------------
  388. float Device::last_delta_time() const
  389. {
  390. return m_last_delta_time;
  391. }
  392. //-----------------------------------------------------------------------------
  393. double Device::time_since_start() const
  394. {
  395. return m_time_since_start;
  396. }
  397. //-----------------------------------------------------------------------------
  398. void Device::frame(cb callback)
  399. {
  400. m_current_time = os::microseconds();
  401. m_last_delta_time = (m_current_time - m_last_time) / 1000000.0f;
  402. m_last_time = m_current_time;
  403. m_time_since_start += m_last_delta_time;
  404. if (!m_is_paused)
  405. {
  406. m_resource_manager->poll_resource_loader();
  407. m_window->frame();
  408. m_input_manager->frame(frame_count());
  409. if (!m_lua_environment->call_global("frame", 1, ARGUMENT_FLOAT, last_delta_time()))
  410. {
  411. pause();
  412. }
  413. callback(m_last_delta_time);
  414. m_renderer->frame();
  415. m_sound_renderer->frame();
  416. }
  417. m_frame_count++;
  418. os_event_buffer()->clear();
  419. }
  420. //-----------------------------------------------------------------------------
  421. ResourcePackage* Device::create_resource_package(const char* name)
  422. {
  423. CE_ASSERT_NOT_NULL(name);
  424. ResourceId package_id = m_resource_manager->load("package", name);
  425. m_resource_manager->flush();
  426. PackageResource* package_res = (PackageResource*) m_resource_manager->data(package_id);
  427. ResourcePackage* package = CE_NEW(default_allocator(), ResourcePackage)(*m_resource_manager, package_id, package_res);
  428. return package;
  429. }
  430. //-----------------------------------------------------------------------------
  431. void Device::destroy_resource_package(ResourcePackage* package)
  432. {
  433. CE_ASSERT_NOT_NULL(package);
  434. m_resource_manager->unload(package->resource_id());
  435. CE_DELETE(default_allocator(), package);
  436. }
  437. //-----------------------------------------------------------------------------
  438. void Device::compile(const char* , const char* , const char* )
  439. {
  440. }
  441. //-----------------------------------------------------------------------------
  442. void Device::reload(ResourceId name)
  443. {
  444. (void)name;
  445. }
  446. //-----------------------------------------------------------------------------
  447. void Device::parse_command_line(int argc, char** argv)
  448. {
  449. static ArgsOption options[] =
  450. {
  451. { "help", AOA_NO_ARGUMENT, NULL, 'i' },
  452. { "source-dir", AOA_REQUIRED_ARGUMENT, NULL, 's' },
  453. { "bundle-dir", AOA_REQUIRED_ARGUMENT, NULL, 'b' },
  454. { "compile", AOA_NO_ARGUMENT, &m_compile, 1 },
  455. { "continue", AOA_NO_ARGUMENT, &m_continue, 1 },
  456. { "width", AOA_REQUIRED_ARGUMENT, NULL, 'w' },
  457. { "height", AOA_REQUIRED_ARGUMENT, NULL, 'h' },
  458. { "fullscreen", AOA_NO_ARGUMENT, &m_preferred_window_fullscreen, 1 },
  459. { "parent-window", AOA_REQUIRED_ARGUMENT, NULL, 'p' },
  460. { "quit-after-init", AOA_NO_ARGUMENT, &m_quit_after_init, 1 },
  461. { NULL, 0, NULL, 0 }
  462. };
  463. Args args(argc, argv, "", options);
  464. int32_t opt;
  465. while ((opt = args.getopt()) != -1)
  466. {
  467. switch (opt)
  468. {
  469. case 0:
  470. {
  471. break;
  472. }
  473. // Source directory
  474. case 's':
  475. {
  476. string::strncpy(m_source_dir, args.optarg(), MAX_PATH_LENGTH);
  477. break;
  478. }
  479. // Bundle directory
  480. case 'b':
  481. {
  482. string::strncpy(m_bundle_dir, args.optarg(), MAX_PATH_LENGTH);
  483. break;
  484. }
  485. // Window width
  486. case 'w':
  487. {
  488. m_preferred_window_width = atoi(args.optarg());
  489. break;
  490. }
  491. // Window height
  492. case 'h':
  493. {
  494. m_preferred_window_height = atoi(args.optarg());
  495. break;
  496. }
  497. // Parent window
  498. case 'p':
  499. {
  500. m_parent_window_handle = string::parse_uint(args.optarg());
  501. break;
  502. }
  503. case 'i':
  504. case '?':
  505. default:
  506. {
  507. print_help_message();
  508. exit(EXIT_FAILURE);
  509. }
  510. }
  511. }
  512. }
  513. //-----------------------------------------------------------------------------
  514. void Device::check_preferred_settings()
  515. {
  516. if (m_compile == 1)
  517. {
  518. if (string::strcmp(m_source_dir, "") == 0)
  519. {
  520. Log::e("You have to specify the source directory when running in compile mode.");
  521. exit(EXIT_FAILURE);
  522. }
  523. if (!os::is_absolute_path(m_source_dir))
  524. {
  525. Log::e("The source directory must be absolute.");
  526. exit(EXIT_FAILURE);
  527. }
  528. }
  529. if (!os::is_absolute_path(m_bundle_dir))
  530. {
  531. Log::e("The bundle directory must be absolute.");
  532. exit(EXIT_FAILURE);
  533. }
  534. if (m_preferred_window_width == 0 || m_preferred_window_height == 0)
  535. {
  536. Log::e("Window width and height must be greater than zero.");
  537. exit(EXIT_FAILURE);
  538. }
  539. }
  540. //-----------------------------------------------------------------------------
  541. void Device::read_engine_settings()
  542. {
  543. // Check crown.config existance
  544. CE_ASSERT(m_filesystem->is_file("crown.config"), "Unable to open crown.config");
  545. // Copy crown config in a buffer
  546. TempAllocator4096 allocator;
  547. File* config_file = m_filesystem->open("crown.config", FOM_READ);
  548. char* json_string = (char*)allocator.allocate(config_file->size());
  549. config_file->read(json_string, config_file->size());
  550. m_filesystem->close(config_file);
  551. // Parse crown.config
  552. JSONParser parser(json_string);
  553. JSONElement root = parser.root();
  554. // Boot
  555. if (root.has_key("boot"))
  556. {
  557. const char* boot = root.key("boot").string_value();
  558. const size_t boot_length = string::strlen(boot) + 1;
  559. string::strncpy(m_boot_file, boot, boot_length);
  560. }
  561. // Window width
  562. if (root.has_key("window_width"))
  563. {
  564. m_preferred_window_width = root.key("window_width").int_value();
  565. }
  566. // Window height
  567. if (root.has_key("window_height"))
  568. {
  569. m_preferred_window_height = root.key("window_height").int_value();
  570. }
  571. allocator.deallocate(json_string);
  572. Log::i("Configuration set");
  573. }
  574. //-----------------------------------------------------------------------------
  575. void Device::print_help_message()
  576. {
  577. os::printf(
  578. "Usage: crown [options]\n"
  579. "Options:\n\n"
  580. "All of the following options take precedence over\n"
  581. "environment variables and configuration files.\n\n"
  582. " --help Show this help.\n"
  583. " --bundle-dir <path> Use <path> as the source directory for compiled resources.\n"
  584. " --width <width> Set the <width> of the main window.\n"
  585. " --height <width> Set the <height> of the main window.\n"
  586. " --fullscreen Start in fullscreen.\n"
  587. " --parent-window <handle> Set the parent window <handle> of the main window.\n"
  588. " Used only by tools.\n"
  589. "\nAvailable only in debug and development builds:\n\n"
  590. " --source-dir <path> Use <path> as the source directory for resource compilation.\n"
  591. " --compile Run the engine as resource compiler.\n"
  592. " --continue Do a full compile of the resources and continue the execution.\n"
  593. " --quit-after-init Quit the engine immediately after the initialization.\n");
  594. }
  595. static Device* g_device = NULL;
  596. //-----------------------------------------------------------------------------
  597. void init()
  598. {
  599. crown::memory::init();
  600. crown::os::init_os();
  601. g_device = CE_NEW(default_allocator(), Device);
  602. }
  603. //-----------------------------------------------------------------------------
  604. void shutdown()
  605. {
  606. CE_DELETE(default_allocator(), g_device);
  607. crown::memory::shutdown();
  608. }
  609. Device* device()
  610. {
  611. return g_device;
  612. }
  613. void nothing(float)
  614. {
  615. device()->renderer()->set_layer_clear(0, CLEAR_COLOR | CLEAR_DEPTH, Color4::LIGHTBLUE, 1.0f);
  616. device()->renderer()->commit(0);
  617. }
  618. } // namespace crown