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) {