-
- EGLDisplay display = fgDisplay.pDisplay.eglDisplay;
- EGLint format = fgDisplay.pDisplay.eglContextFormat;
- ANativeWindow_setBuffersGeometry(window->Window.Handle, 0, 0, format);
- window->Window.pContext.eglSurface = fghEGLPlatformOpenWindow(window->Window.Handle);
+ window->Window.Handle = fgDisplay.pDisplay.single_native_window;
+ window->State.WorkMask |= GLUT_INIT_WORK;
+
+ /* Create context */
+ fghChooseConfig(&window->Window.pContext.egl.Config);
+ window->Window.Context = fghCreateNewContextEGL(window);
+
+ EGLDisplay display = fgDisplay.pDisplay.egl.Display;
+
+ /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
+ * guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
+ * As soon as we picked a EGLConfig, we can safely reconfigure the
+ * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */
+ EGLint vid;
+ eglGetConfigAttrib(display, window->Window.pContext.egl.Config,
+ EGL_NATIVE_VISUAL_ID, &vid);
+ ANativeWindow_setBuffersGeometry(window->Window.Handle, 0, 0, vid);
+
+ fghPlatformOpenWindowEGL(window);
+
+ /* Bind context to the current thread if it's lost */
+ if (eglGetCurrentContext() == EGL_NO_CONTEXT &&
+ eglMakeCurrent(fgDisplay.pDisplay.egl.Display,
+ window->Window.pContext.egl.Surface,
+ window->Window.pContext.egl.Surface,
+ window->Window.Context) == EGL_FALSE)
+ fgError("eglMakeCurrent: err=%x\n", eglGetError());