Rough line-wrapping pass.

This commit is contained in:
Camilla Berglund 2011-07-27 17:48:56 +02:00
parent 4afc67c1df
commit e4027f14d0
7 changed files with 61 additions and 26 deletions

View File

@ -138,7 +138,8 @@ GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode)
if (mode == NULL) if (mode == NULL)
{ {
_glfwSetError(GLFW_INVALID_VALUE, "glfwGetDesktopMode: Parameter 'mode' cannot be NULL"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwGetDesktopMode: Parameter 'mode' cannot be NULL");
return; return;
} }

View File

@ -53,7 +53,8 @@ GLFWAPI int glfwGetKey(GLFWwindow handle, int key)
if (key < 0 || key > GLFW_KEY_LAST) if (key < 0 || key > GLFW_KEY_LAST)
{ {
// TODO: Decide whether key is a value or enum // TODO: Decide whether key is a value or enum
_glfwSetError(GLFW_INVALID_VALUE, "glfwGetKey: The specified key is invalid"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwGetKey: The specified key is invalid");
return GLFW_RELEASE; return GLFW_RELEASE;
} }
@ -85,7 +86,8 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow handle, int button)
// Is it a valid mouse button? // Is it a valid mouse button?
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST) if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
{ {
_glfwSetError(GLFW_INVALID_ENUM, "glfwGetMouseButton: The specified mouse button is invalid"); _glfwSetError(GLFW_INVALID_ENUM,
"glfwGetMouseButton: The specified mouse button is invalid");
return GLFW_RELEASE; return GLFW_RELEASE;
} }

View File

@ -255,25 +255,29 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0) if (wndconfig->glMajor < 1 || wndconfig->glMinor < 0)
{ {
// OpenGL 1.0 is the smallest valid version // OpenGL 1.0 is the smallest valid version
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL version requested");
return GL_FALSE; return GL_FALSE;
} }
if (wndconfig->glMajor == 1 && wndconfig->glMinor > 5) if (wndconfig->glMajor == 1 && wndconfig->glMinor > 5)
{ {
// OpenGL 1.x series ended with version 1.5 // OpenGL 1.x series ended with version 1.5
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL version requested");
return GL_FALSE; return GL_FALSE;
} }
else if (wndconfig->glMajor == 2 && wndconfig->glMinor > 1) else if (wndconfig->glMajor == 2 && wndconfig->glMinor > 1)
{ {
// OpenGL 2.x series ended with version 2.1 // OpenGL 2.x series ended with version 2.1
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL version requested");
return GL_FALSE; return GL_FALSE;
} }
else if (wndconfig->glMajor == 3 && wndconfig->glMinor > 3) else if (wndconfig->glMajor == 3 && wndconfig->glMinor > 3)
{ {
// OpenGL 3.x series ended with version 3.3 // OpenGL 3.x series ended with version 3.3
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL version requested");
return GL_FALSE; return GL_FALSE;
} }
else else
@ -290,7 +294,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
// compatibility with future updates to OpenGL ES, we allow // compatibility with future updates to OpenGL ES, we allow
// everything 2.x and let the driver report invalid 2.x versions // everything 2.x and let the driver report invalid 2.x versions
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL ES 2.x version requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL ES 2.x version requested");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -299,16 +304,20 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE && if (wndconfig->glProfile != GLFW_OPENGL_CORE_PROFILE &&
wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE) wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
{ {
_glfwSetError(GLFW_INVALID_ENUM, "glfwOpenWindow: Invalid OpenGL profile requested"); _glfwSetError(GLFW_INVALID_ENUM,
"glfwOpenWindow: Invalid OpenGL profile requested");
return GL_FALSE; return GL_FALSE;
} }
if (wndconfig->glMajor < 3 || (wndconfig->glMajor == 3 && wndconfig->glMinor < 2)) if (wndconfig->glMajor < 3 ||
(wndconfig->glMajor == 3 && wndconfig->glMinor < 2))
{ {
// Desktop OpenGL context profiles are only defined for version 3.2 // Desktop OpenGL context profiles are only defined for version 3.2
// and above // and above
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Context profiles only exist for OpenGL version 3.2 and above"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Context profiles only exist for "
"OpenGL version 3.2 and above");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -316,7 +325,9 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glForward && wndconfig->glMajor < 3) if (wndconfig->glForward && wndconfig->glMajor < 3)
{ {
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above // Forward-compatible contexts are only defined for OpenGL version 3.0 and above
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Forward compatibility only exist for OpenGL version 3.0 and above"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Forward compatibility only exist for "
"OpenGL version 3.0 and above");
return GL_FALSE; return GL_FALSE;
} }
@ -325,7 +336,8 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
if (wndconfig->glRobustness != GLFW_OPENGL_NO_RESET_NOTIFICATION && if (wndconfig->glRobustness != GLFW_OPENGL_NO_RESET_NOTIFICATION &&
wndconfig->glRobustness != GLFW_OPENGL_LOSE_CONTEXT_ON_RESET) wndconfig->glRobustness != GLFW_OPENGL_LOSE_CONTEXT_ON_RESET)
{ {
_glfwSetError(GLFW_INVALID_VALUE, "glfwOpenWindow: Invalid OpenGL robustness mode requested"); _glfwSetError(GLFW_INVALID_VALUE,
"glfwOpenWindow: Invalid OpenGL robustness mode requested");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -358,7 +370,8 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
// 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
_glfwSetError(GLFW_VERSION_UNAVAILABLE, "glfwOpenWindow: The requested OpenGL version is not available"); _glfwSetError(GLFW_VERSION_UNAVAILABLE,
"glfwOpenWindow: The requested OpenGL version is not available");
return GL_FALSE; return GL_FALSE;
} }
@ -375,7 +388,9 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig)
// on X11/GLX using custom build systems, as it needs explicit // on X11/GLX using custom build systems, as it needs explicit
// configuration in order to work // configuration in order to work
_glfwSetError(GLFW_PLATFORM_ERROR, "glfwOpenWindow: Entry point retrieval is broken; see the build documentation for your platform"); _glfwSetError(GLFW_PLATFORM_ERROR,
"glfwOpenWindow: Entry point retrieval is broken; see "
"the build documentation for your platform");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -614,7 +629,8 @@ GLFWAPI void glfwCopyContext(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mas
if (_glfwLibrary.currentWindow == dst) if (_glfwLibrary.currentWindow == dst)
{ {
_glfwSetError(GLFW_INVALID_VALUE, "Cannot copy OpenGL state to a current context"); _glfwSetError(GLFW_INVALID_VALUE,
"Cannot copy OpenGL state to a current context");
return; return;
} }

View File

@ -265,6 +265,9 @@ void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
// Return desktop mode parameters // Return desktop mode parameters
mode->width = dm.dmPelsWidth; mode->width = dm.dmPelsWidth;
mode->height = dm.dmPelsHeight; mode->height = dm.dmPelsHeight;
_glfwSplitBPP(dm.dmBitsPerPel, &mode->redBits, &mode->greenBits, &mode->blueBits); _glfwSplitBPP(dm.dmBitsPerPel,
&mode->redBits,
&mode->greenBits,
&mode->blueBits);
} }

View File

@ -124,6 +124,9 @@ void* _glfwPlatformGetProcAddress(const char* procname)
void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask) void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{ {
if (!wglCopyContext(src->WGL.context, dst->WGL.context, mask)) if (!wglCopyContext(src->WGL.context, dst->WGL.context, mask))
_glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to copy OpenGL context attributes"); {
_glfwSetError(GLFW_PLATFORM_ERROR,
"Win32/WGL: Failed to copy OpenGL context attributes");
}
} }

View File

@ -289,7 +289,8 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN) if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN)
{ {
_glfwSetError(GLFW_INVALID_ENUM, "glfwOpenWindow: Invalid enum for 'mode' parameter"); _glfwSetError(GLFW_INVALID_ENUM,
"glfwOpenWindow: Invalid enum for 'mode' parameter");
return GL_FALSE; return GL_FALSE;
} }
@ -314,7 +315,8 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
window = (_GLFWwindow*) _glfwMalloc(sizeof(_GLFWwindow)); window = (_GLFWwindow*) _glfwMalloc(sizeof(_GLFWwindow));
if (!window) if (!window)
{ {
_glfwSetError(GLFW_OUT_OF_MEMORY, "glfwOpenWindow: Failed to allocate window structure"); _glfwSetError(GLFW_OUT_OF_MEMORY,
"glfwOpenWindow: Failed to allocate window structure");
return NULL; return NULL;
} }
@ -750,7 +752,9 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
case GLFW_OPENGL_ROBUSTNESS: case GLFW_OPENGL_ROBUSTNESS:
return window->glRobustness; return window->glRobustness;
default: default:
_glfwSetError(GLFW_INVALID_ENUM, "glfwGetWindowParam: Invalid enum value for 'param' parameter"); _glfwSetError(GLFW_INVALID_ENUM,
"glfwGetWindowParam: Invalid enum value for 'param' "
"parameter");
return 0; return 0;
} }
} }

View File

@ -401,7 +401,8 @@ static GLboolean initDisplay(void)
&_glfwLibrary.X11.RandR.majorVersion, &_glfwLibrary.X11.RandR.majorVersion,
&_glfwLibrary.X11.RandR.minorVersion)) &_glfwLibrary.X11.RandR.minorVersion))
{ {
_glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to query RandR version"); _glfwSetError(GLFW_PLATFORM_ERROR,
"X11/GLX: Failed to query RandR version");
return GL_FALSE; return GL_FALSE;
} }
} }
@ -420,7 +421,8 @@ static GLboolean initDisplay(void)
&_glfwLibrary.X11.glxMajor, &_glfwLibrary.X11.glxMajor,
&_glfwLibrary.X11.glxMinor)) &_glfwLibrary.X11.glxMinor))
{ {
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: Failed to query GLX version"); _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"X11/GLX: Failed to query GLX version");
return GL_FALSE; return GL_FALSE;
} }
@ -475,7 +477,8 @@ static void initGammaRamp(void)
// This is probably Nvidia RandR with broken gamma support // This is probably Nvidia RandR with broken gamma support
// Flag it as useless and try Xf86VidMode below, if available // Flag it as useless and try Xf86VidMode below, if available
_glfwLibrary.X11.RandR.gammaBroken = GL_TRUE; _glfwLibrary.X11.RandR.gammaBroken = GL_TRUE;
fprintf(stderr, "Ignoring broken nVidia implementation of RandR 1.2+ gamma\n"); fprintf(stderr,
"Ignoring broken nVidia implementation of RandR 1.2+ gamma\n");
} }
XRRFreeScreenResources(rr); XRRFreeScreenResources(rr);
@ -515,14 +518,17 @@ static Cursor createNULLCursor(void)
// TODO: Add error checks // TODO: Add error checks
cursormask = XCreatePixmap(_glfwLibrary.X11.display, _glfwLibrary.X11.root, 1, 1, 1); cursormask = XCreatePixmap(_glfwLibrary.X11.display,
_glfwLibrary.X11.root,
1, 1, 1);
xgc.function = GXclear; xgc.function = GXclear;
gc = XCreateGC(_glfwLibrary.X11.display, cursormask, GCFunction, &xgc); gc = XCreateGC(_glfwLibrary.X11.display, cursormask, GCFunction, &xgc);
XFillRectangle(_glfwLibrary.X11.display, cursormask, gc, 0, 0, 1, 1); XFillRectangle(_glfwLibrary.X11.display, cursormask, gc, 0, 0, 1, 1);
col.pixel = 0; col.pixel = 0;
col.red = 0; col.red = 0;
col.flags = 4; col.flags = 4;
cursor = XCreatePixmapCursor(_glfwLibrary.X11.display, cursormask, cursormask, cursor = XCreatePixmapCursor(_glfwLibrary.X11.display,
cursormask, cursormask,
&col, &col, 0, 0); &col, &col, 0, 0);
XFreePixmap(_glfwLibrary.X11.display, cursormask); XFreePixmap(_glfwLibrary.X11.display, cursormask);
XFreeGC(_glfwLibrary.X11.display, gc); XFreeGC(_glfwLibrary.X11.display, gc);