diff options
| author | Egor <egor.yusov@gmail.com> | 2018-02-18 17:53:12 +0000 |
|---|---|---|
| committer | Egor <egor.yusov@gmail.com> | 2018-02-18 17:53:12 +0000 |
| commit | b879cb266d99aee11e35e1894b7a119082ab51c2 (patch) | |
| tree | d46856b0a93fb2a9b394499f892e4f20e4ef38e9 /unityplugin/UnityEmulator | |
| parent | Improved device orientation/resize handling on Android (diff) | |
| download | DiligentEngine-b879cb266d99aee11e35e1894b7a119082ab51c2.tar.gz DiligentEngine-b879cb266d99aee11e35e1894b7a119082ab51c2.zip | |
Fixed device orientation change handling in Unity emulator app
Diffstat (limited to 'unityplugin/UnityEmulator')
3 files changed, 22 insertions, 12 deletions
diff --git a/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.cpp b/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.cpp index c3e97df..40bb162 100644 --- a/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.cpp +++ b/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.cpp @@ -270,6 +270,21 @@ void UnityGraphicsGLESAndroid_Impl::Terminate() context_valid_ = false; } +void UnityGraphicsGLESAndroid_Impl::UpdateScreenSize() +{ + int32_t new_screen_width = 0; + int32_t new_screen_height = 0; + eglQuerySurface( display_, surface_, EGL_WIDTH, &new_screen_width ); + eglQuerySurface( display_, surface_, EGL_HEIGHT, &new_screen_height ); + + if( new_screen_width != screen_width_ || new_screen_height != screen_height_ ) + { + screen_width_ = new_screen_width; + screen_height_ = new_screen_height; + //Screen resized + LOG_INFO_MESSAGE( "Window size changed to ", screen_width_, "x", screen_height_ ); + } +} EGLint UnityGraphicsGLESAndroid_Impl::Resume( ANativeWindow* window ) { @@ -283,18 +298,7 @@ EGLint UnityGraphicsGLESAndroid_Impl::Resume( ANativeWindow* window ) //Create surface window_ = window; surface_ = eglCreateWindowSurface( display_, config_, window_, NULL ); - int32_t new_screen_width = 0; - int32_t new_screen_height = 0; - eglQuerySurface( display_, surface_, EGL_WIDTH, &new_screen_width ); - eglQuerySurface( display_, surface_, EGL_HEIGHT, &new_screen_height ); - - if( new_screen_width != screen_width_ || new_screen_height != screen_height_ ) - { - screen_width_ = new_screen_width; - screen_height_ = new_screen_height; - //Screen resized - LOG_INFO_MESSAGE( "Screen resized\n" ); - } + UpdateScreenSize(); if( eglMakeCurrent( display_, surface_, surface_, context_ ) == EGL_TRUE ) return EGL_SUCCESS; diff --git a/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.h b/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.h index 1ef33a6..61762ed 100644 --- a/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.h +++ b/unityplugin/UnityEmulator/src/Android/UnityGraphicsGLESAndroid_Impl.h @@ -61,6 +61,8 @@ public: void Suspend(); EGLint Resume( ANativeWindow* window ); + void UpdateScreenSize(); + private: //EGL configurations ANativeWindow* window_ = nullptr; diff --git a/unityplugin/UnityEmulator/src/UnityGraphicsGLCoreES_Emulator.cpp b/unityplugin/UnityEmulator/src/UnityGraphicsGLCoreES_Emulator.cpp index 9e8757c..8edeb78 100644 --- a/unityplugin/UnityEmulator/src/UnityGraphicsGLCoreES_Emulator.cpp +++ b/unityplugin/UnityEmulator/src/UnityGraphicsGLCoreES_Emulator.cpp @@ -47,6 +47,10 @@ void UnityGraphicsGLCoreES_Emulator::Release() void UnityGraphicsGLCoreES_Emulator::ResizeSwapChain(unsigned int Width, unsigned int Height) { +#if PLATFORM_ANDROID + m_GraphicsImpl->UpdateScreenSize(); + GetBackBufferSize(Width, Height); +#endif m_GraphicsImpl->ResizeSwapchain(Width, Height); } |
