| 3039 | } |
| 3040 | |
| 3041 | int extensionQueryTest(void) |
| 3042 | { |
| 3043 | Display *dpy = NULL; int retval = 1; |
| 3044 | int majorOpcode = -1, eventBase = -1, errorBase = -1, n; |
| 3045 | XErrorHandler prevHandler; |
| 3046 | XVisualInfo *vis = NULL; |
| 3047 | GLXContext ctx = 0; |
| 3048 | Pixmap pm = 0; |
| 3049 | GLXPixmap glxpm = 0; |
| 3050 | |
| 3051 | printf("Extension query and error handling test:\n\n"); |
| 3052 | |
| 3053 | try |
| 3054 | { |
| 3055 | int major = -1, minor = -1, dummy1; |
| 3056 | unsigned int dummy2; |
| 3057 | unsigned long dummy3; |
| 3058 | GLXFBConfig *configs = NULL; |
| 3059 | |
| 3060 | if((dpy = XkbOpenDisplay(0, &dummy1, &dummy1, NULL, NULL, |
| 3061 | &dummy1)) == NULL) |
| 3062 | THROW("Could not open display"); |
| 3063 | |
| 3064 | if(!XQueryExtension(dpy, "GLX", &majorOpcode, &eventBase, &errorBase) |
| 3065 | || majorOpcode <= 0 || eventBase <= 0 || errorBase <= 0) |
| 3066 | THROW("GLX Extension not reported as present"); |
| 3067 | #ifdef FAKEXCB |
| 3068 | xcb_connection_t *conn = XGetXCBConnection(dpy); |
| 3069 | if(!conn) THROW("Could not get XCB connection for display"); |
| 3070 | const xcb_query_extension_reply_t *qeReply = |
| 3071 | xcb_get_extension_data(conn, &xcb_glx_id); |
| 3072 | if(!qeReply || qeReply->major_opcode <= 0 || qeReply->first_event <= 0 |
| 3073 | || qeReply->first_error <= 0) |
| 3074 | THROW("GLX extension not reported as present in XCB"); |
| 3075 | xcb_glx_query_version_cookie_t cookie = xcb_glx_query_version(conn, 1, 4); |
| 3076 | xcb_generic_error_t *error; |
| 3077 | xcb_glx_query_version_reply_t *qvReply = |
| 3078 | xcb_glx_query_version_reply(conn, cookie, &error); |
| 3079 | if(!qvReply) THROW("Could not get GLX version in XCB"); |
| 3080 | if(qvReply->major_version != 1 || qvReply->minor_version != 4) |
| 3081 | { |
| 3082 | free(qvReply); |
| 3083 | THROW("Incorrect GLX version returned in XCB"); |
| 3084 | } |
| 3085 | free(qvReply); |
| 3086 | #endif |
| 3087 | // For some reason, the GLX error string table isn't initialized until a |
| 3088 | // substantial GLX command completes. |
| 3089 | if((configs = glXGetFBConfigs(dpy, DefaultScreen(dpy), &dummy1)) != NULL) |
| 3090 | XFree(configs); |
| 3091 | XERRTEST_START(); |
| 3092 | glXQueryDrawable(dpy, 0, GLX_WIDTH, &dummy2); |
| 3093 | GLXERRTEST_STOP(errorBase + GLXBadDrawable, -1); |
| 3094 | |
| 3095 | int errorBase2 = -1, eventBase2 = -1; |
| 3096 | if(!glXQueryExtension(dpy, &errorBase2, &eventBase2) || errorBase2 <= 0 |
| 3097 | || eventBase2 <= 0 || !glXQueryExtension(dpy, NULL, NULL)) |
| 3098 | THROW("GLX Extension not reported as present"); |
no test coverage detected