diff options
author | Brian Paul <brianp@vmware.com> | 2014-07-15 08:39:20 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2014-07-16 07:30:30 -0600 |
commit | cf7ecd9fc576688ae105c780e07b5bbf32d9e3bd (patch) | |
tree | 9bf60726028e86cf5888e50f38b0a3fabb62ccd3 | |
parent | e769bc682b4a0d0f597286b067f54f923d159866 (diff) |
wglinfo: Add support for reporting core profile info
As with glxinfo, we first report version/extension info for a compatibility
profile context, then report version/extension info for a core profile
context.
Reviewed-by: José Fonseca <jfonseca@vmware.com>
-rw-r--r-- | src/wgl/wglinfo.c | 134 | ||||
-rw-r--r-- | src/xdemos/glinfo_common.h | 24 | ||||
-rw-r--r-- | src/xdemos/glxinfo.c | 24 |
3 files changed, 138 insertions, 44 deletions
diff --git a/src/wgl/wglinfo.c b/src/wgl/wglinfo.c index fe94dccb..16008d20 100644 --- a/src/wgl/wglinfo.c +++ b/src/wgl/wglinfo.c @@ -42,10 +42,12 @@ #include "glinfo_common.h" +static GLboolean have_WGL_ARB_create_context; static GLboolean have_WGL_ARB_pixel_format; static GLboolean have_WGL_ARB_multisample; static PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB_func; +static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB_func; /** @@ -77,7 +79,8 @@ WndProc(HWND hWnd, static void -print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine) +print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine, + GLboolean coreProfile) { WNDCLASS wc; HWND win; @@ -153,36 +156,79 @@ print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine) PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB_func = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); #endif - const char *glVendor = (const char *) glGetString(GL_VENDOR); - const char *glRenderer = (const char *) glGetString(GL_RENDERER); - const char *glVersion = (const char *) glGetString(GL_VERSION); - const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS); + const char *glVendor, *glRenderer, *glVersion, *glExtensions; + const char *wglExtensions = NULL; struct ext_functions extfuncs; #if defined(WGL_ARB_extensions_string) if (wglGetExtensionsStringARB_func) { - const char *wglExtensions = wglGetExtensionsStringARB_func(hdc); - if(wglExtensions) { - printf("WGL extensions:\n"); - print_extension_list(wglExtensions, singleLine); - } + wglExtensions = wglGetExtensionsStringARB_func(hdc); if (extension_supported("WGL_ARB_pixel_format", wglExtensions)) { have_WGL_ARB_pixel_format = GL_TRUE; } if (extension_supported("WGL_ARB_multisample", wglExtensions)) { have_WGL_ARB_multisample = GL_TRUE; } + if (extension_supported("WGL_ARB_create_context", wglExtensions)) { + have_WGL_ARB_create_context = GL_TRUE; + } } #endif - printf("OpenGL vendor string: %s\n", glVendor); - printf("OpenGL renderer string: %s\n", glRenderer); - printf("OpenGL version string: %s\n", glVersion); -#ifdef GL_VERSION_2_0 - if (glVersion[0] >= '2' && glVersion[1] == '.') { - char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION); - printf("OpenGL shading language version string: %s\n", v); + + if (coreProfile && have_WGL_ARB_create_context) { + /* Try to create a new, core context */ + HGLRC core_ctx = 0; + int i; + + wglCreateContextAttribsARB_func = + (PFNWGLCREATECONTEXTATTRIBSARBPROC) + wglGetProcAddress("wglCreateContextAttribsARB"); + assert(wglCreateContextAttribsARB_func); + if (!wglCreateContextAttribsARB_func) { + printf("Failed to get wglCreateContextAttribsARB pointer."); + return; + } + + for (i = NUM_GL_VERSIONS - 2; i > 0 ; i--) { + int attribs[10], n; + + /* don't bother below GL 3.1 */ + if (gl_versions[i].major == 3 && gl_versions[i].minor == 0) { + break; + } + + n = 0; + attribs[n++] = WGL_CONTEXT_MAJOR_VERSION_ARB; + attribs[n++] = gl_versions[i].major; + attribs[n++] = WGL_CONTEXT_MINOR_VERSION_ARB; + attribs[n++] = gl_versions[i].minor; + if (gl_versions[i].major * 10 + gl_versions[i].minor > 31) { + attribs[n++] = WGL_CONTEXT_PROFILE_MASK_ARB; + attribs[n++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; + } + attribs[n++] = 0; + + core_ctx = wglCreateContextAttribsARB_func(hdc, 0, attribs); + if (core_ctx) { + break; + } + } + + if (!core_ctx) { + printf("Failed to create core profile context.\n"); + return; + } + + ctx = core_ctx; + if (!wglMakeCurrent(hdc, ctx)) { + printf("Failed to bind core profile context.\n"); + return; + } + oglString = "OpenGL core profile"; + } + else { + coreProfile = GL_FALSE; } -#endif extfuncs.GetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) wglGetProcAddress("glGetProgramivARB"); @@ -191,9 +237,55 @@ print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine) extfuncs.GetConvolutionParameteriv = (GETCONVOLUTIONPARAMETERIVPROC) wglGetProcAddress("glGetConvolutionParameteriv"); + glVendor = (const char *) glGetString(GL_VENDOR); + glRenderer = (const char *) glGetString(GL_RENDERER); + glVersion = (const char *) glGetString(GL_VERSION); + if (coreProfile) { + glExtensions = build_core_profile_extension_list(&extfuncs); + } + else { + glExtensions = (const char *) glGetString(GL_EXTENSIONS); + } + + /* + * Print all the vendor, version, extension strings. + */ + + if (!coreProfile) { + if (wglExtensions) { + printf("WGL extensions:\n"); + print_extension_list(wglExtensions, singleLine); + } + printf("OpenGL vendor string: %s\n", glVendor); + printf("OpenGL renderer string: %s\n", glRenderer); + } + + printf("%s version string: %s\n", oglString, glVersion); + version = (glVersion[0] - '0') * 10 + (glVersion[2] - '0'); - printf("OpenGL extensions:\n"); +#ifdef GL_VERSION_2_0 + if (version >= 20) { + char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION); + printf("%s shading language version string: %s\n", oglString, v); + } +#endif +#ifdef GL_VERSION_3_0 + if (version >= 30) { + GLint flags; + glGetIntegerv(GL_CONTEXT_FLAGS, &flags); + printf("%s context flags: %s\n", oglString, context_flags_string(flags)); + } +#endif +#ifdef GL_VERSION_3_2 + if (version >= 32) { + GLint mask; + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); + printf("%s profile mask: %s\n", oglString, profile_mask_string(mask)); + } +#endif + + printf("%s extensions:\n", oglString); print_extension_list(glExtensions, singleLine); if (limits) { print_limits(glExtensions, oglString, version, &extfuncs); @@ -543,7 +635,9 @@ main(int argc, char *argv[]) printf("%d\n", b); } else { - print_screen_info(hdc, opts.limits, opts.singleLine); + print_screen_info(hdc, opts.limits, opts.singleLine, GL_FALSE); + printf("\n"); + print_screen_info(hdc, opts.limits, opts.singleLine, GL_TRUE); printf("\n"); print_visual_info(hdc, opts.mode); } diff --git a/src/xdemos/glinfo_common.h b/src/xdemos/glinfo_common.h index a2687276..41384f73 100644 --- a/src/xdemos/glinfo_common.h +++ b/src/xdemos/glinfo_common.h @@ -83,6 +83,30 @@ struct options }; +/** list of known OpenGL versions */ +static const struct { int major, minor; } gl_versions[] = { + {1, 0}, + {1, 1}, + {1, 2}, + {1, 3}, + {1, 4}, + {1, 5}, + {2, 0}, + {2, 1}, + {3, 0}, + {3, 1}, + {3, 2}, + {3, 3}, + {4, 0}, + {4, 1}, + {4, 2}, + {4, 3}, + {4, 4}, + {0, 0} /* end of list */ +}; + +#define NUM_GL_VERSIONS ELEMENTS(gl_versions) + void print_extension_list(const char *ext, GLboolean singleLine); diff --git a/src/xdemos/glxinfo.c b/src/xdemos/glxinfo.c index 6e7fa3a6..2d187f61 100644 --- a/src/xdemos/glxinfo.c +++ b/src/xdemos/glxinfo.c @@ -102,30 +102,6 @@ struct visual_attribs }; -/** list of known OpenGL versions */ -static const struct { int major, minor; } gl_versions[] = { - {1, 0}, - {1, 1}, - {1, 2}, - {1, 3}, - {1, 4}, - {1, 5}, - {2, 0}, - {2, 1}, - {3, 0}, - {3, 1}, - {3, 2}, - {3, 3}, - {4, 0}, - {4, 1}, - {4, 2}, - {4, 3}, - {4, 4}, - {0, 0} /* end of list */ -}; - -#define NUM_GL_VERSIONS ELEMENTS(gl_versions) - /** * Version of the context that was created * |