Move destroy window and glfw to CoreInstnace from render engine
This commit is contained in:
@@ -63,14 +63,18 @@ CoreInstance::CoreInstance()
|
|||||||
window_ = glfwCreateWindow(800, 600, main_config_.game_name.c_str(), nullptr, nullptr);
|
window_ = glfwCreateWindow(800, 600, main_config_.game_name.c_str(), nullptr, nullptr);
|
||||||
if (window_ == nullptr)
|
if (window_ == nullptr)
|
||||||
{
|
{
|
||||||
glfwTerminate();
|
std::cout << "[!] Init render engine: Fail create window\n";
|
||||||
throw std::runtime_error("Fail create window");
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
render_engine_ = new RenderEngine(*this, window_);
|
||||||
|
} catch (const std::exception& e)
|
||||||
|
{
|
||||||
|
std::cout << "[!] Init render engine: " << e.what() << '\n';
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
render_engine_ = new RenderEngine(*this, window_);
|
|
||||||
|
|
||||||
game_ = GameFactory(*this);
|
game_ = GameFactory(*this);
|
||||||
if (game_ == nullptr)
|
|
||||||
throw std::runtime_error("Fail create game instance!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreInstance::~CoreInstance()
|
CoreInstance::~CoreInstance()
|
||||||
@@ -81,6 +85,9 @@ CoreInstance::~CoreInstance()
|
|||||||
|
|
||||||
delete render_engine_;
|
delete render_engine_;
|
||||||
delete game_;
|
delete game_;
|
||||||
|
|
||||||
|
glfwDestroyWindow(window_);
|
||||||
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreInstance::start()
|
void CoreInstance::start()
|
||||||
|
|||||||
@@ -972,10 +972,6 @@ RenderEngine::~RenderEngine()
|
|||||||
|
|
||||||
if (instance_ != VK_NULL_HANDLE)
|
if (instance_ != VK_NULL_HANDLE)
|
||||||
vkDestroyInstance(instance_, nullptr);
|
vkDestroyInstance(instance_, nullptr);
|
||||||
|
|
||||||
if (window_ != nullptr)
|
|
||||||
glfwDestroyWindow(window_);
|
|
||||||
glfwTerminate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEngine::start()
|
void RenderEngine::start()
|
||||||
|
|||||||
Reference in New Issue
Block a user