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