------------------------------------------------------------------------------
| 507 | |
| 508 | //------------------------------------------------------------------------------ |
| 509 | void vtkAndroidRenderWindowInteractor::Initialize() |
| 510 | { |
| 511 | // make sure we have a RenderWindow and camera |
| 512 | if (!this->RenderWindow) |
| 513 | { |
| 514 | vtkErrorMacro(<< "No renderer defined!"); |
| 515 | return; |
| 516 | } |
| 517 | if (this->Initialized) |
| 518 | { |
| 519 | return; |
| 520 | } |
| 521 | |
| 522 | vtkRenderWindow* ren; |
| 523 | int* size; |
| 524 | |
| 525 | this->Initialized = 1; |
| 526 | // get the info we need from the RenderingWindow |
| 527 | ren = this->RenderWindow; |
| 528 | |
| 529 | if (this->GetOwnWindow() && this->AndroidApplication != nullptr) |
| 530 | { |
| 531 | this->AndroidApplication->userData = this; |
| 532 | this->AndroidApplication->onAppCmd = android_handle_cmd; |
| 533 | this->AndroidApplication->onInputEvent = android_handle_input; |
| 534 | |
| 535 | // run event loop until window mapped |
| 536 | bool done = false; |
| 537 | while (!done && this->RenderWindow->GetMapped() == 0) |
| 538 | { |
| 539 | // Read all pending events. |
| 540 | int ident; |
| 541 | int events; |
| 542 | struct android_poll_source* source; |
| 543 | |
| 544 | if ((ident = ALooper_pollOnce(-1, nullptr, &events, (void**)&source)) >= 0) |
| 545 | { |
| 546 | // Process this event. |
| 547 | if (source != nullptr) |
| 548 | { |
| 549 | source->process(this->AndroidApplication, source); |
| 550 | } |
| 551 | |
| 552 | // Check if we are exiting. |
| 553 | if (this->AndroidApplication->destroyRequested != 0) |
| 554 | { |
| 555 | LOGW("Destroying Window in init"); |
| 556 | this->RenderWindow->Finalize(); |
| 557 | done = true; |
| 558 | LOGW("Destroyed window in init"); |
| 559 | return; |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | size = ren->GetSize(); |
| 566 | ren->GetPosition(); |
nothing calls this directly
no test coverage detected