删减application类
This commit is contained in:
parent
c7f0281ea5
commit
bca7d02df8
@ -2,32 +2,25 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "command_line.h"
|
||||
#include "misc/singleton/singleton_manager.h"
|
||||
#include "spdlog/async.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
#include "thread_message/thread_message_hubs.h"
|
||||
|
||||
bool g_is_running = true;
|
||||
bool g_exit_requested = false;
|
||||
application* g_app_instance = nullptr;
|
||||
|
||||
void application::init(const window_params& in_window_params, int argc, char** argv) {
|
||||
void application::init(const char* runtime_dir) {
|
||||
try {
|
||||
async_spdlog_ = spdlog::basic_logger_mt<spdlog::async_factory>("async_file_logger", "logs/log.txt");
|
||||
} catch (const spdlog::spdlog_ex& ex) {
|
||||
std::cout << "Log init failed: " << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
command_line::instance().init(argc, argv);
|
||||
|
||||
g_is_running = true;
|
||||
singleton_manager::get()->init();
|
||||
}
|
||||
|
||||
void application::shutdown() {
|
||||
g_is_running = false;
|
||||
singleton_manager::get()->release();
|
||||
}
|
||||
|
||||
void application::request_exit() {
|
||||
g_exit_requested = true;
|
||||
}
|
||||
|
@ -6,23 +6,8 @@ class render_target;
|
||||
class texture;
|
||||
class application;
|
||||
|
||||
extern bool g_is_running;
|
||||
extern bool g_exit_requested;
|
||||
extern application* g_app_instance;
|
||||
|
||||
struct window_params {
|
||||
std::string title;
|
||||
int width;
|
||||
int height;
|
||||
bool fullscreen;
|
||||
bool borderless;
|
||||
bool resizable;
|
||||
bool minimized;
|
||||
bool maximized;
|
||||
bool hi_dpi;
|
||||
bool always_on_top;
|
||||
};
|
||||
|
||||
class CORE_API application {
|
||||
public:
|
||||
application() {
|
||||
@ -39,13 +24,12 @@ public:
|
||||
return g_app_instance;
|
||||
}
|
||||
|
||||
virtual void init(const window_params& in_window_params, int argc, char** argv);
|
||||
virtual void init(const char* runtime_dir);
|
||||
|
||||
virtual void shutdown();
|
||||
|
||||
void request_exit();
|
||||
|
||||
virtual void draw_gui() = 0;
|
||||
virtual void tick(float delta_time) {}
|
||||
protected:
|
||||
std::shared_ptr<spdlog::logger> async_spdlog_;
|
||||
|
22
core/export.cpp
Normal file
22
core/export.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "export.h"
|
||||
|
||||
#include "application/application.h"
|
||||
|
||||
core_handle::core_handle() : app_(nullptr) {
|
||||
|
||||
}
|
||||
|
||||
void core_handle::init_core(const char* runtime_dir) {
|
||||
delete app_;
|
||||
|
||||
app_ = new application();
|
||||
app_->init(runtime_dir);
|
||||
}
|
||||
|
||||
void core_handle::release_core() {
|
||||
if (app_) {
|
||||
app_->shutdown();
|
||||
delete app_;
|
||||
app_ = nullptr;
|
||||
}
|
||||
}
|
15
core/export.h
Normal file
15
core/export.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "extern.h"
|
||||
|
||||
|
||||
class application;
|
||||
|
||||
class CORE_API core_handle {
|
||||
public:
|
||||
core_handle();
|
||||
|
||||
void init_core(const char* runtime_dir);
|
||||
void release_core();
|
||||
private:
|
||||
application* app_;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user