From c844fea9dfa7614913d3a2f6e1120419a61ee184 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 1 Aug 2016 20:47:29 +0200 Subject: [PATCH] Improve client API error messages Add separate strings for each client API to make it easier to grep. Remove 'client' from fallback error messages as API-related error tokens are used for non-client APIs as well. --- src/context.c | 45 +++++++++++++++++++++++++++++++++++++-------- src/init.c | 4 ++-- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/context.c b/src/context.c index 739a14bc..85bce7fb 100644 --- a/src/context.c +++ b/src/context.c @@ -348,8 +348,17 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig) version = (const char*) window->context.GetString(GL_VERSION); if (!version) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Client API version string retrieval is broken"); + if (ctxconfig->client == GLFW_OPENGL_API) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "OpenGL version string retrieval is broken"); + } + else + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "OpenGL ES version string retrieval is broken"); + } + return GLFW_FALSE; } @@ -370,8 +379,17 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig) &window->context.minor, &window->context.revision)) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "No version found in client API version string"); + if (window->context.client == GLFW_OPENGL_API) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "No version found in OpenGL version string"); + } + else + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "No version found in OpenGL ES version string"); + } + return GLFW_FALSE; } @@ -386,10 +404,21 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig) // For API consistency, we emulate the behavior of the // {GLX|WGL}_ARB_create_context extension and fail here - _glfwInputError(GLFW_VERSION_UNAVAILABLE, - "Requested client API version %i.%i, got version %i.%i", - ctxconfig->major, ctxconfig->minor, - window->context.major, window->context.minor); + if (window->context.client == GLFW_OPENGL_API) + { + _glfwInputError(GLFW_VERSION_UNAVAILABLE, + "Requested OpenGL version %i.%i, got version %i.%i", + ctxconfig->major, ctxconfig->minor, + window->context.major, window->context.minor); + } + else + { + _glfwInputError(GLFW_VERSION_UNAVAILABLE, + "Requested OpenGL ES version %i.%i, got version %i.%i", + ctxconfig->major, ctxconfig->minor, + window->context.major, window->context.minor); + } + return GLFW_FALSE; } diff --git a/src/init.c b/src/init.c index b699b51a..9d4a2b25 100644 --- a/src/init.c +++ b/src/init.c @@ -65,9 +65,9 @@ static const char* getErrorString(int error) case GLFW_OUT_OF_MEMORY: return "Out of memory"; case GLFW_API_UNAVAILABLE: - return "The requested client API is unavailable"; + return "The requested API is unavailable"; case GLFW_VERSION_UNAVAILABLE: - return "The requested client API version is unavailable"; + return "The requested API version is unavailable"; case GLFW_PLATFORM_ERROR: return "A platform-specific error occurred"; case GLFW_FORMAT_UNAVAILABLE: