diff --git a/README.md b/README.md index a82a2ada..e261af04 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ information on what to include when reporting a bug. `linmath.h` (#785) - [Win32] Bugfix: The first shown window ignored the `GLFW_MAXIMIZED` hint when the process was provided a `STARTUPINFO` (#780) + - [WGL] Added reporting of errors from `WGL_ARB_create_context` extension - [GLX] Bugfix: Dynamically loaded entry points were not verified - [EGL] Added `lib` prefix matching between EGL and OpenGL ES library binaries - [EGL] Bugfix: Dynamically loaded entry points were not verified diff --git a/src/wgl_context.c b/src/wgl_context.c index c3af4675..696c4cba 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -623,8 +623,44 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, share, attribs); if (!window->context.wgl.handle) { - _glfwInputError(GLFW_VERSION_UNAVAILABLE, - "WGL: Failed to create OpenGL context"); + const DWORD error = GetLastError(); + + if (error == (0xc0070000 | ERROR_INVALID_VERSION_ARB)) + { + if (ctxconfig->client == GLFW_OPENGL_API) + { + _glfwInputError(GLFW_VERSION_UNAVAILABLE, + "WGL: Driver does not support OpenGL version %i.%i", + ctxconfig->major, + ctxconfig->minor); + } + else + { + _glfwInputError(GLFW_VERSION_UNAVAILABLE, + "WGL: Driver does not support OpenGL ES version %i.%i", + ctxconfig->major, + ctxconfig->minor); + } + } + else if (error == (0xc0070000 | ERROR_INVALID_PROFILE_ARB)) + { + _glfwInputError(GLFW_VERSION_UNAVAILABLE, + "WGL: Driver does not support the requested OpenGL profile"); + } + else + { + if (ctxconfig->client == GLFW_OPENGL_API) + { + _glfwInputError(GLFW_VERSION_UNAVAILABLE, + "WGL: Failed to create OpenGL context"); + } + else + { + _glfwInputError(GLFW_VERSION_UNAVAILABLE, + "WGL: Failed to create OpenGL ES context"); + } + } + return GLFW_FALSE; } } diff --git a/src/wgl_context.h b/src/wgl_context.h index e3a22025..b837d438 100644 --- a/src/wgl_context.h +++ b/src/wgl_context.h @@ -73,6 +73,9 @@ #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#define ERROR_INVALID_VERSION_ARB 0x2095 +#define ERROR_INVALID_PROFILE_ARB 0x2096 + typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*); typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);