From 42725d6f545087d094b1479d1ebcbd45ec6ac15c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 7 Feb 2006 00:39:56 +0000 Subject: David Reveman's GLX_EXT_texture_from_pixmap extension patch --- src/glx/x11/glx_pbuffer.c | 51 +++++++++++++++------------ src/glx/x11/glxcmds.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ src/glx/x11/glxextensions.c | 1 + src/glx/x11/glxextensions.h | 3 +- 4 files changed, 117 insertions(+), 22 deletions(-) (limited to 'src/glx') diff --git a/src/glx/x11/glx_pbuffer.c b/src/glx/x11/glx_pbuffer.c index 83c550559c..afdf710790 100644 --- a/src/glx/x11/glx_pbuffer.c +++ b/src/glx/x11/glx_pbuffer.c @@ -200,6 +200,7 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable, GLboolean use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3)); + *value = 0; if ( (dpy == NULL) || (drawable == 0) ) { return 0; @@ -230,33 +231,41 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable, _XReply(dpy, (xReply*) &reply, 0, False); + if (reply.type == X_Error) + { + UnlockDisplay(dpy); + SyncHandle(); + return 0; + } + length = reply.length; - num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2; - data = (CARD32 *) Xmalloc( length * sizeof(CARD32) ); - if ( data == NULL ) { - /* Throw data on the floor */ - _XEatData(dpy, length); - } else { - _XRead(dpy, (char *)data, length * sizeof(CARD32) ); + if (length) + { + num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2; + data = (CARD32 *) Xmalloc( length * sizeof(CARD32) ); + if ( data == NULL ) { + /* Throw data on the floor */ + _XEatData(dpy, length); + } else { + _XRead(dpy, (char *)data, length * sizeof(CARD32) ); + + /* Search the set of returned attributes for the attribute requested by + * the caller. + */ + for ( i = 0 ; i < num_attributes ; i++ ) { + if ( data[i*2] == attribute ) { + *value = data[ (i*2) + 1 ]; + break; + } + } + + Xfree( data ); + } } UnlockDisplay(dpy); SyncHandle(); - - /* Search the set of returned attributes for the attribute requested by - * the caller. - */ - - for ( i = 0 ; i < num_attributes ; i++ ) { - if ( data[i*2] == attribute ) { - *value = data[ (i*2) + 1 ]; - break; - } - } - - Xfree( data ); - return 0; } diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 6a31f24dd8..d23a530710 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -2589,7 +2589,87 @@ PUBLIC Bool glXSet3DfxModeMESA( int mode ) } /*@}*/ +PUBLIC Bool glXBindTexImageEXT(Display *dpy, + GLXDrawable drawable, + int buffer) +{ + xGLXVendorPrivateReq *req; + GLXContext gc = __glXGetCurrentContext(); + CARD32 *drawable_ptr; + INT32 *buffer_ptr; + CARD8 opcode; + if (gc == NULL) + return False; + +#ifdef GLX_DIRECT_RENDERING + if (gc->isDirect) + return False; +#endif + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return False; + + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, sizeof(CARD32)+sizeof(INT32),req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_BindTexImageEXT; + req->contextTag = gc->currentContextTag; + + drawable_ptr = (CARD32 *) (req + 1); + buffer_ptr = (INT32 *) (drawable_ptr + 1); + + *drawable_ptr = drawable; + *buffer_ptr = buffer; + + UnlockDisplay(dpy); + SyncHandle(); + + return True; +} + +PUBLIC Bool glXReleaseTexImageEXT(Display *dpy, + GLXDrawable drawable, + int buffer) +{ + xGLXVendorPrivateReq *req; + GLXContext gc = __glXGetCurrentContext(); + CARD32 *drawable_ptr; + INT32 *buffer_ptr; + CARD8 opcode; + + if (gc == NULL) + return False; + +#ifdef GLX_DIRECT_RENDERING + if (gc->isDirect) + return False; +#endif + + opcode = __glXSetupForCommand(dpy); + if (!opcode) + return False; + + LockDisplay(dpy); + GetReqExtra(GLXVendorPrivate, sizeof(CARD32)+sizeof(INT32),req); + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivate; + req->vendorCode = X_GLXvop_ReleaseTexImageEXT; + req->contextTag = gc->currentContextTag; + + drawable_ptr = (CARD32 *) (req + 1); + buffer_ptr = (INT32 *) (drawable_ptr + 1); + + *drawable_ptr = drawable; + *buffer_ptr = buffer; + + UnlockDisplay(dpy); + SyncHandle(); + + return True; +} /** * \c strdup is actually not a standard ANSI C or POSIX routine. @@ -2771,6 +2851,10 @@ static const struct name_address_pair GLX_functions[] = { GLX_FUNCTION( glXGetMscRateOML ), GLX_FUNCTION( glXGetSyncValuesOML ), + /*** GLX_EXT_texture_from_pixmap ***/ + GLX_FUNCTION( glXBindTexImageEXT ), + GLX_FUNCTION( glXReleaseTexImageEXT ), + #ifdef GLX_DIRECT_RENDERING /*** DRI configuration ***/ GLX_FUNCTION( glXGetScreenDriver ), diff --git a/src/glx/x11/glxextensions.c b/src/glx/x11/glxextensions.c index d2597981cf..3e4fc0d19f 100644 --- a/src/glx/x11/glxextensions.c +++ b/src/glx/x11/glxextensions.c @@ -107,6 +107,7 @@ static const struct extension_info known_glx_extensions[] = { { GLX(SGIX_video_source), VER(0,0), N, N, N, N }, { GLX(SGIX_visual_select_group), VER(0,0), Y, Y, N, N }, { GLX(SUN_get_transparent_index), VER(0,0), N, N, N, N }, + { GLX(EXT_texture_from_pixmap), VER(0,0), Y, N, N, N }, { NULL } }; diff --git a/src/glx/x11/glxextensions.h b/src/glx/x11/glxextensions.h index b4b03729ce..8a8e901e6b 100644 --- a/src/glx/x11/glxextensions.h +++ b/src/glx/x11/glxextensions.h @@ -69,7 +69,8 @@ enum { SGIX_video_resize_bit, SGIX_video_source_bit, SGIX_visual_select_group_bit, - SUN_get_transparent_index_bit + SUN_get_transparent_index_bit, + EXT_texture_from_pixmap_bit }; enum { -- cgit v1.2.3