David Reveman's GLX_EXT_texture_from_pixmap extension patch
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 7 Feb 2006 00:39:56 +0000 (00:39 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 7 Feb 2006 00:39:56 +0000 (00:39 +0000)
src/glx/x11/glx_pbuffer.c
src/glx/x11/glxcmds.c
src/glx/x11/glxextensions.c
src/glx/x11/glxextensions.h

index 83c5505..afdf710 100644 (file)
@@ -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;
 }
 
index 6a31f24..d23a530 100644 (file)
@@ -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 ),
index d259798..3e4fc0d 100644 (file)
@@ -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 }
 };
 
index b4b0372..8a8e901 100644 (file)
@@ -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 {