diff options
author | Brian Paul <brianp@vmware.com> | 2011-05-19 19:27:51 -0600 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2011-05-19 21:18:33 -0600 |
commit | d1cd1cc871b79cce52ccd033c53fa57e410c9a6a (patch) | |
tree | 105731a1b6a7c0fe93b772048eb774aaf23d0ee5 | |
parent | 81183b1e3e6a23987817c4b29ab15bc37eae9711 (diff) |
st/glx: implement glXCreateContextAttribsARB()
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/glx_api.c | 95 |
1 files changed, 95 insertions, 0 deletions
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); +} |