X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fandroid%2Ffg_window_android.c;h=4c5d9d2550a4b873eed90fdb8254de8b24f83cad;hb=4b1d80d34568230510aafef6b9d505e1215c8d38;hp=8b1f682952f1e8d96840e2eac340a5b753da5b8a;hpb=7fbb15bc63c7937cab772bd942883e3811acbabf;p=freeglut diff --git a/src/android/fg_window_android.c b/src/android/fg_window_android.c index 8b1f682..4c5d9d2 100644 --- a/src/android/fg_window_android.c +++ b/src/android/fg_window_android.c @@ -1,5 +1,5 @@ /* - * freeglut_window_android.c + * fg_window_android.c * * Window management methods for Android * @@ -29,7 +29,8 @@ #define FREEGLUT_BUILDING_LIB #include #include "fg_internal.h" -extern EGLSurface fghEGLPlatformOpenWindow( EGLNativeWindowType handle ); +#include "egl/fg_window_egl.h" +#include "android/fg_main_android.h" /* * Opens a window. Requires a SFG_Window object created and attached @@ -40,18 +41,18 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, GLboolean sizeUse, int w, int h, GLboolean gameMode, GLboolean isSubWindow ) { - printf("fgPlatformOpenWindow %p ID=%d\n", (void*)window, window->ID); - /* TODO: only one full-screen window possible? */ static int nb_windows = 0; if (nb_windows == 0) { nb_windows++; fgDisplay.pDisplay.single_window = window; - printf("=> %p ID=%d\n", (void*)fgDisplay.pDisplay.single_window, fgDisplay.pDisplay.single_window->ID); } else { 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 @@ -64,17 +65,29 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, 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 */ } /*