mirror of https://github.com/auygun/kaliber.git
Add Platform::CreateMainWindow
This commit is contained in:
parent
8503c549d7
commit
6e952e511e
|
@ -108,6 +108,8 @@ void Engine::Initialize() {
|
||||||
|
|
||||||
thread_pool_.Initialize();
|
thread_pool_.Initialize();
|
||||||
|
|
||||||
|
platform_->CreateMainWindow();
|
||||||
|
|
||||||
CreateRendererInternal(RendererType::kVulkan);
|
CreateRendererInternal(RendererType::kVulkan);
|
||||||
|
|
||||||
CreateProjectionMatrix();
|
CreateProjectionMatrix();
|
||||||
|
@ -485,6 +487,7 @@ bool Engine::IsMobile() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::OnWindowCreated() {
|
void Engine::OnWindowCreated() {
|
||||||
|
if (renderer_)
|
||||||
renderer_->Initialize(platform_);
|
renderer_->Initialize(platform_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,8 +496,8 @@ void Engine::OnWindowDestroyed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::OnWindowResized(int width, int height) {
|
void Engine::OnWindowResized(int width, int height) {
|
||||||
if (width != renderer_->GetScreenWidth() ||
|
if (renderer_ && (width != renderer_->GetScreenWidth() ||
|
||||||
height != renderer_->GetScreenHeight()) {
|
height != renderer_->GetScreenHeight())) {
|
||||||
renderer_->OnWindowResized(width, height);
|
renderer_->OnWindowResized(width, height);
|
||||||
CreateProjectionMatrix();
|
CreateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,8 @@ class Platform {
|
||||||
#endif
|
#endif
|
||||||
~Platform();
|
~Platform();
|
||||||
|
|
||||||
|
void CreateMainWindow();
|
||||||
|
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
void Exit();
|
void Exit();
|
||||||
|
|
|
@ -292,20 +292,18 @@ void Platform::HandleCmd(android_app* app, int32_t cmd) {
|
||||||
DLOG(0) << "APP_CMD_INIT_WINDOW";
|
DLOG(0) << "APP_CMD_INIT_WINDOW";
|
||||||
if (app->window != NULL) {
|
if (app->window != NULL) {
|
||||||
platform->SetFrameRate(60);
|
platform->SetFrameRate(60);
|
||||||
if (platform->observer_)
|
|
||||||
platform->observer_->OnWindowCreated();
|
platform->observer_->OnWindowCreated();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case APP_CMD_TERM_WINDOW:
|
case APP_CMD_TERM_WINDOW:
|
||||||
DLOG(0) << "APP_CMD_TERM_WINDOW";
|
DLOG(0) << "APP_CMD_TERM_WINDOW";
|
||||||
if (platform->observer_)
|
|
||||||
platform->observer_->OnWindowDestroyed();
|
platform->observer_->OnWindowDestroyed();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case APP_CMD_CONFIG_CHANGED:
|
case APP_CMD_CONFIG_CHANGED:
|
||||||
DLOG(0) << "APP_CMD_CONFIG_CHANGED";
|
DLOG(0) << "APP_CMD_CONFIG_CHANGED";
|
||||||
if (platform->app_->window != NULL && platform->observer_)
|
if (platform->app_->window != NULL)
|
||||||
platform->observer_->OnWindowResized(
|
platform->observer_->OnWindowResized(
|
||||||
ANativeWindow_getWidth(app->window),
|
ANativeWindow_getWidth(app->window),
|
||||||
ANativeWindow_getHeight(app->window));
|
ANativeWindow_getHeight(app->window));
|
||||||
|
@ -319,7 +317,6 @@ void Platform::HandleCmd(android_app* app, int32_t cmd) {
|
||||||
DLOG(0) << "APP_CMD_GAINED_FOCUS";
|
DLOG(0) << "APP_CMD_GAINED_FOCUS";
|
||||||
// platform->timer_.Reset();
|
// platform->timer_.Reset();
|
||||||
platform->has_focus_ = true;
|
platform->has_focus_ = true;
|
||||||
if (platform->observer_)
|
|
||||||
platform->observer_->GainedFocus(g_showing_interstitial_ad);
|
platform->observer_->GainedFocus(g_showing_interstitial_ad);
|
||||||
g_showing_interstitial_ad = false;
|
g_showing_interstitial_ad = false;
|
||||||
break;
|
break;
|
||||||
|
@ -327,7 +324,6 @@ void Platform::HandleCmd(android_app* app, int32_t cmd) {
|
||||||
case APP_CMD_LOST_FOCUS:
|
case APP_CMD_LOST_FOCUS:
|
||||||
DLOG(0) << "APP_CMD_LOST_FOCUS";
|
DLOG(0) << "APP_CMD_LOST_FOCUS";
|
||||||
platform->has_focus_ = false;
|
platform->has_focus_ = false;
|
||||||
if (platform->observer_)
|
|
||||||
platform->observer_->LostFocus();
|
platform->observer_->LostFocus();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -370,8 +366,12 @@ Platform::Platform(android_app* app) {
|
||||||
reinterpret_cast<PFN_ANativeWindow_setFrameRateWithChangeStrategy>(
|
reinterpret_cast<PFN_ANativeWindow_setFrameRateWithChangeStrategy>(
|
||||||
dlsym(mLibAndroid, "ANativeWindow_setFrameRateWithChangeStrategy"));
|
dlsym(mLibAndroid, "ANativeWindow_setFrameRateWithChangeStrategy"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform::CreateMainWindow() {
|
||||||
|
DCHECK(!app_->window);
|
||||||
Update();
|
Update();
|
||||||
|
DCHECK(app_->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
Platform::~Platform() {
|
Platform::~Platform() {
|
||||||
|
|
|
@ -39,7 +39,9 @@ Platform::Platform() {
|
||||||
LOG(0) << "Root path: " << root_path_.c_str();
|
LOG(0) << "Root path: " << root_path_.c_str();
|
||||||
LOG(0) << "Data path: " << data_path_.c_str();
|
LOG(0) << "Data path: " << data_path_.c_str();
|
||||||
LOG(0) << "Shared data path: " << shared_data_path_.c_str();
|
LOG(0) << "Shared data path: " << shared_data_path_.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform::CreateMainWindow() {
|
||||||
bool res = CreateWindow(800, 1205);
|
bool res = CreateWindow(800, 1205);
|
||||||
CHECK(res) << "Failed to create window.";
|
CHECK(res) << "Failed to create window.";
|
||||||
|
|
||||||
|
@ -103,8 +105,10 @@ void Platform::Update() {
|
||||||
}
|
}
|
||||||
case ClientMessage: {
|
case ClientMessage: {
|
||||||
// WM_DELETE_WINDOW is the only registered type for now.
|
// WM_DELETE_WINDOW is the only registered type for now.
|
||||||
|
observer_->OnWindowDestroyed();
|
||||||
|
DestroyWindow();
|
||||||
should_exit_ = true;
|
should_exit_ = true;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
case ConfigureNotify: {
|
case ConfigureNotify: {
|
||||||
XConfigureEvent xce = e.xconfigure;
|
XConfigureEvent xce = e.xconfigure;
|
||||||
|
|
Loading…
Reference in New Issue