From de8465ce6d63cf7c0187d7e7e3c59d9ff9c566e6 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sun, 13 Jan 2013 22:13:49 -0800 Subject: [PATCH] Added EGL resize. --- src/glcontext_egl.cpp | 47 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/src/glcontext_egl.cpp b/src/glcontext_egl.cpp index 172edd5c5..d59d76eb4 100644 --- a/src/glcontext_egl.cpp +++ b/src/glcontext_egl.cpp @@ -45,6 +45,14 @@ namespace bgfx EGL_NONE }; + EGLint numConfig = 0; + EGLConfig config; + success = eglChooseConfig(m_display, attrs, &config, 1, &numConfig); + BGFX_FATAL(success, Fatal::UnableToInitialize, "eglChooseConfig"); + + m_surface = eglCreateWindowSurface(m_display, config, nwt, NULL); + BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface."); + EGLint contextAttrs[] = { # if BGFX_CONFIG_RENDERER_OPENGLES2 @@ -56,14 +64,6 @@ namespace bgfx EGL_NONE }; - EGLint numConfig = 0; - EGLConfig config = 0; - success = eglChooseConfig(m_display, attrs, &config, 1, &numConfig); - BGFX_FATAL(success, Fatal::UnableToInitialize, "eglChooseConfig"); - - m_surface = eglCreateWindowSurface(m_display, config, nwt, NULL); - BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface."); - m_context = eglCreateContext(m_display, config, EGL_NO_CONTEXT, contextAttrs); BGFX_FATAL(m_context != EGL_NO_CONTEXT, Fatal::UnableToInitialize, "Failed to create context."); @@ -88,6 +88,37 @@ namespace bgfx void GlContext::resize(uint32_t _width, uint32_t _height) { + eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + eglDestroySurface(m_display, m_surface); + + EGLint attrs[] = + { + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + +# if BX_PLATFORM_ANDROID + EGL_DEPTH_SIZE, 16, +# else + EGL_DEPTH_SIZE, 24, +# endif // BX_PLATFORM_ + + EGL_NONE + }; + + EGLint numConfig = 0; + EGLConfig config; + EGLBoolean success = eglChooseConfig(m_display, attrs, &config, 1, &numConfig); + BGFX_FATAL(success, Fatal::UnableToInitialize, "eglChooseConfig"); + + EGLNativeWindowType nwt = (EGLNativeWindowType)NULL; +# if BX_PLATFORM_WINDOWS + nwt = g_bgfxHwnd; +# endif // BX_PLATFORM_ + + m_surface = eglCreateWindowSurface(m_display, config, nwt, NULL); + BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface."); + + eglMakeCurrent(m_display, m_surface, m_surface, m_context); } void GlContext::swap()