From 6063a63f283868b7124f53a5babb38f7f02eefb8 Mon Sep 17 00:00:00 2001 From: Vera-Firefly <1964762970@qq.com> Date: Thu, 14 Nov 2024 18:17:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D[=E6=A1=A5=E6=8E=A5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE]:=20=E4=BF=AE=E5=A4=8D=E9=85=8D=E7=BD=AE2=E9=97=AA?= =?UTF-8?q?=E5=B1=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/jni/ctxbridges/osm_bridge_xxx2.c | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/app_pojavlauncher/src/main/jni/ctxbridges/osm_bridge_xxx2.c b/app_pojavlauncher/src/main/jni/ctxbridges/osm_bridge_xxx2.c index 5a215c0c..5136a46c 100644 --- a/app_pojavlauncher/src/main/jni/ctxbridges/osm_bridge_xxx2.c +++ b/app_pojavlauncher/src/main/jni/ctxbridges/osm_bridge_xxx2.c @@ -17,6 +17,8 @@ ANativeWindow_Buffer buf; int32_t stride; + +static bool hasCleaned = false; void *abuffer; void *xxx2OsmGetCurrentContext() { @@ -32,15 +34,19 @@ void xxx2OsmSwapBuffers() { if (ctx == NULL) printf("Zink: attempted to swap buffers without context!"); - OSMesaMakeCurrent_p(ctx,buf.bits,GL_UNSIGNED_BYTE,pojav_environ->savedWidth,pojav_environ->savedHeight); + ANativeWindow_lock(pojav_environ->pojavWindow, &buf, NULL); + OSMesaMakeCurrent_p(ctx, buf.bits, GL_UNSIGNED_BYTE, pojav_environ->savedWidth, pojav_environ->savedHeight); glFinish_p(); + + if (buf.stride != stride) + OSMesaPixelStore_p(OSMESA_ROW_LENGTH, buf.stride); + stride = buf.stride; + ANativeWindow_unlockAndPost(pojav_environ->pojavWindow); - ANativeWindow_lock(pojav_environ->pojavWindow,&buf,NULL); } void xxx2OsmMakeCurrent(void *window) { printf("OSMDroid: making current\n"); - if (SpareBuffer()) { #ifdef FRAME_BUFFER_SUPPOST @@ -58,16 +64,22 @@ void xxx2OsmMakeCurrent(void *window) { pojav_environ->savedWidth, pojav_environ->savedHeight); - ANativeWindow_lock(pojav_environ->pojavWindow,&buf,NULL); - OSMesaPixelStore_p(OSMESA_ROW_LENGTH,buf.stride); + OSMesaPixelStore_p(OSMESA_Y_UP, 0); + if (!hasCleaned) ANativeWindow_lock(pojav_environ->pojavWindow, &buf, NULL); + + if (buf.stride != stride) + OSMesaPixelStore_p(OSMESA_ROW_LENGTH, buf.stride); stride = buf.stride; - OSMesaPixelStore_p(OSMESA_Y_UP,0); - printf("OSMDroid: vendor: %s\n",glGetString_p(GL_VENDOR)); - printf("OSMDroid: renderer: %s\n",glGetString_p(GL_RENDERER)); - glClear_p(GL_COLOR_BUFFER_BIT); - glClearColor_p(0.4f, 0.4f, 0.4f, 1.0f); - xxx2OsmSwapBuffers(); + printf("OSMDroid: vendor: %s\n", glGetString_p(GL_VENDOR)); + printf("OSMDroid: renderer: %s\n", glGetString_p(GL_RENDERER)); + if (!hasCleaned) + { + hasCleaned = true; + glClear_p(GL_COLOR_BUFFER_BIT); + glClearColor_p(0.4f, 0.4f, 0.4f, 1.0f); + ANativeWindow_unlockAndPost(pojav_environ->pojavWindow); + } } void *xxx2OsmCreateContext(void *contextSrc) {