mirror of https://github.com/auygun/kaliber.git
Remove exceptions
This commit is contained in:
parent
971540dce2
commit
b2e5f19963
|
@ -16,8 +16,6 @@ using namespace base;
|
|||
|
||||
namespace eng {
|
||||
|
||||
Platform::InternalError Platform::internal_error;
|
||||
|
||||
Platform::Platform() = default;
|
||||
|
||||
Platform::~Platform() = default;
|
||||
|
@ -33,10 +31,8 @@ void Platform::InitializeCommon() {
|
|||
#elif defined(__linux__)
|
||||
audio_driver_ = std::make_unique<AudioDriverAlsa>();
|
||||
#endif
|
||||
if (!audio_driver_->Initialize()) {
|
||||
LOG << "Failed to initialize audio driver.";
|
||||
throw internal_error;
|
||||
}
|
||||
bool res = audio_driver_->Initialize();
|
||||
CHECK(res) << "Failed to initialize audio driver.";
|
||||
|
||||
auto context = std::make_unique<VulkanContext>();
|
||||
if (context->Initialize()) {
|
||||
|
@ -57,10 +53,8 @@ void Platform::ShutdownCommon() {
|
|||
void Platform::RunMainLoop() {
|
||||
engine_ =
|
||||
std::make_unique<Engine>(this, renderer_.get(), audio_driver_.get());
|
||||
if (!engine_->Initialize()) {
|
||||
LOG << "Failed to initialize the engine.";
|
||||
throw internal_error;
|
||||
}
|
||||
bool res = engine_->Initialize();
|
||||
CHECK(res) << "Failed to initialize the engine.";
|
||||
|
||||
// Use fixed time steps.
|
||||
float time_step = engine_->time_step();
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef ENGINE_PLATFORM_PLATFORM_H
|
||||
#define ENGINE_PLATFORM_PLATFORM_H
|
||||
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -66,9 +65,6 @@ class Platform {
|
|||
|
||||
bool mobile_device() const { return mobile_device_; }
|
||||
|
||||
static class InternalError : public std::exception {
|
||||
} internal_error;
|
||||
|
||||
protected:
|
||||
base::Timer timer_;
|
||||
|
||||
|
|
|
@ -295,10 +295,9 @@ void Platform::HandleCmd(android_app* app, int32_t cmd) {
|
|||
DLOG << "APP_CMD_INIT_WINDOW";
|
||||
if (app->window != NULL) {
|
||||
platform->SetFrameRate(60);
|
||||
if (!platform->renderer_->Initialize(app->window)) {
|
||||
LOG << "Failed to initialize the renderer.";
|
||||
throw internal_error;
|
||||
}
|
||||
bool res = platform->renderer_->Initialize(app->window);
|
||||
CHECK(res) << "Failed to initialize "
|
||||
<< platform->renderer_->GetDebugName() << " renderer.";
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -315,10 +314,9 @@ void Platform::HandleCmd(android_app* app, int32_t cmd) {
|
|||
if (width != ANativeWindow_getWidth(app->window) ||
|
||||
height != ANativeWindow_getHeight(app->window)) {
|
||||
platform->renderer_->Shutdown();
|
||||
if (!platform->renderer_->Initialize(platform->app_->window)) {
|
||||
LOG << "Failed to initialize the renderer.";
|
||||
throw internal_error;
|
||||
}
|
||||
bool res = platform->renderer_->Initialize(platform->app_->window);
|
||||
CHECK(res) << "Failed to initialize "
|
||||
<< platform->renderer_->GetDebugName() << " renderer.";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -445,11 +443,8 @@ void Platform::SetFrameRate(float frame_rate) {
|
|||
|
||||
void android_main(android_app* app) {
|
||||
eng::Platform platform;
|
||||
try {
|
||||
platform.Initialize(app);
|
||||
platform.RunMainLoop();
|
||||
platform.Shutdown();
|
||||
} catch (eng::Platform::InternalError& e) {
|
||||
}
|
||||
_exit(0);
|
||||
}
|
||||
|
|
|
@ -23,15 +23,12 @@ void Platform::Initialize() {
|
|||
shared_data_path_ = "./";
|
||||
LOG << "Shared data path: " << shared_data_path_.c_str();
|
||||
|
||||
if (!CreateWindow(800, 1205)) {
|
||||
LOG << "Failed to create window.";
|
||||
throw internal_error;
|
||||
}
|
||||
bool res = CreateWindow(800, 1205);
|
||||
CHECK(res) << "Failed to create window.";
|
||||
|
||||
if (!renderer_->Initialize(display_, window_)) {
|
||||
LOG << "Failed to initialize renderer.";
|
||||
throw internal_error;
|
||||
}
|
||||
res = renderer_->Initialize(display_, window_);
|
||||
CHECK(res) << "Failed to initialize " << renderer_->GetDebugName()
|
||||
<< " renderer.";
|
||||
|
||||
XSelectInput(display_, window_,
|
||||
KeyPressMask | Button1MotionMask | ButtonPressMask |
|
||||
|
@ -164,12 +161,8 @@ void Platform::DestroyWindow() {
|
|||
|
||||
int main(int argc, char** argv) {
|
||||
eng::Platform platform;
|
||||
try {
|
||||
platform.Initialize();
|
||||
platform.RunMainLoop();
|
||||
platform.Shutdown();
|
||||
} catch (eng::Platform::InternalError& e) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue