/*
* Mesa 3-D graphics library
- * Version: 7.6
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*/
#define GLX_GLXEXT_PROTOTYPES
#include "GL/glx.h"
+#include <X11/Xmd.h>
+#include <GL/glxproto.h>
+
#include "xm_api.h"
"GLX_MESA_copy_sub_buffer " \
"GLX_MESA_pixmap_colormap " \
"GLX_MESA_release_buffers " \
+ "GLX_ARB_create_context " \
+ "GLX_ARB_create_context_profile " \
"GLX_ARB_get_proc_address " \
+ "GLX_EXT_create_context_es_profile " \
+ "GLX_EXT_create_context_es2_profile " \
"GLX_EXT_texture_from_pixmap " \
"GLX_EXT_visual_info " \
"GLX_EXT_visual_rating " \
#define DEFAULT_DIRECT GL_TRUE
+/** XXX this could be based on gallium's max texture size */
+#define PBUFFER_MAX_SIZE 16384
+
/**
* The GLXContext typedef is defined as a pointer to this structure.
if (dbFlag) {
/* Check if the MESA_BACK_BUFFER env var is set */
- char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER");
+ char *backbuffer = getenv("MESA_BACK_BUFFER");
if (backbuffer) {
if (backbuffer[0]=='p' || backbuffer[0]=='P') {
ximageFlag = GL_FALSE;
/* Comparing IDs uses less memory but sometimes fails. */
/* XXX revisit this after 3.0 is finished. */
- if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
+ if (getenv("MESA_GLX_VISUAL_HACK"))
comparePointers = GL_TRUE;
else
comparePointers = GL_FALSE;
/* Force the visual to have an alpha channel */
- if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA"))
+ if (rgbFlag && getenv("MESA_GLX_FORCE_ALPHA"))
alphaFlag = GL_TRUE;
/* First check if a matching visual is already in the list */
*/
xmvis->vishandle = vinfo;
/* Allocate more space for additional visual */
- VisualTable = (XMesaVisual *) _mesa_realloc( VisualTable,
- sizeof(XMesaVisual) * NumVisuals,
+ VisualTable = (XMesaVisual *) realloc( VisualTable,
sizeof(XMesaVisual) * (NumVisuals + 1));
/* add xmvis to the list */
VisualTable[NumVisuals] = xmvis;
default_depth_bits(void)
{
int zBits;
- const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS");
+ const char *zEnv = getenv("MESA_GLX_DEPTH_BITS");
if (zEnv)
zBits = atoi(zEnv);
else
- zBits = DEFAULT_SOFTWARE_DEPTH_BITS;
+ zBits = 24;
return zBits;
}
default_alpha_bits(void)
{
int aBits;
- const char *aEnv = _mesa_getenv("MESA_GLX_ALPHA_BITS");
+ const char *aEnv = getenv("MESA_GLX_ALPHA_BITS");
if (aEnv)
aBits = atoi(aEnv);
else
GL_TRUE, /* double */
GL_FALSE, /* stereo */
zBits,
- STENCIL_BITS,
+ 8, /* stencil bits */
accBits, /* r */
accBits, /* g */
accBits, /* b */
return vis;
}
else {
- XFree((void *) vis);
+ free((void *) vis);
return NULL;
}
}
int depth, xclass = -1;
XVisualInfo *vis;
- if (!_mesa_getenv( varname )) {
+ if (!getenv( varname )) {
return NULL;
}
- strncpy( value, _mesa_getenv(varname), 100 );
+ strncpy( value, getenv(varname), 100 );
value[99] = 0;
sscanf( value, "%s %d", type, &depth );
}
+/**
+ * Fake an error.
+ */
+static int
+generate_error(Display *dpy,
+ unsigned char error_code,
+ XID resourceid,
+ unsigned char minor_code,
+ Bool core)
+{
+ XErrorHandler handler;
+ int major_opcode;
+ int first_event;
+ int first_error;
+ XEvent event;
+
+ handler = XSetErrorHandler(NULL);
+ XSetErrorHandler(handler);
+ if (!handler) {
+ return 0;
+ }
+
+ if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_opcode, &first_event, &first_error)) {
+ major_opcode = 0;
+ first_event = 0;
+ first_error = 0;
+ }
+
+ if (!core) {
+ error_code += first_error;
+ }
+
+ memset(&event, 0, sizeof event);
+
+ event.xerror.type = X_Error;
+ event.xerror.display = dpy;
+ event.xerror.resourceid = resourceid;
+ event.xerror.serial = NextRequest(dpy) - 1;
+ event.xerror.error_code = error_code;
+ event.xerror.request_code = major_opcode;
+ event.xerror.minor_code = minor_code;
+
+ return handler(dpy, &event.xerror);
+}
+
+
/**********************************************************************/
/*** Begin Fake GLX API Functions ***/
/**********************************************************************/
const GLboolean rgbModeDefault = fbConfig;
const int *parselist;
XVisualInfo *vis;
- int min_ci = 0;
int min_red=0, min_green=0, min_blue=0;
GLboolean rgb_flag = rgbModeDefault;
GLboolean alpha_flag = GL_FALSE;
GLint accumAlphaSize = 0;
int level = 0;
int visual_type = DONT_CARE;
- int trans_type = DONT_CARE;
- int trans_value = DONT_CARE;
GLint caveat = DONT_CARE;
XMesaVisual xmvis = NULL;
int desiredVisualID = -1;
while (*parselist) {
+ if (fbConfig &&
+ parselist[1] == GLX_DONT_CARE &&
+ parselist[0] != GLX_LEVEL) {
+ /* For glXChooseFBConfig(), skip attributes whose value is
+ * GLX_DONT_CARE, unless it's GLX_LEVEL (which can legitimately be
+ * a negative value).
+ *
+ * From page 17 (23 of the pdf) of the GLX 1.4 spec:
+ * GLX DONT CARE may be specified for all attributes except GLX LEVEL.
+ */
+ parselist += 2;
+ continue;
+ }
+
switch (*parselist) {
case GLX_USE_GL:
if (fbConfig) {
break;
case GLX_BUFFER_SIZE:
parselist++;
- min_ci = *parselist++;
+ parselist++;
break;
case GLX_LEVEL:
parselist++;
break;
case GLX_TRANSPARENT_TYPE_EXT:
parselist++;
- trans_type = *parselist++;
+ parselist++;
break;
case GLX_TRANSPARENT_INDEX_VALUE_EXT:
parselist++;
- trans_value = *parselist++;
+ parselist++;
break;
case GLX_TRANSPARENT_RED_VALUE_EXT:
case GLX_TRANSPARENT_GREEN_VALUE_EXT:
* GLX_ARB_multisample
*/
case GLX_SAMPLE_BUFFERS_ARB:
- /* ms not supported */
- return NULL;
case GLX_SAMPLES_ARB:
- /* ms not supported */
- return NULL;
+ parselist++;
+ if (*parselist++ != 0) {
+ /* ms not supported */
+ return NULL;
+ }
+ break;
/*
* FBConfig attribs.
parselist++;
break;
case GLX_FBCONFIG_ID:
+ case GLX_VISUAL_ID:
if (!fbConfig)
return NULL;
parselist++;
desiredVisualID = *parselist++;
break;
case GLX_X_RENDERABLE:
+ case GLX_MAX_PBUFFER_WIDTH:
+ case GLX_MAX_PBUFFER_HEIGHT:
+ case GLX_MAX_PBUFFER_PIXELS:
if (!fbConfig)
- return NULL;
- parselist += 2;
- /* ignore */
+ return NULL; /* invalid config option */
+ parselist += 2; /* ignore the parameter */
break;
#ifdef GLX_EXT_texture_from_pixmap
/* we only support one size of stencil and accum buffers. */
if (stencil_size > 0)
- stencil_size = STENCIL_BITS;
+ stencil_size = 8;
if (accumRedSize > 0 ||
accumGreenSize > 0 ||
}
-PUBLIC GLXContext
-glXCreateContext( Display *dpy, XVisualInfo *visinfo,
- GLXContext share_list, Bool direct )
+/**
+ * Helper function used by other glXCreateContext functions.
+ */
+static GLXContext
+create_context(Display *dpy, XMesaVisual xmvis,
+ XMesaContext shareCtx, Bool direct,
+ unsigned major, unsigned minor,
+ unsigned profileMask, unsigned contextFlags)
{
- XMesaVisual xmvis;
GLXContext glxCtx;
- GLXContext shareCtx = share_list;
- if (!dpy || !visinfo)
+ if (!dpy || !xmvis)
return 0;
glxCtx = CALLOC_STRUCT(__GLXcontextRec);
XMesaGarbageCollect();
#endif
- xmvis = find_glx_visual( dpy, visinfo );
- if (!xmvis) {
- /* This visual wasn't found with glXChooseVisual() */
- xmvis = create_glx_visual( dpy, visinfo );
- if (!xmvis) {
- /* unusable visual */
- free(glxCtx);
- return NULL;
- }
- }
-
- glxCtx->xmesaContext = XMesaCreateContext(xmvis,
- shareCtx ? shareCtx->xmesaContext : NULL);
+ glxCtx->xmesaContext = XMesaCreateContext(xmvis, shareCtx, major, minor,
+ profileMask, contextFlags);
if (!glxCtx->xmesaContext) {
free(glxCtx);
return NULL;
}
+PUBLIC GLXContext
+glXCreateContext( Display *dpy, XVisualInfo *visinfo,
+ GLXContext shareCtx, Bool direct )
+{
+ XMesaVisual xmvis;
+
+ xmvis = find_glx_visual( dpy, visinfo );
+ if (!xmvis) {
+ /* This visual wasn't found with glXChooseVisual() */
+ xmvis = create_glx_visual( dpy, visinfo );
+ if (!xmvis) {
+ /* unusable visual */
+ return NULL;
+ }
+ }
+
+ return create_context(dpy, xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL,
+ direct,
+ 1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0);
+}
+
+
/* XXX these may have to be removed due to thread-safety issues. */
static GLXContext MakeCurrent_PrevContext = 0;
static GLXDrawable MakeCurrent_PrevDrawable = 0;
if (!b) {
return 0;
}
- return b->drawable;
+ return b->ws.drawable;
}
if (!b) {
return 0;
}
- return b->drawable;
+ return b->ws.drawable;
}
if (b) {
XMesaDestroyBuffer(b);
}
- else if (_mesa_getenv("MESA_DEBUG")) {
+ else if (getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
}
}
PUBLIC void
glXDestroyContext( Display *dpy, GLXContext ctx )
{
- GLXContext glxCtx = ctx;
- (void) dpy;
- MakeCurrent_PrevContext = 0;
- MakeCurrent_PrevDrawable = 0;
- MakeCurrent_PrevReadable = 0;
- MakeCurrent_PrevDrawBuffer = 0;
- MakeCurrent_PrevReadBuffer = 0;
- XMesaDestroyContext( glxCtx->xmesaContext );
- XMesaGarbageCollect();
- free(glxCtx);
+ if (ctx) {
+ GLXContext glxCtx = ctx;
+ (void) dpy;
+ MakeCurrent_PrevContext = 0;
+ MakeCurrent_PrevDrawable = 0;
+ MakeCurrent_PrevReadable = 0;
+ MakeCurrent_PrevDrawBuffer = 0;
+ MakeCurrent_PrevReadBuffer = 0;
+ XMesaDestroyContext( glxCtx->xmesaContext );
+ XMesaGarbageCollect();
+ free(glxCtx);
+ }
}
PUBLIC Bool
glXIsDirect( Display *dpy, GLXContext ctx )
{
- GLXContext glxCtx = ctx;
- (void) ctx;
- return glxCtx->isDirect;
+ return ctx ? ctx->isDirect : False;
}
if (buffer) {
XMesaSwapBuffers(buffer);
}
- else if (_mesa_getenv("MESA_DEBUG")) {
+ else if (getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n",
(int) drawable);
}
/*** GLX_MESA_copy_sub_buffer ***/
PUBLIC void
-glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
- int x, int y, int width, int height )
+glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height)
{
XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
if (buffer) {
XMesaCopySubBuffer(buffer, x, y, width, height);
}
- else if (_mesa_getenv("MESA_DEBUG")) {
+ else if (getenv("MESA_DEBUG")) {
_mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
}
}
PUBLIC int
-glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
- int attribute, int *value )
+glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config,
+ int attribute, int *value)
{
XMesaVisual v = (XMesaVisual) config;
(void) dpy;
PUBLIC GLXFBConfig *
-glXChooseFBConfig( Display *dpy, int screen,
- const int *attribList, int *nitems )
+glXChooseFBConfig(Display *dpy, int screen,
+ const int *attribList, int *nitems)
{
XMesaVisual xmvis;
+ /* register ourselves as an extension on this display */
+ register_with_display(dpy);
+
if (!attribList || !attribList[0]) {
/* return list of all configs (per GLX_SGIX_fbconfig spec) */
return glXGetFBConfigs(dpy, screen, nitems);
PUBLIC GLXWindow
-glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
- const int *attribList )
+glXCreateWindow(Display *dpy, GLXFBConfig config, Window win,
+ const int *attribList)
{
XMesaVisual xmvis = (XMesaVisual) config;
XMesaBuffer xmbuf;
/* XXX untested */
PUBLIC GLXPixmap
-glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
- const int *attribList )
+glXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap,
+ const int *attribList)
{
XMesaVisual v = (XMesaVisual) config;
XMesaBuffer b;
PUBLIC GLXPbuffer
-glXCreatePbuffer( Display *dpy, GLXFBConfig config,
- const int *attribList )
+glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribList)
{
XMesaVisual xmvis = (XMesaVisual) config;
XMesaBuffer xmbuf;
if (width == 0 || height == 0)
return 0;
- if (width > MAX_WIDTH || height > MAX_HEIGHT) {
+ if (width > PBUFFER_MAX_SIZE || height > PBUFFER_MAX_SIZE) {
/* If allocation would have failed and GLX_LARGEST_PBUFFER is set,
* allocate the largest possible buffer.
*/
if (useLargest) {
- width = MAX_WIDTH;
- height = MAX_HEIGHT;
+ width = PBUFFER_MAX_SIZE;
+ height = PBUFFER_MAX_SIZE;
}
}
if (xmbuf) {
xmbuf->largestPbuffer = useLargest;
xmbuf->preservedContents = preserveContents;
- return (GLXPbuffer) xmbuf->drawable;
+ return (GLXPbuffer) xmbuf->ws.drawable;
}
else {
return 0;
PUBLIC void
-glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
- unsigned int *value )
+glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute,
+ unsigned int *value)
{
GLuint width, height;
XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw);
- if (!xmbuf)
+ if (!xmbuf) {
+ generate_error(dpy, GLXBadDrawable, draw, X_GLXGetDrawableAttributes, False);
return;
+ }
/* make sure buffer's dimensions are up to date */
xmesa_get_window_size(dpy, xmbuf, &width, &height);
#endif
default:
- return; /* raise BadValue error */
+ generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, true);
+ return;
}
}
PUBLIC GLXContext
glXCreateNewContext( Display *dpy, GLXFBConfig config,
- int renderType, GLXContext shareList, Bool direct )
+ int renderType, GLXContext shareCtx, Bool direct )
{
- GLXContext glxCtx;
- GLXContext shareCtx = shareList;
XMesaVisual xmvis = (XMesaVisual) config;
if (!dpy || !config ||
(renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
return 0;
- glxCtx = CALLOC_STRUCT(__GLXcontextRec);
- if (!glxCtx)
- return 0;
-
- /* deallocate unused windows/buffers */
- XMesaGarbageCollect();
-
- glxCtx->xmesaContext = XMesaCreateContext(xmvis,
- shareCtx ? shareCtx->xmesaContext : NULL);
- if (!glxCtx->xmesaContext) {
- free(glxCtx);
- return NULL;
- }
-
- glxCtx->isDirect = DEFAULT_DIRECT;
- glxCtx->currentDpy = dpy;
- glxCtx->xid = (XID) glxCtx; /* self pointer */
-
- return glxCtx;
+ return create_context(dpy, xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL,
+ direct,
+ 1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0);
}
PUBLIC void
-glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
- unsigned long *mask )
+glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
{
XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
if (xmbuf)
/*** GLX_SGI_make_current_read ***/
PUBLIC Bool
-glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read,
+ GLXContext ctx)
{
return glXMakeContextCurrent( dpy, draw, read, ctx );
}
#if defined(_VL_H)
PUBLIC GLXVideoSourceSGIX
-glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
+glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server,
+ VLPath path, int nodeClass, VLNode drainNode)
{
(void) dpy;
(void) screen;
}
PUBLIC int
-glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
+glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute,
+ int *value)
{
(void) dpy;
(void) context;
/*** GLX_SGIX_fbconfig ***/
PUBLIC int
-glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
+glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config,
+ int attribute, int *value)
{
return glXGetFBConfigAttrib(dpy, config, attribute, value);
}
PUBLIC GLXFBConfigSGIX *
-glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
+glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list,
+ int *nelements)
{
- return (GLXFBConfig *) glXChooseFBConfig(dpy, screen, attrib_list, nelements);
+ return (GLXFBConfig *) glXChooseFBConfig(dpy, screen,
+ attrib_list, nelements);
}
PUBLIC GLXPixmap
-glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
+glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config,
+ Pixmap pixmap)
{
XMesaVisual xmvis = (XMesaVisual) config;
XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0);
- return xmbuf->drawable; /* need to return an X ID */
+ return xmbuf->ws.drawable; /* need to return an X ID */
}
PUBLIC GLXContext
-glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
+glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config,
+ int renderType, GLXContext shareCtx,
+ Bool direct)
{
XMesaVisual xmvis = (XMesaVisual) config;
- GLXContext glxCtx;
- GLXContext shareCtx = share_list;
- glxCtx = CALLOC_STRUCT(__GLXcontextRec);
- if (!glxCtx)
+ if (!dpy || !config ||
+ (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
return 0;
- /* deallocate unused windows/buffers */
- XMesaGarbageCollect();
-
- glxCtx->xmesaContext = XMesaCreateContext(xmvis,
- shareCtx ? shareCtx->xmesaContext : NULL);
- if (!glxCtx->xmesaContext) {
- free(glxCtx);
- return NULL;
- }
-
- glxCtx->isDirect = DEFAULT_DIRECT;
- glxCtx->currentDpy = dpy;
- glxCtx->xid = (XID) glxCtx; /* self pointer */
-
- return glxCtx;
+ return create_context(dpy, xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL,
+ direct,
+ 1, 0, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, 0x0);
}
PUBLIC GLXPbufferSGIX
glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
- unsigned int width, unsigned int height,
- int *attribList)
+ unsigned int width, unsigned int height,
+ int *attribList)
{
XMesaVisual xmvis = (XMesaVisual) config;
XMesaBuffer xmbuf;
/* A GLXPbuffer handle must be an X Drawable because that's what
* glXMakeCurrent takes.
*/
- return (GLXPbuffer) xmbuf->drawable;
+ return (GLXPbuffer) xmbuf->ws.drawable;
}
PUBLIC int
-glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
+glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute,
+ unsigned int *value)
{
const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
PUBLIC void
-glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable,
+ unsigned long *mask)
{
XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
if (xmbuf) {
/*** GLX_SGIX_video_resize ***/
PUBLIC int
-glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
+glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel,
+ Window window)
{
(void) dpy;
(void) screen;
}
PUBLIC int
-glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
+glXChannelRectSGIX(Display *dpy, int screen, int channel,
+ int x, int y, int w, int h)
{
(void) dpy;
(void) screen;
}
PUBLIC int
-glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
+glXQueryChannelRectSGIX(Display *dpy, int screen, int channel,
+ int *x, int *y, int *w, int *h)
{
(void) dpy;
(void) screen;
}
PUBLIC int
-glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
+glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel,
+ int *dx, int *dy, int *dw, int *dh)
{
(void) dpy;
(void) screen;
#if defined(_DM_BUFFER_H_)
PUBLIC Bool
-glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
+glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer,
+ DMparams *params, DMbuffer dmbuffer)
{
(void) dpy;
(void) pbuffer;
/*** GLX_SUN_get_transparent_index ***/
PUBLIC Status
-glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
+glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay,
+ long *pTransparent)
{
(void) dpy;
(void) overlay;
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);
+ GLXContext ctx;
+
+ /* parse attrib_list */
+ for (i = 0; !done && attrib_list && 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 */
+ generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, True);
+ return NULL;
+ }
+ }
+
+ /* check contextFlags */
+ if (contextFlags & ~contextFlagsAll) {
+ generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, True);
+ return NULL;
+ }
+
+ /* check profileMask */
+ if (profileMask != GLX_CONTEXT_CORE_PROFILE_BIT_ARB &&
+ profileMask != GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB &&
+ profileMask != GLX_CONTEXT_ES_PROFILE_BIT_EXT) {
+ generate_error(dpy, GLXBadProfileARB, 0, X_GLXCreateContextAtrribsARB, False);
+ return NULL;
+ }
+
+ /* check renderType */
+ if (renderType != GLX_RGBA_TYPE &&
+ renderType != GLX_COLOR_INDEX_TYPE) {
+ generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, True);
+ return NULL;
+ }
+
+ /* check version */
+ if (majorVersion <= 0 ||
+ minorVersion < 0 ||
+ (profileMask != GLX_CONTEXT_ES_PROFILE_BIT_EXT &&
+ ((majorVersion == 1 && minorVersion > 5) ||
+ (majorVersion == 2 && minorVersion > 1) ||
+ (majorVersion == 3 && minorVersion > 3) ||
+ (majorVersion == 4 && minorVersion > 5) ||
+ majorVersion > 4))) {
+ generate_error(dpy, BadMatch, 0, X_GLXCreateContextAtrribsARB, True);
+ return NULL;
+ }
+ if (profileMask == GLX_CONTEXT_ES_PROFILE_BIT_EXT &&
+ ((majorVersion == 1 && minorVersion > 1) ||
+ (majorVersion == 2 && minorVersion > 0) ||
+ (majorVersion == 3 && minorVersion > 1) ||
+ majorVersion > 3)) {
+ /* GLX_EXT_create_context_es2_profile says nothing to justifying a
+ * different error code for invalid ES versions, but this is what NVIDIA
+ * does and piglit expects.
+ */
+ generate_error(dpy, GLXBadProfileARB, 0, X_GLXCreateContextAtrribsARB, False);
+ return NULL;
+ }
+
+ if ((contextFlags & GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) &&
+ majorVersion < 3) {
+ generate_error(dpy, BadMatch, 0, X_GLXCreateContextAtrribsARB, True);
+ return NULL;
+ }
+
+ if (renderType == GLX_COLOR_INDEX_TYPE && majorVersion >= 3) {
+ generate_error(dpy, BadMatch, 0, X_GLXCreateContextAtrribsARB, True);
+ return NULL;
+ }
+
+ ctx = create_context(dpy, xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL,
+ direct,
+ majorVersion, minorVersion,
+ profileMask, contextFlags);
+ if (!ctx) {
+ generate_error(dpy, GLXBadFBConfig, 0, X_GLXCreateContextAtrribsARB, False);
+ }
+
+ return ctx;
+}