1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 20:28:49 -05:00

Improved error messages

This commit is contained in:
Camilla Berglund 2016-03-29 10:49:34 +02:00
parent bc713dabc4
commit 29e232f4b2
4 changed files with 37 additions and 31 deletions

View File

@ -57,7 +57,7 @@ static GLFWbool parseVersionString(int* api, int* major, int* minor, int* rev)
if (!version)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Failed to retrieve context version string");
"Client API version string retrieval is broken");
return GLFW_FALSE;
}
@ -76,7 +76,7 @@ static GLFWbool parseVersionString(int* api, int* major, int* minor, int* rev)
if (!sscanf(version, "%d.%d.%d", major, minor, rev))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"No version found in context version string");
"No version found in client API version string");
return GLFW_FALSE;
}
@ -94,7 +94,9 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
ctxconfig->api != GLFW_OPENGL_API &&
ctxconfig->api != GLFW_OPENGL_ES_API)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid client API");
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid client API %i",
ctxconfig->api);
return GLFW_FALSE;
}
@ -123,7 +125,8 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid OpenGL profile");
"Invalid OpenGL profile %i",
ctxconfig->profile);
return GLFW_FALSE;
}
@ -171,7 +174,8 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid context robustness mode");
"Invalid context robustness mode %i",
ctxconfig->robustness);
return GLFW_FALSE;
}
}
@ -182,7 +186,8 @@ GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid context release behavior");
"Invalid context release behavior %i",
ctxconfig->release);
return GLFW_FALSE;
}
}
@ -381,7 +386,10 @@ 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, NULL);
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"Requested client API version %i.%i, got version %i.%i",
ctxconfig->major, ctxconfig->minor,
window->context.major, window->context.minor);
return GLFW_FALSE;
}
@ -603,7 +611,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
if (*extension == '\0')
{
_glfwInputError(GLFW_INVALID_VALUE, NULL);
_glfwInputError(GLFW_INVALID_VALUE, "Extension name is empty string");
return GLFW_FALSE;
}
@ -623,7 +631,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
if (!en)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Failed to retrieve extension string %i", i);
"Extension string retrieval is broken");
return GLFW_FALSE;
}
@ -640,7 +648,7 @@ GLFWAPI int glfwExtensionSupported(const char* extension)
if (!extensions)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Failed to retrieve extension string");
"Extension string retrieval is broken");
return GLFW_FALSE;
}

View File

@ -44,7 +44,7 @@ static void setCursorMode(_GLFWwindow* window, int newMode)
newMode != GLFW_CURSOR_HIDDEN &&
newMode != GLFW_CURSOR_DISABLED)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid cursor mode");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid cursor mode %i", newMode);
return;
}
@ -253,7 +253,7 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
case GLFW_STICKY_MOUSE_BUTTONS:
return window->stickyMouseButtons;
default:
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode %i", mode);
return 0;
}
}
@ -277,7 +277,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
setStickyMouseButtons(window, value ? GLFW_TRUE : GLFW_FALSE);
break;
default:
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode %i", mode);
break;
}
}
@ -297,7 +297,7 @@ GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
if (key < 0 || key > GLFW_KEY_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid key");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
return GLFW_RELEASE;
}
@ -320,8 +320,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid mouse button");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid mouse button %i", button);
return GLFW_RELEASE;
}
@ -415,7 +414,7 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
shape != GLFW_HRESIZE_CURSOR &&
shape != GLFW_VRESIZE_CURSOR)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor %i", shape);
return NULL;
}
@ -570,7 +569,7 @@ GLFWAPI int glfwJoystickPresent(int joy)
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", joy);
return 0;
}
@ -586,7 +585,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count)
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", joy);
return NULL;
}
@ -602,7 +601,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count)
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", joy);
return NULL;
}
@ -615,7 +614,7 @@ GLFWAPI const char* glfwGetJoystickName(int joy)
if (joy < 0 || joy > GLFW_JOYSTICK_LAST)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick %i", joy);
return NULL;
}
@ -655,7 +654,7 @@ GLFWAPI void glfwSetTime(double time)
if (time != time || time < 0.0 || time > 18446744073.0)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid time");
_glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", time);
return;
}

View File

@ -409,7 +409,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value");
_glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma);
return;
}

View File

@ -137,7 +137,10 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
if (width <= 0 || height <= 0)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid window size");
_glfwInputError(GLFW_INVALID_VALUE,
"Invalid window size %ix%i",
width, height);
return NULL;
}
@ -372,7 +375,7 @@ GLFWAPI void glfwWindowHint(int hint, int value)
_glfw.hints.refreshRate = value;
break;
default:
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint %i", hint);
break;
}
}
@ -477,11 +480,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
_GLFW_REQUIRE_INIT();
if (window->monitor)
{
_glfwInputError(GLFW_INVALID_VALUE,
"Full screen windows cannot be moved");
return;
}
_glfwPlatformSetWindowPos(window, xpos, ypos);
}
@ -698,7 +697,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
return window->context.noerror;
}
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute");
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute %i", attrib);
return 0;
}
@ -849,7 +848,7 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout)
if (timeout != timeout || timeout < 0.0 || timeout > DBL_MAX)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid time");
_glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", timeout);
return;
}