NativeWindowAndroid.cpp 1018 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/Core/NativeWindowAndroid.h>
  6. namespace anki
  7. {
  8. Error NativeWindow::init(NativeWindowInitInfo& init, HeapAllocator<U8>& alloc)
  9. {
  10. ANKI_CORE_LOGI("Initializing Android window");
  11. m_impl = m_alloc.newInstance<NativeWindowImpl>();
  12. // Loop until the window is ready
  13. extern android_app* g_androidApp;
  14. while(g_androidApp->window == nullptr)
  15. {
  16. int ident;
  17. int events;
  18. android_poll_source* source;
  19. const int timeoutMs = 5;
  20. while((ident = ALooper_pollAll(timeoutMs, NULL, &events, reinterpret_cast<void**>(&source))) >= 0)
  21. {
  22. if(source != NULL)
  23. {
  24. source->process(g_androidApp, source);
  25. }
  26. }
  27. }
  28. m_impl->m_nativeWindow = g_androidApp->window;
  29. return Error::NONE;
  30. }
  31. void NativeWindow::destroy()
  32. {
  33. // Nothing
  34. }
  35. void NativeWindow::setWindowTitle(CString title)
  36. {
  37. // Nothing
  38. }
  39. } // end namespace anki