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