From d1cd1cc871b79cce52ccd033c53fa57e410c9a6a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 19 May 2011 19:27:51 -0600 Subject: st/glx: implement glXCreateContextAttribsARB() --- src/gallium/state_trackers/glx/xlib/glx_api.c | 95 +++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index eae93918ac..2bab020652 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -2638,3 +2638,98 @@ glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer) 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); +} -- cgit v1.2.3