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.
This commit is contained in:
Camilla Berglund 2016-08-01 20:47:29 +02:00
parent 923568a279
commit c844fea9df
2 changed files with 39 additions and 10 deletions

View File

@ -348,8 +348,17 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
version = (const char*) window->context.GetString(GL_VERSION); version = (const char*) window->context.GetString(GL_VERSION);
if (!version) if (!version)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, if (ctxconfig->client == GLFW_OPENGL_API)
"Client API version string retrieval is broken"); {
_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; return GLFW_FALSE;
} }
@ -370,8 +379,17 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
&window->context.minor, &window->context.minor,
&window->context.revision)) &window->context.revision))
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, if (window->context.client == GLFW_OPENGL_API)
"No version found in client API version string"); {
_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; return GLFW_FALSE;
} }
@ -386,10 +404,21 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
// For API consistency, we emulate the behavior of the // For API consistency, we emulate the behavior of the
// {GLX|WGL}_ARB_create_context extension and fail here // {GLX|WGL}_ARB_create_context extension and fail here
_glfwInputError(GLFW_VERSION_UNAVAILABLE, if (window->context.client == GLFW_OPENGL_API)
"Requested client API version %i.%i, got version %i.%i", {
ctxconfig->major, ctxconfig->minor, _glfwInputError(GLFW_VERSION_UNAVAILABLE,
window->context.major, window->context.minor); "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; return GLFW_FALSE;
} }

View File

@ -65,9 +65,9 @@ static const char* getErrorString(int error)
case GLFW_OUT_OF_MEMORY: case GLFW_OUT_OF_MEMORY:
return "Out of memory"; return "Out of memory";
case GLFW_API_UNAVAILABLE: case GLFW_API_UNAVAILABLE:
return "The requested client API is unavailable"; return "The requested API is unavailable";
case GLFW_VERSION_UNAVAILABLE: case GLFW_VERSION_UNAVAILABLE:
return "The requested client API version is unavailable"; return "The requested API version is unavailable";
case GLFW_PLATFORM_ERROR: case GLFW_PLATFORM_ERROR:
return "A platform-specific error occurred"; return "A platform-specific error occurred";
case GLFW_FORMAT_UNAVAILABLE: case GLFW_FORMAT_UNAVAILABLE: