diff --git a/components/raybri/ios/raybriEGL.h b/components/raybri/ios/raybriEGL.h index 3949779..5beada6 100644 --- a/components/raybri/ios/raybriEGL.h +++ b/components/raybri/ios/raybriEGL.h @@ -9,6 +9,12 @@ // Header bool raybriEGLInit(void); +bool raybriEGLResetSurface( + void *caLayer, + EGLConfig *cfg, + EGLDisplay *display, + EGLSurface *surface +); // Source @@ -48,6 +54,28 @@ bool raybriEGLInit(void) { return true; } +bool raybriEGLResetSurface( + void *caLayer, + EGLConfig *cfg, + EGLDisplay *display, + EGLSurface *surface +) { + // Destroy previous surface + if (surface != EGL_NO_SURFACE) { + eglDestroySurface(display, surface); + surface = EGL_NO_SURFACE; + } + + // Create new surface + // ANGLE on iOS takes a CALayer as the native window + surface = eglCreateWindowSurface(display, cfg, (EGLNativeWindowType)caLayer, NULL); + if (surface == EGL_NO_SURFACE) { + return false; + } + + return true; +} + #endif // RAYBRI_EGL_IMPLEMENTATION #endif // RAYBRI_EGL_H