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

@ -347,9 +347,18 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
version = (const char*) window->context.GetString(GL_VERSION);
if (!version)
{
if (ctxconfig->client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Client API version string retrieval is broken");
"OpenGL version string retrieval is broken");
}
else
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"OpenGL ES version string retrieval is broken");
}
return GLFW_FALSE;
}
@ -369,9 +378,18 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
&window->context.major,
&window->context.minor,
&window->context.revision))
{
if (window->context.client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"No version found in client API version string");
"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
if (window->context.client == GLFW_OPENGL_API)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"Requested client API version %i.%i, got version %i.%i",
"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;
}

View File

@ -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: