Use perhaps a better form of access

This commit is contained in:
Vera-Firefly 2024-04-10 19:03:35 +08:00 committed by GitHub
parent e8a19d5bff
commit 707616c59c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 20 deletions

View File

@ -125,7 +125,7 @@ static void swapBuffersOSMesa(_GLFWwindow* window)
if (strcmp(getenv("LIBGL_STRING"), "VirGLRenderer") == 0) {
window->context.Finish();
vtest_swap_buffers();
} else if (strcmp(getenv("LIBGL_STRING"), "Zink") == 0 || strcmp(getenv("LIBGL_STRING"), "Freedreno") == 0) {
} else {
OSMesaContext context = OSMesaGetCurrentContext();
if (context == NULL) {
printf("OSMesa: attempted to swap buffers without context!");
@ -165,8 +165,6 @@ static void set_vulkan_ptr(void* ptr) {
}
void load_vulkan() {
if(getenv("FCL_ZINK_PREFER_SYSTEM_DRIVER") == NULL && android_get_device_api_level() >= 28) {
// the loader does not support below that
#ifdef ADRENO_POSSIBLE
void* result = load_turnip_vulkan();
if(result != NULL) {
@ -175,7 +173,6 @@ void load_vulkan() {
return;
}
#endif
}
printf("OSMDroid: loading vulkan regularly...\n");
void* vulkan_ptr = dlopen("libvulkan.so", RTLD_LAZY | RTLD_LOCAL);
printf("OSMDroid: loaded vulkan, ptr=%p\n", vulkan_ptr);
@ -187,16 +184,12 @@ GLFWbool _glfwInitOSMesa(void)
if (_glfw.osmesa.handle)
return GLFW_TRUE;
_glfw.osmesa.handle = _glfw_dlopen(getenv("LIBGL_NAME"));
const char *renderer = getenv("LIBGL_STRING");
if (strcmp(renderer, "VirGLRenderer") == 0) {
_glfw.osmesa.handle = _glfw_dlopen("libOSMesa_81.so");
} else if (strcmp(renderer, "Zink") == 0) {
if (strcmp(renderer, "Zink") == 0)
load_vulkan();
_glfw.osmesa.handle = _glfw_dlopen("libOSMesa_8.so");
} else if (strcmp(renderer, "Freedreno") == 0) {
_glfw.osmesa.handle = _glfw_dlopen("libOSMesa_8.so");
}
if (!_glfw.osmesa.handle)
{

View File

@ -229,7 +229,7 @@ void glfwDefaultWindowHints(void)
// The default is OpenGL with minimum version 1.0
memset(&_glfw.hints.context, 0, sizeof(_glfw.hints.context));
_glfw.hints.context.client = GLFW_OPENGL_API;
_glfw.hints.context.source = (strcmp(getenv("LIBGL_NAME"), "libOSMesa_8.so") == 0 || strcmp(getenv("LIBGL_NAME"), "libOSMesa_81.so") == 0) ? GLFW_OSMESA_CONTEXT_API : GLFW_NATIVE_CONTEXT_API;
_glfw.hints.context.source = (strncmp(getenv("LIBGL_NAME"), "libOSMesa", 9) == 0) ? GLFW_OSMESA_CONTEXT_API : GLFW_NATIVE_CONTEXT_API;
_glfw.hints.context.major = 1;
_glfw.hints.context.minor = 0;
@ -355,7 +355,7 @@ GLFWAPI void glfwWindowHint(int hint, int value)
_glfw.hints.context.client = value;
return;
case GLFW_CONTEXT_CREATION_API:
_glfw.hints.context.source = (strcmp(getenv("LIBGL_NAME"), "libOSMesa_8.so") == 0 || strcmp(getenv("LIBGL_NAME"), "libOSMesa_81.so") == 0) ? GLFW_OSMESA_CONTEXT_API : value;
_glfw.hints.context.source = (strncmp(getenv("LIBGL_NAME"), "libOSMesa", 9) == 0) ? GLFW_OSMESA_CONTEXT_API : value;
return;
case GLFW_CONTEXT_VERSION_MAJOR:
_glfw.hints.context.major = value;