#define FREEGLUT_BUILDING_LIB
#include <GL/freeglut.h>
#include "fg_internal.h"
-extern EGLSurface fghEGLPlatformOpenWindow( EGLNativeWindowType handle );
+#include "egl/fg_window_egl.h"
/*
* Opens a window. Requires a SFG_Window object created and attached
return;
}
+ fghChooseConfig(&window->Window.pContext.egl.Config);
+ window->Window.Context = fghCreateNewContextEGL(window);
+
/* Wait until window is available and OpenGL context is created */
/* Normally events are processed through glutMainLoop(), but the
user didn't call it yet, and the Android may not have initialized
fgPlatformProcessSingleEvent();
}
- 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);
+ 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);
window->State.Visible = GL_TRUE;
}
-void fgPlatformSetWindow ( SFG_Window *window )
+/*
+ * Closes a window, destroying the frame and OpenGL context
+ */
+void fgPlatformCloseWindow( SFG_Window* window )
{
- /* TODO: only a single window possible? */
+ fghPlatformCloseWindowEGL(window);
+ /* Window pre-created by Android, no way to delete it */
}
/*