From 4e5c93315abd237ba9df0e3638bd2b10b37dc21b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 17 Jun 2024 23:55:32 +0800 Subject: [PATCH] OpenGL: print used ogl library --- src/detection/opengl/opengl.h | 1 + src/detection/opengl/opengl_apple.c | 1 + src/detection/opengl/opengl_linux.c | 9 +++++---- src/detection/opengl/opengl_windows.c | 1 + src/modules/opengl/opengl.c | 8 ++++++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/detection/opengl/opengl.h b/src/detection/opengl/opengl.h index 3c878f97c..6614ea2f2 100644 --- a/src/detection/opengl/opengl.h +++ b/src/detection/opengl/opengl.h @@ -8,6 +8,7 @@ typedef struct FFOpenGLResult FFstrbuf renderer; FFstrbuf vendor; FFstrbuf slv; + const char* library; } FFOpenGLResult; const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result); diff --git a/src/detection/opengl/opengl_apple.c b/src/detection/opengl/opengl_apple.c index e7f3ad0e9..3a8e7ac5e 100644 --- a/src/detection/opengl/opengl_apple.c +++ b/src/detection/opengl/opengl_apple.c @@ -12,6 +12,7 @@ static const char* glHandleResult(FFOpenGLResult* result) ffStrbufAppendS(&result->renderer, (const char*) glGetString(GL_RENDERER)); ffStrbufAppendS(&result->vendor, (const char*) glGetString(GL_VENDOR)); ffStrbufAppendS(&result->slv, (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); + result->library = "CGL"; return NULL; } diff --git a/src/detection/opengl/opengl_linux.c b/src/detection/opengl/opengl_linux.c index 5f471bf77..bc957add7 100644 --- a/src/detection/opengl/opengl_linux.c +++ b/src/detection/opengl/opengl_linux.c @@ -18,12 +18,13 @@ typedef struct GLData FF_LIBRARY_SYMBOL(glGetString) } GLData; -static const char* glHandleResult(FFOpenGLResult* result, const GLData* data) +static const char* glHandleResult(FFOpenGLResult* result, const GLData* data, const char* library) { ffStrbufAppendS(&result->version, (const char*) data->ffglGetString(GL_VERSION)); ffStrbufAppendS(&result->renderer, (const char*) data->ffglGetString(GL_RENDERER)); ffStrbufAppendS(&result->vendor, (const char*) data->ffglGetString(GL_VENDOR)); ffStrbufAppendS(&result->slv, (const char*) data->ffglGetString(GL_SHADING_LANGUAGE_VERSION)); + result->library = library; return NULL; } @@ -61,7 +62,7 @@ static const char* eglHandleContext(FFOpenGLResult* result, EGLData* data) if(data->ffeglMakeCurrent(data->display, data->surface, data->surface, data->context) != EGL_TRUE) return "eglMakeCurrent returned EGL_FALSE"; - return glHandleResult(result, &data->glData); + return glHandleResult(result, &data->glData, "EGL"); } static const char* eglHandleSurface(FFOpenGLResult* result, EGLData* data) @@ -173,7 +174,7 @@ static const char* glxHandleContext(FFOpenGLResult* result, GLXData* data) if(data->ffglXMakeCurrent(data->display, data->glxPixmap, data->context) != True) return "glXMakeCurrent returned False"; - return glHandleResult(result, &data->glData); + return glHandleResult(result, &data->glData, "GLX"); } static const char* glxHandleGLXPixmap(FFOpenGLResult* result, GLXData* data) @@ -284,7 +285,7 @@ static const char* osMesaHandleContext(FFOpenGLResult* result, OSMesaData* data) if(data->ffOSMesaMakeCurrent(data->context, buffer, GL_UNSIGNED_BYTE, FF_OPENGL_BUFFER_WIDTH, FF_OPENGL_BUFFER_HEIGHT) != GL_TRUE) return "OSMesaMakeCurrent returned GL_FALSE"; - return glHandleResult(result, &data->glData); + return glHandleResult(result, &data->glData, "OSMesa"); } static const char* osMesaHandleData(FFOpenGLResult* result, OSMesaData* data) diff --git a/src/detection/opengl/opengl_windows.c b/src/detection/opengl/opengl_windows.c index 91b79388f..e0b29fc8a 100644 --- a/src/detection/opengl/opengl_windows.c +++ b/src/detection/opengl/opengl_windows.c @@ -25,6 +25,7 @@ static const char* glHandleResult(WGLData* wglData) ffStrbufAppendS(&wglData->result->renderer, (const char*) wglData->ffglGetString(GL_RENDERER)); ffStrbufAppendS(&wglData->result->vendor, (const char*) wglData->ffglGetString(GL_VENDOR)); ffStrbufAppendS(&wglData->result->slv, (const char*) wglData->ffglGetString(GL_SHADING_LANGUAGE_VERSION)); + wglData->result->library = "WGL"; return NULL; } diff --git a/src/modules/opengl/opengl.c b/src/modules/opengl/opengl.c index 3f9e42211..f0f49662b 100644 --- a/src/modules/opengl/opengl.c +++ b/src/modules/opengl/opengl.c @@ -4,7 +4,7 @@ #include "modules/opengl/opengl.h" #include "util/stringUtils.h" -#define FF_OPENGL_NUM_FORMAT_ARGS 4 +#define FF_OPENGL_NUM_FORMAT_ARGS 5 void ffPrintOpenGL(FFOpenGLOptions* options) { @@ -13,6 +13,7 @@ void ffPrintOpenGL(FFOpenGLOptions* options) ffStrbufInit(&result.renderer); ffStrbufInit(&result.vendor); ffStrbufInit(&result.slv); + result.library = "Unknown"; const char* error = ffDetectOpenGL(options, &result); if(error) @@ -33,6 +34,7 @@ void ffPrintOpenGL(FFOpenGLOptions* options) {FF_FORMAT_ARG_TYPE_STRBUF, &result.renderer, "renderer"}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor, "vendor"}, {FF_FORMAT_ARG_TYPE_STRBUF, &result.slv, "slv"}, + {FF_FORMAT_ARG_TYPE_STRING, result.library, "library"}, })); } @@ -150,6 +152,7 @@ void ffGenerateOpenGLJsonResult(FF_MAYBE_UNUSED FFOpenGLOptions* options, yyjson yyjson_mut_obj_add_strbuf(doc, obj, "renderer", &result.renderer); yyjson_mut_obj_add_strbuf(doc, obj, "vendor", &result.vendor); yyjson_mut_obj_add_strbuf(doc, obj, "slv", &result.slv); + yyjson_mut_obj_add_str(doc, obj, "library", result.library); } ffStrbufDestroy(&result.version); @@ -164,7 +167,8 @@ void ffPrintOpenGLHelpFormat(void) "version - version", "renderer - renderer", "vendor - vendor", - "shading language version - slv" + "shading language version - slv", + "ogl library used - library", })); }