diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index cc1f01b0..138c7c50 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -353,15 +353,13 @@ extern "C" { /* glfwGetError/glfwErrorString tokens */ #define GLFW_NO_ERROR 0 #define GLFW_NOT_INITIALIZED 0x00070001 -#define GLFW_INVALID_ENUM 0x00070002 -#define GLFW_INVALID_VALUE 0x00070003 -#define GLFW_OUT_OF_MEMORY 0x00070004 -#define GLFW_OPENGL_NOT_SUPPORTED 0x00070005 -#define GLFW_NO_PIXEL_FORMAT 0x00070006 -#define GLFW_VIDEO_MODE_FAILED 0x00070007 -#define GLFW_UNAVAILABLE_VERSION 0x00070008 -#define GLFW_NO_CURRENT_WINDOW 0x00070009 -#define GLFW_INTERNAL_ERROR 0x0007000A +#define GLFW_NO_CURRENT_WINDOW 0x00070002 +#define GLFW_INVALID_ENUM 0x00070003 +#define GLFW_INVALID_VALUE 0x00070004 +#define GLFW_OUT_OF_MEMORY 0x00070005 +#define GLFW_OPENGL_UNAVAILABLE 0x00070006 +#define GLFW_VERSION_UNAVAILABLE 0x00070007 +#define GLFW_PLATFORM_ERROR 0x00070008 /************************************************************************* diff --git a/src/cocoa/cocoa_window.m b/src/cocoa/cocoa_window.m index ecd6f4de..eeb1a13a 100644 --- a/src/cocoa/cocoa_window.m +++ b/src/cocoa/cocoa_window.m @@ -475,7 +475,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, // Fail if OpenGL 3.0 or above was requested if (wndconfig->glMajor > 2) { - _glfwSetError(GLFW_UNAVAILABLE_VERSION); + _glfwSetError(GLFW_VERSION_UNAVAILABLE); return GL_FALSE; } @@ -486,7 +486,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, _glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init]; if (_glfwLibrary.NS.delegate == nil) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } @@ -496,7 +496,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, window->NS.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window]; if (window->NS.delegate == nil) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } @@ -627,7 +627,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; if (window->NSGL.pixelFormat == nil) { - _glfwSetError(GLFW_NO_PIXEL_FORMAT); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } @@ -641,7 +641,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, shareContext:share]; if (window->NSGL.context == nil) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } diff --git a/src/error.c b/src/error.c index 5a189f2a..9eb80071 100644 --- a/src/error.c +++ b/src/error.c @@ -79,24 +79,20 @@ GLFWAPI const char* glfwErrorString(int error) return "No error"; case GLFW_NOT_INITIALIZED: return "The GLFW library is not initialized"; + case GLFW_NO_CURRENT_WINDOW: + return "There is no current GLFW window"; case GLFW_INVALID_ENUM: return "Invalid argument for enum parameter"; case GLFW_INVALID_VALUE: return "Invalid value for parameter"; case GLFW_OUT_OF_MEMORY: return "Out of memory"; - case GLFW_OPENGL_NOT_SUPPORTED: - return "OpenGL is not supported"; - case GLFW_NO_PIXEL_FORMAT: - return "No matching framebuffer pixel format could be found"; - case GLFW_VIDEO_MODE_FAILED: - return "Video mode setting failed"; - case GLFW_UNAVAILABLE_VERSION: + case GLFW_OPENGL_UNAVAILABLE: + return "OpenGL is not available on this machine"; + case GLFW_VERSION_UNAVAILABLE: return "The requested OpenGL version is unavailable"; - case GLFW_NO_CURRENT_WINDOW: - return "There is no current GLFW window"; - case GLFW_INTERNAL_ERROR: - return "Internal GLFW library error"; + case GLFW_PLATFORM_ERROR: + return "A platform-specific error occurred"; default: // TODO: Set GLFW_INVALID_ENUM here? return NULL; diff --git a/src/win32/win32_window.c b/src/win32/win32_window.c index c4bc10fb..bc74e721 100644 --- a/src/win32/win32_window.c +++ b/src/win32/win32_window.c @@ -184,7 +184,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found) if (!count) { - _glfwSetError(GLFW_NO_PIXEL_FORMAT); + _glfwSetError(GLFW_OPENGL_UNAVAILABLE); return NULL; } @@ -324,13 +324,13 @@ static GLboolean createContext(_GLFWwindow* window, if (!_glfw_DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd)) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_OPENGL_UNAVAILABLE); return GL_FALSE; } if (!_glfw_SetPixelFormat(window->WGL.DC, pixelFormat, &pfd)) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_OPENGL_UNAVAILABLE); return GL_FALSE; } @@ -380,7 +380,7 @@ static GLboolean createContext(_GLFWwindow* window, attribs); if (!window->WGL.context) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_VERSION_UNAVAILABLE); return GL_FALSE; } } @@ -389,7 +389,7 @@ static GLboolean createContext(_GLFWwindow* window, window->WGL.context = wglCreateContext(window->WGL.DC); if (!window->WGL.context) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } @@ -397,7 +397,7 @@ static GLboolean createContext(_GLFWwindow* window, { if (!wglShareLists(share, window->WGL.context)) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } } @@ -1082,7 +1082,7 @@ static ATOM registerWindowClass(void) classAtom = RegisterClass(&wc); if (!classAtom) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return 0; } @@ -1196,14 +1196,14 @@ static int createWindow(_GLFWwindow* window, if (!window->Win32.handle) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } window->WGL.DC = GetDC(window->Win32.handle); if (!window->WGL.DC) { - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } diff --git a/src/window.c b/src/window.c index 4843d242..14b0c4dc 100644 --- a/src/window.c +++ b/src/window.c @@ -564,7 +564,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, // The desired OpenGL version is greater than the actual version // This only happens if the machine lacks {GLX|WGL}_ARB_create_context glfwCloseWindow(window); - _glfwSetError(GLFW_UNAVAILABLE_VERSION); + _glfwSetError(GLFW_VERSION_UNAVAILABLE); return GL_FALSE; } @@ -574,7 +574,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, if (!window->GetStringi) { glfwCloseWindow(window); - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } } diff --git a/src/x11/x11_init.c b/src/x11/x11_init.c index 3934047d..6eab3c5f 100644 --- a/src/x11/x11_init.c +++ b/src/x11/x11_init.c @@ -71,7 +71,7 @@ static GLboolean initDisplay(void) if (!_glfwLibrary.X11.display) { fprintf(stderr, "Failed to open X display\n"); - _glfwSetError(GLFW_OPENGL_NOT_SUPPORTED); + _glfwSetError(GLFW_OPENGL_UNAVAILABLE); return GL_FALSE; } @@ -106,7 +106,7 @@ static GLboolean initDisplay(void) if (!glXQueryExtension(_glfwLibrary.X11.display, NULL, NULL)) { fprintf(stderr, "GLX not supported\n"); - _glfwSetError(GLFW_OPENGL_NOT_SUPPORTED); + _glfwSetError(GLFW_OPENGL_UNAVAILABLE); return GL_FALSE; } @@ -115,7 +115,7 @@ static GLboolean initDisplay(void) &_glfwLibrary.X11.glxMinor)) { fprintf(stderr, "Unable to query GLX version\n"); - _glfwSetError(GLFW_OPENGL_NOT_SUPPORTED); + _glfwSetError(GLFW_OPENGL_UNAVAILABLE); return GL_FALSE; } diff --git a/src/x11/x11_window.c b/src/x11/x11_window.c index ae9e84e7..5c9f7412 100644 --- a/src/x11/x11_window.c +++ b/src/x11/x11_window.c @@ -388,7 +388,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found) if (!window->GLX.has_GLX_SGIX_fbconfig) { fprintf(stderr, "GLXFBConfigs are not supported by the X server\n"); - _glfwSetError(GLFW_NO_PIXEL_FORMAT); + _glfwSetError(GLFW_OPENGL_UNAVAILABLE); return NULL; } } @@ -402,7 +402,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found) if (!count) { fprintf(stderr, "No GLXFBConfigs returned\n"); - _glfwSetError(GLFW_NO_PIXEL_FORMAT); + _glfwSetError(GLFW_OPENGL_UNAVAILABLE); return NULL; } } @@ -412,7 +412,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found) if (!count) { fprintf(stderr, "No GLXFBConfigs returned\n"); - _glfwSetError(GLFW_NO_PIXEL_FORMAT); + _glfwSetError(GLFW_OPENGL_UNAVAILABLE); return NULL; } } @@ -520,7 +520,7 @@ static int createContext(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, G if (fbconfig == NULL) { fprintf(stderr, "Unable to retrieve the selected GLXFBConfig\n"); - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } } @@ -542,7 +542,7 @@ static int createContext(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, G XFree(fbconfig); fprintf(stderr, "Unable to retrieve visual for GLXFBconfig\n"); - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } @@ -577,7 +577,7 @@ static int createContext(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, G { fprintf(stderr, "OpenGL profile requested but GLX_ARB_create_context_profile " "is unavailable\n"); - _glfwSetError(GLFW_UNAVAILABLE_VERSION); + _glfwSetError(GLFW_VERSION_UNAVAILABLE); return GL_FALSE; } @@ -634,7 +634,7 @@ static int createContext(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, G { fprintf(stderr, "Unable to create OpenGL context\n"); // TODO: Handle all the various error codes here - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } @@ -752,7 +752,7 @@ static GLboolean createWindow(_GLFWwindow* window, if (!window->X11.handle) { // TODO: Handle all the various error codes here - _glfwSetError(GLFW_INTERNAL_ERROR); + _glfwSetError(GLFW_PLATFORM_ERROR); return GL_FALSE; } }