-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathstart.cpp
More file actions
99 lines (78 loc) · 3.11 KB
/
Copy pathstart.cpp
File metadata and controls
99 lines (78 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#include "core/start.h"
#include <memory>
#include "core/context.h"
#include "core/default_resource_manager.h"
#include "core/profiler.h"
#include "graphics/linux/linux_window_manager.h"
#include "graphics/opengl/opengl_material_manager.h"
#include "graphics/opengl/opengl_mesh_manager.h"
#include "graphics/opengl/opengl_render_target_manager.h"
#include "graphics/opengl/opengl_texture_manager.h"
#include "iris_version.h"
#include "jobs/fiber/fiber_job_system_manager.h"
#include "jobs/thread/thread_job_system_manager.h"
#include "log/log.h"
#include "log/logger.h"
#include "physics/bullet/bullet_physics_manager.h"
namespace
{
/**
* Create the engine context object, with defaults for the current platform.
*
* @param argc
* Number of command line arguments.
*
* @param argv
* Array of command line arguments.
*
* @returns
* Engine conetext object.
*/
iris::Context create_context(int argc, char **argv)
{
iris::Context ctx{argc, argv};
auto resource_manager = std::make_unique<iris::DefaultResourceManager>();
auto opengl_texture_manager = std::make_unique<iris::OpenGLTextureManager>(*resource_manager);
auto opengl_material_manager = std::make_unique<iris::OpenGLMaterialManager>();
auto opengl_window_manager =
std::make_unique<iris::LinuxWindowManager>(*opengl_texture_manager, *opengl_material_manager);
auto opengl_mesh_manager = std::make_unique<iris::OpenGLMeshManager>(*resource_manager);
auto opengl_render_target_manager =
std::make_unique<iris::OpenGLRenderTargetManager>(*opengl_window_manager, *opengl_texture_manager);
ctx.register_graphics_api(
"opengl",
std::move(opengl_window_manager),
std::move(opengl_mesh_manager),
std::move(opengl_texture_manager),
std::move(opengl_material_manager),
std::move(opengl_render_target_manager));
ctx.set_graphics_api("d3d12");
ctx.register_physics_api("bullet", std::make_unique<iris::BulletPhysicsManager>(ctx.mesh_manager()));
ctx.set_physics_api("bullet");
ctx.register_jobs_api("thread", std::make_unique<iris::ThreadJobSystemManager>());
ctx.register_jobs_api("fiber", std::make_unique<iris::FiberJobSystemManager>());
ctx.set_jobs_api("fiber");
ctx.set_resource_manager(std::move(resource_manager));
return ctx;
}
}
namespace iris
{
void start(int argc, char **argv, std::function<void(Context)> entry, bool debug)
{
std::unique_ptr<Profiler> profiler;
if (debug)
{
profiler = std::make_unique<Profiler>();
Logger::instance().set_log_engine(true);
LOG_ENGINE_INFO("start", "debug mode on");
}
LOG_ENGINE_INFO("start", "engine start {}", IRIS_VERSION_STR);
entry(create_context(argc, argv));
}
}