X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fglws_egl_xlib.cpp;h=5aacdfed2b5bea5c0b738b907711d936610a93f8;hb=48c661ea6c0f2bd9b76a3385cd946b7d07bc9b5f;hp=0b8f34c17bc595d192d297cf5517901632abbb05;hpb=06555614b7385c49964d27aaeec68dec6ff31744;p=apitrace diff --git a/retrace/glws_egl_xlib.cpp b/retrace/glws_egl_xlib.cpp index 0b8f34c..5aacdfe 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_DRAW); + 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,9 +394,9 @@ 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 *