summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorEgor <egor.yusov@gmail.com>2018-02-18 08:17:51 +0000
committerEgor <egor.yusov@gmail.com>2018-02-18 08:17:51 +0000
commit520227f04f0ea08521db716c4d1fbc4fe8264cfe (patch)
treed21636d696412bf4152f2abdd8833010414929a8 /Graphics/GraphicsEngineOpenGL
parentFixed issue with _RETURN_() macro on arm compilers on Android (diff)
downloadDiligentCore-520227f04f0ea08521db716c4d1fbc4fe8264cfe.tar.gz
DiligentCore-520227f04f0ea08521db716c4d1fbc4fe8264cfe.zip
Implemented more robust screen orientation/size change handling on Android
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h2
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp27
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp8
3 files changed, 27 insertions, 10 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h b/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h
index 622b60ba..db25be8e 100644
--- a/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h
+++ b/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h
@@ -40,6 +40,8 @@ namespace Diligent
void SwapBuffers();
+ void UpdateScreenSize();
+
bool Invalidate();
void Suspend();
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp
index 47353a04..a8f788ee 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp
@@ -340,6 +340,22 @@ namespace Diligent
}
+ void GLContext::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 GLContext::Resume( ANativeWindow* window )
{
LOG_INFO_MESSAGE( "Resuming gl context\n" );
@@ -353,16 +369,7 @@ namespace Diligent
//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 resized
- LOG_INFO_MESSAGE( "Screen resized\n" );
- }
+ UpdateScreenSize();
if( eglMakeCurrent( display_, surface_, surface_, context_ ) == EGL_TRUE )
return EGL_SUCCESS;
diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp
index 2cce8cde..4939716d 100644
--- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp
@@ -84,6 +84,14 @@ void SwapChainGLImpl::Present()
void SwapChainGLImpl::Resize( Uint32 NewWidth, Uint32 NewHeight )
{
+#if PLATFORM_ANDROID
+ auto *pDeviceGL = ValidatedCast<RenderDeviceGLImpl>(m_pRenderDevice.RawPtr());
+ auto &GLContext = pDeviceGL->m_GLContext;
+ GLContext.UpdateScreenSize();
+ NewWidth = GLContext.GetScreenWidth();
+ NewHeight = GLContext.GetScreenHeight();
+#endif
+
if( TSwapChainBase::Resize( NewWidth, NewHeight ) )
{
auto pDeviceContext = m_wpDeviceContext.Lock();