I got this error too on nvidia when requesting a context with a version <= 3.2, but from what I understand from the spec, this is not the correct behavior.<br>
The 0x2096 part corresponds to ERROR_INVALID_PROFILE_ARB (I don't know
what is the meaning of the 0xc0070000 part and if it is nvidia specific
or not). <br><br>
I would be very interested to know what is the behavior of others vendors but I only have nvidia hardware here.<br><br><div class="gmail_quote">On Wed, Nov 2, 2011 at 1:17 PM, Jose Fonseca <span dir="ltr"><<a href="mailto:jfonseca@vmware.com">jfonseca@vmware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I've pushed, but it doesn't work on nvidia.<br>
<br>
It fails with error 0xc0072096.<br>
<br>
Have you tried with different implementations?<br>
<br>
Jose<br>
<div><div></div><div class="h5"><br>
----- Original Message -----<br>
> ---<br>
> src/wgl/CMakeLists.txt | 1 +<br>
> src/wgl/wglcontext.c | 274<br>
> ++++++++++++++++++++++++++++++++++++++++++++++++<br>
> 2 files changed, 275 insertions(+), 0 deletions(-)<br>
> create mode 100644 src/wgl/wglcontext.c<br>
><br>
> diff --git a/src/wgl/CMakeLists.txt b/src/wgl/CMakeLists.txt<br>
> index 834e836..88e6a20 100644<br>
> --- a/src/wgl/CMakeLists.txt<br>
> +++ b/src/wgl/CMakeLists.txt<br>
> @@ -13,5 +13,6 @@ add_executable (wgl_sharedtex_mt sharedtex_mt.c)<br>
> set_target_properties (wgl_sharedtex_mt PROPERTIES OUTPUT_NAME<br>
> sharedtex_mt)<br>
><br>
> add_executable (wglinfo wglinfo.c)<br>
> +add_executable (wglcontext wglcontext.c)<br>
><br>
> install (TARGETS wglthreads wgl_sharedtex_mt wglinfo DESTINATION<br>
> wgl)<br>
> diff --git a/src/wgl/wglcontext.c b/src/wgl/wglcontext.c<br>
> new file mode 100644<br>
> index 0000000..41e44cd<br>
> --- /dev/null<br>
> +++ b/src/wgl/wglcontext.c<br>
> @@ -0,0 +1,274 @@<br>
> +/*<br>
> + * Copyright (C) 2011 Morgan Armand <<a href="mailto:morgan.devel@gmail.com">morgan.devel@gmail.com</a>><br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person<br>
> obtaining a<br>
> + * copy of this software and associated documentation files (the<br>
> "Software"),<br>
> + * to deal in the Software without restriction, including without<br>
> limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute,<br>
> sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom<br>
> the<br>
> + * Software is furnished to do so, subject to the following<br>
> conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice shall be<br>
> included<br>
> + * in all copies or substantial portions of the Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
> EXPRESS<br>
> + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
> MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO<br>
> EVENT SHALL<br>
> + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,<br>
> WHETHER IN<br>
> + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR<br>
> IN<br>
> + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br>
> SOFTWARE.<br>
> + */<br>
> +<br>
> +#include <windows.h><br>
> +#include <stdio.h><br>
> +#include <stdlib.h><br>
> +#include <GL/gl.h><br>
> +#include <GL/glext.h><br>
> +#include <GL/wglext.h><br>
> +<br>
> +static LRESULT CALLBACK<br>
> +WndProc(HWND hWnd,<br>
> + UINT uMsg,<br>
> + WPARAM wParam,<br>
> + LPARAM lParam )<br>
> +{<br>
> + switch (uMsg) {<br>
> + case WM_DESTROY:<br>
> + PostQuitMessage(0);<br>
> + break;<br>
> + default:<br>
> + return DefWindowProc(hWnd, uMsg, wParam, lParam);<br>
> + }<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static char *<br>
> +context_error_to_string(DWORD error)<br>
> +{<br>
> + switch (error) {<br>
> + case ERROR_INVALID_VERSION_ARB: return<br>
> "ERROR_INVALID_VERSION_ARB";<br>
> + case ERROR_INVALID_PROFILE_ARB: return<br>
> "ERROR_INVALID_PROFILE_ARB";<br>
> + case ERROR_INVALID_OPERATION: return<br>
> "ERROR_INVALID_OPERATION";<br>
> + case ERROR_DC_NOT_FOUND: return "ERROR_DC_NOT_FOUND";<br>
> + case ERROR_INVALID_PIXEL_FORMAT: return<br>
> "ERROR_INVALID_PIXEL_FORMAT";<br>
> + case ERROR_NO_SYSTEM_RESOURCES: return<br>
> "ERROR_NO_SYSTEM_RESOURCES";<br>
> + case ERROR_INVALID_PARAMETER: return<br>
> "ERROR_INVALID_PARAMETER";<br>
> + default: return "Unknown Error";<br>
> + }<br>
> +}<br>
> +<br>
> +static char *<br>
> +profile_mask_to_string(GLint profileMask)<br>
> +{<br>
> + switch (profileMask) {<br>
> + case WGL_CONTEXT_CORE_PROFILE_BIT_ARB:<br>
> + return "WGL_CONTEXT_CORE_PROFILE_BIT_ARB";<br>
> + case WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:<br>
> + return "WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB";<br>
> + default:<br>
> + return "0";<br>
> + }<br>
> +}<br>
> +<br>
> +static void<br>
> +print_context_infos()<br>
> +{<br>
> + GLint majorVersion;<br>
> + GLint minorVersion;<br>
> + GLint profileMask;<br>
> + const GLubyte *version;<br>
> +<br>
> + fprintf(stdout, "Context Informations\n");<br>
> +<br>
> + version = glGetString(GL_VERSION);<br>
> + fprintf(stdout, "GL_VERSION: %s\n", glGetString(GL_VERSION));<br>
> +<br>
> + // Request informations with the new 3.x features.<br>
> + if (sscanf(version, "%d.%d", &majorVersion, &minorVersion) != 2)<br>
> + return;<br>
> +<br>
> + if (majorVersion >= 3) {<br>
> + glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);<br>
> + glGetIntegerv(GL_MINOR_VERSION, &minorVersion);<br>
> + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profileMask);<br>
> + fprintf(stdout, "GL_MAJOR_VERSION: %d\n", majorVersion);<br>
> + fprintf(stdout, "GL_MINOR_VERSION: %d\n", minorVersion);<br>
> + fprintf(stdout, "GL_CONTEXT_PROFILE_MASK: %s\n",<br>
> profile_mask_to_string(profileMask));<br>
> + }<br>
> +}<br>
> +<br>
> +static void<br>
> +create_context(int majorVersion, int minorVersion, int profileMask,<br>
> int<br>
> contextFlags)<br>
> +{<br>
> + WNDCLASS wc;<br>
> + HWND win;<br>
> + HDC hdc;<br>
> + PIXELFORMATDESCRIPTOR pfd;<br>
> + int pixelFormat;<br>
> + HGLRC tmp, ctx;<br>
> + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;<br>
> + int attribsList[] = {<br>
> + WGL_CONTEXT_MAJOR_VERSION_ARB, 1,<br>
> + WGL_CONTEXT_MINOR_VERSION_ARB, 0,<br>
> + WGL_CONTEXT_FLAGS_ARB, 0,<br>
> + WGL_CONTEXT_PROFILE_MASK_ARB,<br>
> WGL_CONTEXT_CORE_PROFILE_BIT_ARB,<br>
> + 0<br>
> + };<br>
> +<br>
> + memset(&wc, 0, sizeof(wc));<br>
> + wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;<br>
> + wc.lpfnWndProc = WndProc;<br>
> + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br>
> + wc.hCursor = LoadCursor(NULL, IDC_ARROW);<br>
> + wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);<br>
> + wc.lpszClassName = "wglcontext";<br>
> +<br>
> + if (!RegisterClass(&wc)) {<br>
> + fprintf(stderr, "RegisterClass() failed\n");<br>
> + return;<br>
> + }<br>
> +<br>
> + win = CreateWindowEx(0,<br>
> + wc.lpszClassName,<br>
> + "wglinfo",<br>
> + WS_CLIPSIBLINGS | WS_CLIPCHILDREN,<br>
> + CW_USEDEFAULT,<br>
> + CW_USEDEFAULT,<br>
> + CW_USEDEFAULT,<br>
> + CW_USEDEFAULT,<br>
> + NULL,<br>
> + NULL,<br>
> + wc.hInstance,<br>
> + NULL);<br>
> + if (!win) {<br>
> + fprintf(stderr, "CreateWindowEx() failed\n");<br>
> + return;<br>
> + }<br>
> +<br>
> + hdc = GetDC(win);<br>
> + if (!hdc) {<br>
> + fprintf(stderr, "GetDC() failed\n");<br>
> + return;<br>
> + }<br>
> +<br>
> + memset(&pfd, 0, sizeof(pfd));<br>
> + pfd.nVersion = 1;<br>
> + pfd.nSize = sizeof(pfd);<br>
> + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;<br>
> + pfd.iPixelType = PFD_TYPE_RGBA;<br>
> + pfd.cColorBits = 24;<br>
> + pfd.cDepthBits = 24;<br>
> + pfd.iLayerType = PFD_MAIN_PLANE;<br>
> +<br>
> + pixelFormat = ChoosePixelFormat(hdc, &pfd);<br>
> + if (!pixelFormat) {<br>
> + fprintf(stderr, "ChoosePixelFormat() failed\n");<br>
> + return;<br>
> + }<br>
> +<br>
> + if (!SetPixelFormat(hdc, pixelFormat, &pfd)) {<br>
> + fprintf(stderr, "SetPixelFormat() failed\n");<br>
> + return;<br>
> + }<br>
> +<br>
> + tmp = wglCreateContext(hdc);<br>
> + if (!tmp) {<br>
> + fprintf(stderr, "wglCreateContext() failed\n");<br>
> + return;<br>
> + }<br>
> +<br>
> + if (!wglMakeCurrent(hdc, tmp)) {<br>
> + fprintf(stderr, "wglMakeCurrent() failed\n");<br>
> + return;<br>
> + }<br>
> +<br>
> + wglCreateContextAttribsARB =<br>
> +<br>
> (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");<br>
> +<br>
> + if (!wglCreateContextAttribsARB) {<br>
> + fprintf(stderr, "wglCreateContextAttribsARB isn't<br>
> supported\n");<br>
> + return;<br>
> + }<br>
> +<br>
> + attribsList[1] = majorVersion;<br>
> + attribsList[3] = minorVersion;<br>
> + attribsList[5] = contextFlags;<br>
> + attribsList[7] = profileMask;<br>
> +<br>
> + ctx = wglCreateContextAttribsARB(hdc, 0, attribsList);<br>
> + if (!ctx) {<br>
> + DWORD error = GetLastError();<br>
> + fprintf(stderr, "wglCreateContextAttribsARB failed(): %s<br>
> (0x%x)\n",<br>
> + context_error_to_string(error), error);<br>
> + return;<br>
> + }<br>
> +<br>
> + wglMakeCurrent(NULL, NULL);<br>
> + wglDeleteContext(tmp);<br>
> +<br>
> + if (!wglMakeCurrent(hdc, ctx)) {<br>
> + fprintf(stderr, "wglMakeCurrent() failed\n");<br>
> + return;<br>
> + }<br>
> +<br>
> + print_context_infos(majorVersion);<br>
> +}<br>
> +<br>
> +static void<br>
> +usage(void)<br>
> +{<br>
> + fprintf(stdout, "Usage: wglcontext [-h] [-major <major>] [-minor<br>
> <minor>] [-core] [-compat] [-debug] [-forward]\n");<br>
> + fprintf(stdout, " -major : specify the major version you<br>
> want\n");<br>
> + fprintf(stdout, " -minor : specify the minor version you<br>
> want\n");<br>
> + fprintf(stdout, " -core : request a context implementing the<br>
> core profile\n");<br>
> + fprintf(stdout, " -compat : request a context implementing the<br>
> compatibility profile\n");<br>
> + fprintf(stdout, " -debug : request a debug context\n");<br>
> + fprintf(stdout, " -forward : request a forward-compatible<br>
> context\n");<br>
> +<br>
> +}<br>
> +<br>
> +int<br>
> +main(int argc, char *argv[])<br>
> +{<br>
> + int i;<br>
> + int majorVersion = 1, minorVersion = 0;<br>
> + int contextFlags = 0x0;<br>
> + int profileMask = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;<br>
> +<br>
> + for (i = 1; i < argc; i++) {<br>
> + if (strcmp(argv[i], "-h") == 0) {<br>
> + usage();<br>
> + exit(0);<br>
> + }<br>
> + else if (strcmp(argv[i], "-major") == 0 && i + 1 < argc) {<br>
> + majorVersion = (int)strtol(argv[i + 1], (char **)NULL, 10);<br>
> + i++;<br>
> + }<br>
> + else if (strcmp(argv[i], "-minor") == 0 && i + 1 < argc) {<br>
> + minorVersion = (int)strtol(argv[i + 1], (char **)NULL, 10);<br>
> + i++;<br>
> + }<br>
> + else if (strcmp(argv[i], "-core") == 0) {<br>
> + profileMask = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;<br>
> + }<br>
> + else if (strcmp(argv[i], "-compat") == 0) {<br>
> + profileMask = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;<br>
> + }<br>
> + else if (strcmp(argv[i], "-debug") == 0) {<br>
> + contextFlags |= WGL_CONTEXT_DEBUG_BIT_ARB;<br>
> + }<br>
> + else if (strcmp(argv[i], "-forward") == 0) {<br>
> + contextFlags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;<br>
> + }<br>
> + else {<br>
> + usage();<br>
> + exit(1);<br>
> + }<br>
> + }<br>
> +<br>
> + create_context(majorVersion, minorVersion,<br>
> + profileMask, contextFlags);<br>
> +<br>
> + return 0;<br>
> +}<br>
> --<br>
> 1.7.7.1.msysgit.0<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
><br>
</blockquote></div><br>