if (b)
XMesaReleaseTexImage(dpy, b, buffer);
}
+
+
+
+/*** GLX_ARB_create_context ***/
+
+GLXContext
+glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
+ GLXContext shareCtx, Bool direct,
+ const int *attrib_list)
+{
+ XMesaVisual xmvis = (XMesaVisual) config;
+ int majorVersion = 1, minorVersion = 0;
+ int contextFlags = 0x0;
+ int profileMask = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
+ int renderType = GLX_RGBA_TYPE;
+ unsigned i;
+ Bool done = False;
+ const int contextFlagsAll = (GLX_CONTEXT_DEBUG_BIT_ARB |
+ GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB);
+
+ /* parse attrib_list */
+ for (i = 0; !done && attrib_list[i]; i++) {
+ switch (attrib_list[i]) {
+ case GLX_CONTEXT_MAJOR_VERSION_ARB:
+ majorVersion = attrib_list[++i];
+ break;
+ case GLX_CONTEXT_MINOR_VERSION_ARB:
+ minorVersion = attrib_list[++i];
+ break;
+ case GLX_CONTEXT_FLAGS_ARB:
+ contextFlags = attrib_list[++i];
+ break;
+ case GLX_CONTEXT_PROFILE_MASK_ARB:
+ profileMask = attrib_list[++i];
+ break;
+ case GLX_RENDER_TYPE:
+ renderType = attrib_list[++i];
+ break;
+ case 0:
+ /* end of list */
+ done = True;
+ break;
+ default:
+ /* bad attribute */
+ /* XXX generate BadValue X Error */
+ return NULL;
+ }
+ }
+
+ /* check contextFlags */
+ if (contextFlags & ~contextFlagsAll) {
+ return NULL; /* generate BadValue X Error */
+ }
+
+ /* check profileMask */
+ if (profileMask != GLX_CONTEXT_CORE_PROFILE_BIT_ARB &&
+ profileMask != GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) {
+ return NULL; /* generate BadValue X Error */
+ }
+
+ /* check version (generate BadMatch if bad) */
+ switch (majorVersion) {
+ case 1:
+ if (minorVersion < 0 || minorVersion > 5)
+ return NULL;
+ break;
+ case 2:
+ if (minorVersion < 0 || minorVersion > 1)
+ return NULL;
+ break;
+ case 3:
+ if (minorVersion < 0 || minorVersion > 2)
+ return NULL;
+ break;
+ case 4:
+ if (minorVersion < 0 || minorVersion > 0)
+ return NULL;
+ break;
+ default:
+ return NULL;
+ }
+
+ if ((contextFlags & GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) &&
+ majorVersion < 3)
+ return NULL; /* generate GLXBadProfileARB */
+
+ if (renderType == GLX_COLOR_INDEX_TYPE && majorVersion >= 3)
+ return NULL; /* generate BadMatch */
+
+ return create_context(dpy, xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL,
+ direct,
+ majorVersion, minorVersion,
+ profileMask, contextFlags);
+}