From 9c0e19adcaed411c77d20dede9beece41e6eb162 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 13 Dec 2012 19:18:04 +0100 Subject: [PATCH] Made error message tags more consistent. --- src/cocoa_init.m | 3 +-- src/cocoa_window.m | 2 +- src/context.c | 32 ++++++++++++-------------------- src/gamma.c | 2 +- src/glx_context.c | 4 +++- src/input.c | 4 ++-- src/nsgl_context.m | 2 +- src/window.c | 6 ++---- 8 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 3bb61c18..e4de641e 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -85,8 +85,7 @@ int _glfwPlatformInit(void) CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl")); if (_glfwLibrary.NSGL.framework == NULL) { - _glfwSetError(GLFW_PLATFORM_ERROR, - "glfwInit: Failed to locate OpenGL framework"); + _glfwSetError(GLFW_PLATFORM_ERROR, "Failed to locate OpenGL framework"); return GL_FALSE; } diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 040277a7..aa28d241 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -731,7 +731,7 @@ static GLboolean createContext(_GLFWwindow* window, if (wndconfig->clientAPI == GLFW_OPENGL_ES_API) { _glfwSetError(GLFW_VERSION_UNAVAILABLE, - "Cocoa/NSOpenGL: NSOpenGL does not support OpenGL ES"); + "NSOpenGL: This API does not support OpenGL ES"); return GL_FALSE; } diff --git a/src/context.c b/src/context.c index 4dba4a81..4eb2c6d4 100644 --- a/src/context.c +++ b/src/context.c @@ -255,7 +255,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, //======================================================================== // Checks whether the client API part of the window config is sane -// It blames glfwOpenWindow because that's the only caller //======================================================================== GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) @@ -263,8 +262,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) if (wndconfig->clientAPI != GLFW_OPENGL_API && wndconfig->clientAPI != GLFW_OPENGL_ES_API) { - _glfwSetError(GLFW_INVALID_ENUM, - "glfwCreateWindow: Invalid client API requested"); + _glfwSetError(GLFW_INVALID_ENUM, "Invalid client API requested"); return GL_FALSE; } @@ -281,7 +279,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) // OpenGL 3.x series ended with version 3.3 _glfwSetError(GLFW_INVALID_VALUE, - "glfwCreateWindow: Invalid OpenGL version %i.%i requested", + "Invalid OpenGL version %i.%i requested", wndconfig->glMajor, wndconfig->glMinor); return GL_FALSE; } @@ -296,7 +294,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE) { _glfwSetError(GLFW_INVALID_ENUM, - "glfwCreateWindow: Invalid OpenGL profile requested"); + "Invalid OpenGL profile requested"); return GL_FALSE; } @@ -307,7 +305,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) // and above _glfwSetError(GLFW_INVALID_VALUE, - "glfwCreateWindow: Context profiles only exist for " + "Context profiles only exist for " "OpenGL version 3.2 and above"); return GL_FALSE; } @@ -317,8 +315,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) { // Forward-compatible contexts are only defined for OpenGL version 3.0 and above _glfwSetError(GLFW_INVALID_VALUE, - "glfwCreateWindow: Forward compatibility only exist " - "for OpenGL version 3.0 and above"); + "Forward compatibility only exist for OpenGL " + "version 3.0 and above"); return GL_FALSE; } } @@ -333,7 +331,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) // OpenGL ES 2.x series ended with version 2.0 _glfwSetError(GLFW_INVALID_VALUE, - "glfwCreateWindow: Invalid OpenGL ES version %i.%i requested", + "Invalid OpenGL ES version %i.%i requested", wndconfig->glMajor, wndconfig->glMinor); return GL_FALSE; } @@ -346,8 +344,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) { // OpenGL ES does not support profiles _glfwSetError(GLFW_INVALID_VALUE, - "glfwCreateWindow: Context profiles are not supported " - "by OpenGL ES"); + "Context profiles are not supported by OpenGL ES"); return GL_FALSE; } @@ -355,8 +352,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) { // OpenGL ES does not support forward-compatibility _glfwSetError(GLFW_INVALID_VALUE, - "glfwCreateWindow: Forward compatibility is not " - "supported by OpenGL ES"); + "Forward compatibility is not supported by OpenGL ES"); return GL_FALSE; } } @@ -367,8 +363,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) wndconfig->glRobustness != GLFW_LOSE_CONTEXT_ON_RESET) { _glfwSetError(GLFW_INVALID_VALUE, - "glfwCreateWindow: Invalid OpenGL robustness mode " - "requested"); + "Invalid OpenGL robustness mode requested"); return GL_FALSE; } } @@ -379,7 +374,6 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) //======================================================================== // Reads back context properties -// It blames glfwCreateWindow because that's the only caller //======================================================================== GLboolean _glfwRefreshContextParams(void) @@ -404,7 +398,7 @@ GLboolean _glfwRefreshContextParams(void) if (!window->GetStringi) { _glfwSetError(GLFW_PLATFORM_ERROR, - "glfwCreateWindow: Entry point retrieval is broken"); + "Entry point retrieval is broken"); return GL_FALSE; } } @@ -483,7 +477,6 @@ GLboolean _glfwRefreshContextParams(void) //======================================================================== // Checks whether the current context fulfils the specified requirements -// It blames glfwCreateWindow because that's the only caller //======================================================================== GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig) @@ -501,8 +494,7 @@ GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig) // For API consistency, we emulate the behavior of the // {GLX|WGL}_ARB_create_context extension and fail here - _glfwSetError(GLFW_VERSION_UNAVAILABLE, - "glfwCreateWindow: The requested OpenGL version is not available"); + _glfwSetError(GLFW_VERSION_UNAVAILABLE, NULL); return GL_FALSE; } diff --git a/src/gamma.c b/src/gamma.c index 51e0ce14..07180886 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -55,7 +55,7 @@ GLFWAPI void glfwSetGamma(float gamma) if (gamma <= 0.f) { _glfwSetError(GLFW_INVALID_VALUE, - "glfwSetGamma: Gamma value must be greater than zero"); + "Gamma value must be greater than zero"); return; } diff --git a/src/glx_context.c b/src/glx_context.c index ac9d0662..1db55dd3 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -294,7 +294,9 @@ static int createContext(_GLFWwindow* window, if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0) { - // Request an explicitly versioned context + // NOTE: Only request an explicitly versioned context when + // necessary, as explicitly requesting version 1.0 does not always + // return the highest available version setGLXattrib(attribs, index, GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor); setGLXattrib(attribs, index, GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor); diff --git a/src/input.c b/src/input.c index 2a077502..497e7520 100644 --- a/src/input.c +++ b/src/input.c @@ -323,7 +323,7 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key) if (key < 0 || key > GLFW_KEY_LAST) { _glfwSetError(GLFW_INVALID_ENUM, - "glfwGetKey: The specified key is invalid"); + "The specified key is invalid"); return GLFW_RELEASE; } @@ -355,7 +355,7 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button) if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST) { _glfwSetError(GLFW_INVALID_ENUM, - "glfwGetMouseButton: The specified mouse button is invalid"); + "The specified mouse button is invalid"); return GLFW_RELEASE; } diff --git a/src/nsgl_context.m b/src/nsgl_context.m index ed024d6e..66518140 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -51,7 +51,7 @@ int _glfwInitOpenGL(void) if (pthread_key_create(&_glfwCurrentTLS, NULL) != 0) { _glfwSetError(GLFW_PLATFORM_ERROR, - "Cocoa/NSGL: Failed to create context TLS"); + "NSOpenGL: Failed to create context TLS"); return GL_FALSE; } diff --git a/src/window.c b/src/window.c index f9048cb8..7b47e3f1 100644 --- a/src/window.c +++ b/src/window.c @@ -265,15 +265,13 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN) { - _glfwSetError(GLFW_INVALID_ENUM, - "glfwCreateWindow: Invalid window mode"); + _glfwSetError(GLFW_INVALID_ENUM, "Invalid window mode"); return GL_FALSE; } if (width <= 0 || height <= 0) { - _glfwSetError(GLFW_INVALID_VALUE, - "glfwCreateWindow: Invalid window size"); + _glfwSetError(GLFW_INVALID_VALUE, "Invalid window size"); return GL_FALSE; }