Added basic error reporting to X11 port.

This commit is contained in:
Camilla Berglund 2010-09-09 21:52:31 +02:00
parent 922cd1011a
commit fa5d7488b8
4 changed files with 38 additions and 3 deletions

View File

@ -372,7 +372,10 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
// Get list of visuals
vislist = XGetVisualInfo(dpy, 0, &dummy, &viscount);
if (vislist == NULL)
{
// TODO: Figure out which error this is
return 0;
}
rgbarray = (int*) malloc(sizeof(int) * viscount);
rgbcount = 0;

View File

@ -79,13 +79,14 @@ static void glfw_atexit(void)
// Initialize X11 display
//========================================================================
static int initDisplay(void)
static GLboolean initDisplay(void)
{
// Open display
_glfwLibrary.X11.display = XOpenDisplay(0);
if (!_glfwLibrary.X11.display)
{
fprintf(stderr, "Failed to open X display\n");
_glfwSetError(GLFW_OPENGL_NOT_SUPPORTED);
return GL_FALSE;
}
@ -114,6 +115,7 @@ static int initDisplay(void)
if (!glXQueryExtension(_glfwLibrary.X11.display, NULL, NULL))
{
fprintf(stderr, "GLX not supported\n");
_glfwSetError(GLFW_OPENGL_NOT_SUPPORTED);
return GL_FALSE;
}
@ -123,6 +125,7 @@ static int initDisplay(void)
&_glfwLibrary.X11.glxMinor))
{
fprintf(stderr, "Unable to query GLX version\n");
_glfwSetError(GLFW_OPENGL_NOT_SUPPORTED);
return GL_FALSE;
}

View File

@ -266,7 +266,10 @@ static void pollJoystickEvents(void)
int _glfwPlatformGetJoystickParam(int joy, int param)
{
if (!_glfwJoy[joy].Present)
{
// TODO: Figure out if this is an error
return 0;
}
switch (param)
{
@ -296,7 +299,10 @@ int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes)
int i;
if (!_glfwJoy[joy].Present)
{
// TODO: Figure out if this is an error
return 0;
}
// Update joystick state
pollJoystickEvents();
@ -323,7 +329,10 @@ int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons,
int i;
if (!_glfwJoy[joy].Present)
{
// TODO: Figure out if this is an error
return 0;
}
// Update joystick state
pollJoystickEvents();

View File

@ -365,6 +365,8 @@ static Cursor createNULLCursor(Display* display, Window root)
XColor col;
Cursor cursor;
// TODO: Add error checks
cursormask = XCreatePixmap(display, root, 1, 1, 1);
xgc.function = GXclear;
gc = XCreateGC(display, cursormask, GCFunction, &xgc);
@ -419,6 +421,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);
return NULL;
}
}
@ -432,6 +435,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
if (!count)
{
fprintf(stderr, "No GLXFBConfigs returned\n");
_glfwSetError(GLFW_NO_PIXEL_FORMAT);
return NULL;
}
}
@ -441,6 +445,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
if (!count)
{
fprintf(stderr, "No GLXFBConfigs returned\n");
_glfwSetError(GLFW_NO_PIXEL_FORMAT);
return NULL;
}
}
@ -448,7 +453,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count);
if (!result)
{
fprintf(stderr, "Out of memory\n");
_glfwSetError(GLFW_OUT_OF_MEMORY);
return NULL;
}
@ -544,6 +549,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);
return GL_FALSE;
}
}
@ -565,6 +571,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);
return GL_FALSE;
}
@ -599,6 +606,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);
return GL_FALSE;
}
@ -643,6 +651,8 @@ static int createContext(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, G
if (window->GLX.context == NULL)
{
fprintf(stderr, "Unable to create OpenGL context\n");
// TODO: Handle all the various error codes here
_glfwSetError(GLFW_INTERNAL_ERROR);
return GL_FALSE;
}
@ -759,7 +769,11 @@ static GLboolean createWindow(_GLFWwindow* window,
);
if (!window->X11.window)
{
// TODO: Handle all the various error codes here
_glfwSetError(GLFW_INTERNAL_ERROR);
return GL_FALSE;
}
}
// Check whether an EWMH-compliant window manager is running
@ -817,7 +831,10 @@ static GLboolean createWindow(_GLFWwindow* window,
{
XWMHints* hints = XAllocWMHints();
if (!hints)
{
_glfwSetError(GLFW_OUT_OF_MEMORY);
return GL_FALSE;
}
hints->flags = StateHint;
hints->initial_state = NormalState;
@ -830,7 +847,10 @@ static GLboolean createWindow(_GLFWwindow* window,
{
XSizeHints* hints = XAllocSizeHints();
if (!hints)
{
_glfwSetError(GLFW_OUT_OF_MEMORY);
return GL_FALSE;
}
hints->flags = 0;
@ -1610,7 +1630,7 @@ void _glfwPlatformRefreshWindowParams(void)
if (fbconfig == NULL)
{
// This should never ever happen
// TODO: Figure out what to do when this happens
// TODO: Flag this as an error and propagate up
fprintf(stderr, "Cannot find known GLXFBConfig by ID. "
"This cannot happen. Have a nice day.\n");
abort();