X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fglws_egl_xlib.cpp;h=0e6b8237305dd302c67c98bca88124d2a1de020e;hb=25e08d072ae40fffa99b72dab0429c6ed25b19ce;hp=66557815017fda939a5edc4e622b84c7e0ee7459;hpb=9d27a54b0381610c30964880a5fdd4c27bb6e732;p=apitrace diff --git a/retrace/glws_egl_xlib.cpp b/retrace/glws_egl_xlib.cpp index 6655781..0e6b823 100644 --- a/retrace/glws_egl_xlib.cpp +++ b/retrace/glws_egl_xlib.cpp @@ -92,8 +92,9 @@ public: EGLSurface surface; EGLint api; - EglDrawable(const Visual *vis, int w, int h) : - Drawable(vis, w, h), api(EGL_OPENGL_ES_API) + EglDrawable(const Visual *vis, int w, int h, bool pbuffer) : + Drawable(vis, w, h, pbuffer), + api(EGL_OPENGL_ES_API) { XVisualInfo *visinfo = static_cast(visual)->visinfo; @@ -155,6 +156,28 @@ public: eglWaitNative(EGL_CORE_NATIVE_ENGINE); } + void + recreate(void) { + EGLContext currentContext = eglGetCurrentContext(); + EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW); + EGLSurface currentReadSurface = eglGetCurrentSurface(EGL_READ); + bool rebindDrawSurface = currentDrawSurface == surface; + bool rebindReadSurface = currentReadSurface == surface; + + if (rebindDrawSurface || rebindReadSurface) { + eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + } + + eglDestroySurface(eglDisplay, surface); + + EGLConfig config = static_cast(visual)->config; + surface = eglCreateWindowSurface(eglDisplay, config, (EGLNativeWindowType)window, NULL); + + if (rebindDrawSurface || rebindReadSurface) { + eglMakeCurrent(eglDisplay, surface, surface, currentContext); + } + } + void resize(int w, int h) { if (w == width && h == height) { @@ -182,6 +205,27 @@ public: waitForEvent(ConfigureNotify); eglWaitNative(EGL_CORE_NATIVE_ENGINE); + + /* + * Some implementations won't update the backbuffer unless we recreate + * the EGL surface. + */ + + int eglWidth; + int eglHeight; + + eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth); + eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight); + + if (eglWidth != width || eglHeight != height) { + recreate(); + + eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth); + eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight); + } + + assert(eglWidth == width); + assert(eglHeight == height); } void show(void) { @@ -350,13 +394,13 @@ createVisual(bool doubleBuffer, Profile profile) { } Drawable * -createDrawable(const Visual *visual, int width, int height) +createDrawable(const Visual *visual, int width, int height, bool pbuffer) { - return new EglDrawable(visual, width, height); + return new EglDrawable(visual, width, height, pbuffer); } Context * -createContext(const Visual *_visual, Context *shareContext, Profile profile) +createContext(const Visual *_visual, Context *shareContext, Profile profile, bool debug) { const EglVisual *visual = static_cast(_visual); EGLContext share_context = EGL_NO_CONTEXT;