Commit 18645b89 authored by idr's avatar idr
Browse files

Add support for glXQueryContext (part of GLX 1.3).

parent d39737e5
......@@ -67,7 +67,7 @@
#endif
#define GLX_MAJOR_VERSION 1 /* current version numbers */
#define GLX_MINOR_VERSION 2
#define GLX_MINOR_VERSION 4
#define __GLX_MAX_TEXTURE_UNITS 32
......@@ -529,6 +529,11 @@ struct __GLXcontextRec {
* drivers should NEVER use this data or even care that it exists.
*/
void * client_state_private;
/**
* Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
*/
int renderType;
};
#define __glXSetError(gc,code) \
......
......@@ -1694,12 +1694,15 @@ GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
* \returns \c Success on success. \c GLX_BAD_CONTEXT if \c ctx is invalid,
* or zero if the request failed due to internal problems (i.e.,
* unable to allocate temporary memory, etc.)
*
* \note
* This function dynamically determines whether to use the EXT_import_context
* version of the protocol or the GLX 1.3 version of the protocol.
*/
static int __glXQueryContextInfo(Display *dpy, GLXContext ctx)
{
xGLXVendorPrivateReq *vpreq;
xGLXQueryContextInfoEXTReq *req;
xGLXQueryContextInfoEXTReply reply;
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
xGLXQueryContextReply reply;
CARD8 opcode;
GLuint numValues;
int retval;
......@@ -1714,13 +1717,28 @@ static int __glXQueryContextInfo(Display *dpy, GLXContext ctx)
/* Send the glXQueryContextInfoEXT request */
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate,
sz_xGLXQueryContextInfoEXTReq-sz_xGLXVendorPrivateReq,vpreq);
req = (xGLXQueryContextInfoEXTReq *)vpreq;
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_QueryContextInfoEXT;
req->context = (unsigned int)(ctx->xid);
if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
xGLXQueryContextReq * req;
req->reqType = opcode;
req->glxCode = X_GLXQueryContext;
req->context = (unsigned int)(ctx->xid);
}
else {
xGLXVendorPrivateReq *vpreq;
xGLXQueryContextInfoEXTReq *req;
GetReqExtra( GLXVendorPrivate,
sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq,
vpreq );
req = (xGLXQueryContextInfoEXTReq *)vpreq;
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_QueryContextInfoEXT;
req->context = (unsigned int)(ctx->xid);
}
_XReply(dpy, (xReply*) &reply, 0, False);
numValues = reply.n;
......@@ -1749,12 +1767,15 @@ static int __glXQueryContextInfo(Display *dpy, GLXContext ctx)
case GLX_VISUAL_ID_EXT:
ctx->vid = *pProp++;
break;
case GLX_SCREEN_EXT:
case GLX_SCREEN:
ctx->screen = *pProp++;
break;
case GLX_FBCONFIG_ID_SGIX:
case GLX_FBCONFIG_ID:
ctx->fbconfigID = *pProp++;
break;
case GLX_RENDER_TYPE:
ctx->renderType = *pProp++;
break;
default:
pProp++;
continue;
......@@ -1769,8 +1790,9 @@ static int __glXQueryContextInfo(Display *dpy, GLXContext ctx)
return retval;
}
int GLX_PREFIX(glXQueryContextInfoEXT)(Display *dpy, GLXContext ctx,
int attribute, int *value)
int
GLX_PREFIX(glXQueryContext)(Display *dpy, GLXContext ctx,
int attribute, int *value)
{
int retVal;
......@@ -1786,18 +1808,26 @@ int GLX_PREFIX(glXQueryContextInfoEXT)(Display *dpy, GLXContext ctx,
case GLX_VISUAL_ID_EXT:
*value = (int)(ctx->vid);
break;
case GLX_SCREEN_EXT:
case GLX_SCREEN:
*value = (int)(ctx->screen);
break;
case GLX_FBCONFIG_ID_SGIX:
case GLX_FBCONFIG_ID:
*value = (int)(ctx->fbconfigID);
break;
case GLX_RENDER_TYPE:
*value = (int)(ctx->renderType);
break;
default:
return GLX_BAD_ATTRIBUTE;
}
return Success;
}
GLX_ALIAS( int, glXQueryContextInfoEXT,
(Display *dpy, GLXContext ctx, int attribute, int *value),
(dpy, ctx, attribute, value),
glXQueryContext )
GLXContextID glXGetContextIDEXT(const GLXContext ctx)
{
return ctx->xid;
......@@ -1934,16 +1964,6 @@ XVisualInfo *GLX_PREFIX(glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig conf
}
int GLX_PREFIX(glXQueryContext)(Display *dpy, GLXContext ctx, int attribute, int *value)
{
(void) dpy;
(void) ctx;
(void) attribute;
(void) value;
return 0;
}
/*
** GLX_SGI_make_current_read
*/
......@@ -2971,7 +2991,7 @@ static const struct name_address_pair GLX_functions[] = {
GLX_FUNCTION( glXGetContextIDEXT ),
GLX_FUNCTION2( glXGetCurrentDisplayEXT, glXGetCurrentDisplay ),
GLX_FUNCTION( glXImportContextEXT ),
GLX_FUNCTION( glXQueryContextInfoEXT ),
GLX_FUNCTION2( glXQueryContextInfoEXT, glXQueryContext ),
/*** GLX_SGIX_fbconfig ***/
GLX_FUNCTION2( glXGetFBConfigAttribSGIX, glXGetFBConfigAttrib ),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment