Device.cpp 18 KB

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