Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/freeglut/src/android/fg_window_android.c @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * fg_window_android.c | |
| 3 * | |
| 4 * Window management methods for Android | |
| 5 * | |
| 6 * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved. | |
| 7 * Written by Pawel W. Olszta, <olszta@sourceforge.net> | |
| 8 * Copied for Platform code by Evan Felix <karcaw at gmail.com> | |
| 9 * Copyright (C) 2012 Sylvain Beucler | |
| 10 * | |
| 11 * Permission is hereby granted, free of charge, to any person obtaining a | |
| 12 * copy of this software and associated documentation files (the "Software"), | |
| 13 * to deal in the Software without restriction, including without limitation | |
| 14 * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
| 15 * and/or sell copies of the Software, and to permit persons to whom the | |
| 16 * Software is furnished to do so, subject to the following conditions: | |
| 17 * | |
| 18 * The above copyright notice and this permission notice shall be included | |
| 19 * in all copies or substantial portions of the Software. | |
| 20 * | |
| 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
| 22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
| 24 * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | |
| 25 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
| 26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 27 */ | |
| 28 | |
| 29 #define FREEGLUT_BUILDING_LIB | |
| 30 #include <GL/freeglut.h> | |
| 31 #include "fg_internal.h" | |
| 32 #include "egl/fg_window_egl.h" | |
| 33 #include <android/native_app_glue/android_native_app_glue.h> | |
| 34 | |
| 35 /* | |
| 36 * Opens a window. Requires a SFG_Window object created and attached | |
| 37 * to the freeglut structure. OpenGL context is created here. | |
| 38 */ | |
| 39 void fgPlatformOpenWindow( SFG_Window* window, const char* title, | |
| 40 GLboolean positionUse, int x, int y, | |
| 41 GLboolean sizeUse, int w, int h, | |
| 42 GLboolean gameMode, GLboolean isSubWindow ) | |
| 43 { | |
| 44 /* TODO: only one full-screen window possible? */ | |
| 45 if (fgDisplay.pDisplay.single_native_window != NULL) { | |
| 46 fgWarning("You can't have more than one window on Android"); | |
| 47 return; | |
| 48 } | |
| 49 | |
| 50 /* First, wait until Activity surface is available */ | |
| 51 /* Normally events are processed through glutMainLoop(), but the | |
| 52 user didn't call it yet, and the Android may not have initialized | |
| 53 the View yet. So we need to wait for that to happen. */ | |
| 54 /* We can't return from this function before the OpenGL context is | |
| 55 properly made current with a valid surface. So we wait for the | |
| 56 surface. */ | |
| 57 while (fgDisplay.pDisplay.single_native_window == NULL) { | |
| 58 /* APP_CMD_INIT_WINDOW will do the job */ | |
| 59 int ident; | |
| 60 int events; | |
| 61 struct android_poll_source* source; | |
| 62 if ((ident=ALooper_pollOnce(0, NULL, &events, (void**)&source)) >= 0) | |
| 63 if (source != NULL) source->process(source->app, source); | |
| 64 /* fgPlatformProcessSingleEvent(); */ | |
| 65 } | |
| 66 window->Window.Handle = fgDisplay.pDisplay.single_native_window; | |
| 67 window->State.WorkMask |= GLUT_INIT_WORK; | |
| 68 | |
| 69 /* Create context */ | |
| 70 fghChooseConfig(&window->Window.pContext.egl.Config); | |
| 71 window->Window.Context = fghCreateNewContextEGL(window); | |
| 72 | |
| 73 EGLDisplay display = fgDisplay.pDisplay.egl.Display; | |
| 74 | |
| 75 /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is | |
| 76 * guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). | |
| 77 * As soon as we picked a EGLConfig, we can safely reconfigure the | |
| 78 * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */ | |
| 79 EGLint vid; | |
| 80 eglGetConfigAttrib(display, window->Window.pContext.egl.Config, | |
| 81 EGL_NATIVE_VISUAL_ID, &vid); | |
| 82 ANativeWindow_setBuffersGeometry(window->Window.Handle, 0, 0, vid); | |
| 83 | |
| 84 fghPlatformOpenWindowEGL(window); | |
| 85 | |
| 86 /* Bind context to the current thread if it's lost */ | |
| 87 if (eglGetCurrentContext() == EGL_NO_CONTEXT && | |
| 88 eglMakeCurrent(fgDisplay.pDisplay.egl.Display, | |
| 89 window->Window.pContext.egl.Surface, | |
| 90 window->Window.pContext.egl.Surface, | |
| 91 window->Window.Context) == EGL_FALSE) | |
| 92 fgError("eglMakeCurrent: err=%x\n", eglGetError()); | |
| 93 | |
| 94 window->State.Visible = GL_TRUE; | |
| 95 } | |
| 96 | |
| 97 /* | |
| 98 * Request a window resize | |
| 99 */ | |
| 100 void fgPlatformReshapeWindow ( SFG_Window *window, int width, int height ) | |
| 101 { | |
| 102 fprintf(stderr, "fgPlatformReshapeWindow: STUB\n"); | |
| 103 } | |
| 104 | |
| 105 /* | |
| 106 * Closes a window, destroying the frame and OpenGL context | |
| 107 */ | |
| 108 void fgPlatformCloseWindow( SFG_Window* window ) | |
| 109 { | |
| 110 fghPlatformCloseWindowEGL(window); | |
| 111 /* Window pre-created by Android, no way to delete it */ | |
| 112 } | |
| 113 | |
| 114 /* | |
| 115 * This function makes the specified window visible | |
| 116 */ | |
| 117 void fgPlatformShowWindow( void ) | |
| 118 { | |
| 119 fprintf(stderr, "fgPlatformShowWindow: STUB\n"); | |
| 120 } | |
| 121 | |
| 122 /* | |
| 123 * This function hides the specified window | |
| 124 */ | |
| 125 void fgPlatformHideWindow( SFG_Window *window ) | |
| 126 { | |
| 127 fprintf(stderr, "fgPlatformHideWindow: STUB\n"); | |
| 128 } | |
| 129 | |
| 130 /* | |
| 131 * Iconify the specified window (top-level windows only) | |
| 132 */ | |
| 133 void fgPlatformIconifyWindow( SFG_Window *window ) | |
| 134 { | |
| 135 fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n"); | |
| 136 } | |
| 137 | |
| 138 /* | |
| 139 * Set the current window's title | |
| 140 */ | |
| 141 void fgPlatformGlutSetWindowTitle( const char* title ) | |
| 142 { | |
| 143 fprintf(stderr, "fgPlatformGlutSetWindowTitle: STUB\n"); | |
| 144 } | |
| 145 | |
| 146 /* | |
| 147 * Set the current window's iconified title | |
| 148 */ | |
| 149 void fgPlatformGlutSetIconTitle( const char* title ) | |
| 150 { | |
| 151 fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n");} | |
| 152 | |
| 153 /* | |
| 154 * Change the specified window's position | |
| 155 */ | |
| 156 void fgPlatformPositionWindow( SFG_Window *window, int x, int y ) | |
| 157 { | |
| 158 fprintf(stderr, "fgPlatformPositionWindow: STUB\n"); | |
| 159 } | |
| 160 | |
| 161 /* | |
| 162 * Lowers the specified window (by Z order change) | |
| 163 */ | |
| 164 void fgPlatformPushWindow( SFG_Window *window ) | |
| 165 { | |
| 166 fprintf(stderr, "fgPlatformPushWindow: STUB\n"); | |
| 167 } | |
| 168 | |
| 169 /* | |
| 170 * Raises the specified window (by Z order change) | |
| 171 */ | |
| 172 void fgPlatformPopWindow( SFG_Window *window ) | |
| 173 { | |
| 174 fprintf(stderr, "fgPlatformPopWindow: STUB\n"); | |
| 175 } | |
| 176 | |
| 177 /* | |
| 178 * Toggle the window's full screen state. | |
| 179 */ | |
| 180 void fgPlatformFullScreenToggle( SFG_Window *win ) | |
| 181 { | |
| 182 fprintf(stderr, "fgPlatformFullScreenToggle: STUB\n"); | |
| 183 } |
