X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fandroid%2Ffg_window_android.c;h=58d612afe4c4771dfbbbcc37d13e8a85afa9a9cf;hb=e5cd5f98d651aad9c265e569db6188fb0378aeeb;hp=bbd17fd3a6b125c89ee76187374bcb3f96039edf;hpb=d1cccef518bc222b3733706aa1e5776c6cb9fec9;p=freeglut diff --git a/src/android/fg_window_android.c b/src/android/fg_window_android.c index bbd17fd..58d612a 100644 --- a/src/android/fg_window_android.c +++ b/src/android/fg_window_android.c @@ -40,19 +40,20 @@ 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); + // 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); + // printf("=> %p ID=%d\n", (void*)fgDisplay.pDisplay.single_window, fgDisplay.pDisplay.single_window->ID); } else { return; } - fghCreateNewContextEGL(window); + 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 @@ -67,8 +68,16 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title, } EGLDisplay display = fgDisplay.pDisplay.egl.Display; - EGLint format = fgDisplay.pDisplay.single_window->Window.pContext.egl.ContextFormat; - ANativeWindow_setBuffersGeometry(window->Window.Handle, 0, 0, format); + + /* 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; @@ -83,11 +92,6 @@ void fgPlatformCloseWindow( SFG_Window* window ) /* Window pre-created by Android, no way to delete it */ } -void fgPlatformSetWindow ( SFG_Window *window ) -{ - /* TODO: only a single window possible? */ -} - /* * This function makes the current window visible */