| 74 | explicit Engine(android_app* app) : app_(app) {} |
| 75 | |
| 76 | void AttachWindow() { |
| 77 | // This is called whenever a new native window is created for our app, so we |
| 78 | // need to reinitialize the buffer format to the format our render loop |
| 79 | // expects. |
| 80 | // |
| 81 | // Attaching the window will not cause the app to start running its update |
| 82 | // and render loop. The app's update cycle is separately enabled by |
| 83 | // Engine::Resume. |
| 84 | if (ANativeWindow_setBuffersGeometry( |
| 85 | app_->window, 0, 0, AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM) < 0) { |
| 86 | LOGE("Unable to set window buffer geometry"); |
| 87 | window_initialized = false; |
| 88 | return; |
| 89 | } |
| 90 | window_initialized = true; |
| 91 | color_ = Color::kRed; |
| 92 | last_update_ = std::chrono::steady_clock::now(); |
| 93 | } |
| 94 | |
| 95 | void DetachWindow() { |
| 96 | // This is called whenever the native window for our app is destroyed. That |