do clipping prior to XGetImage, just in case the image would extend beyond the screen...
[mesa.git] / src / mesa / drivers / x11 / xm_api.c
index 16963ab71c798ba4909dd76dc5c7c9247807072f..6255c3b79421af9d054c9c24da0f4c384f2a9361 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.1
+ * Version:  6.3
  *
  * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
  *
@@ -882,8 +882,6 @@ static GLboolean setup_grayscale( int client, XMesaVisual v,
 static GLboolean setup_dithered_color( int client, XMesaVisual v,
                                        XMesaBuffer buffer, XMesaColormap cmap )
 {
-   (void) DitherValues;  /* silence warning */
-
    if (GET_VISUAL_DEPTH(v)<4 || GET_VISUAL_DEPTH(v)>16) {
       return GL_FALSE;
    }
@@ -1343,6 +1341,8 @@ static GLboolean initialize_visual_and_buffer( int client,
                                   32,                   /*bitmap_pad*/
                                   0                     /*bytes_per_line*/ );
 #endif
+      if (!b->rowimage)
+         return GL_FALSE;
    }
 
    return GL_TRUE;
@@ -1604,6 +1604,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
                             accum_blue_size, accum_alpha_size,
                             0 );
 
+   /* XXX minor hack */
    v->mesa_visual.level = level;
    return v;
 }
@@ -1666,6 +1667,14 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
    _mesa_enable_1_3_extensions(mesaCtx);
    _mesa_enable_1_4_extensions(mesaCtx);
    _mesa_enable_1_5_extensions(mesaCtx);
+   _mesa_enable_2_0_extensions(mesaCtx);
+#if SWTC
+    if (c->Mesa_DXTn) {
+       _mesa_enable_extension(c, "GL_EXT_texture_compression_s3tc");
+       _mesa_enable_extension(c, "GL_S3_s3tc");
+    }
+    _mesa_enable_extension(c, "GL_3DFX_texture_compression_FXT1");
+#endif
 
    /* finish up xmesa context initializations */
    c->swapbytes = CHECK_BYTE_ORDER(v) ? GL_FALSE : GL_TRUE;
@@ -1678,10 +1687,14 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
 
    /* Initialize the software rasterizer and helper modules.
     */
-   _swrast_CreateContext( mesaCtx );
-   _ac_CreateContext( mesaCtx );
-   _tnl_CreateContext( mesaCtx );
-   _swsetup_CreateContext( mesaCtx );
+   if (!_swrast_CreateContext( mesaCtx ) ||
+       !_ac_CreateContext( mesaCtx ) ||
+       !_tnl_CreateContext( mesaCtx ) ||
+       !_swsetup_CreateContext( mesaCtx )) {
+      _mesa_free_context_data(&c->mesa);
+      _mesa_free(c);
+      return NULL;
+   }
 
    /* tnl setup */
    tnl = TNL_CONTEXT(mesaCtx);
@@ -1791,6 +1804,8 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
                                 v->mesa_visual.stencilBits > 0,
                                 v->mesa_visual.accumRedBits > 0,
                                 v->mesa_visual.alphaBits > 0 );
+   /* XXX hack */
+   b->mesa_buffer.UseSoftwareAuxBuffers = GL_TRUE;
 
    if (!initialize_visual_and_buffer( client, v, b, v->mesa_visual.rgbMode,
                                       (XMesaDrawable)w, b->cmap )) {
@@ -1830,15 +1845,19 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, XMesaWindow w,
        }
        attribs[numAttribs++] = FXMESA_NONE;
 
-       /* [dBorca]  we should take an envvar for `fxMesaSelectCurrentBoard'!!! */
-       if ((hw = fxMesaSelectCurrentBoard(0))==GR_SSTTYPE_VOODOO) {
+       /* [dBorca] we should take an envvar for `fxMesaSelectCurrentBoard'!!! */
+       hw = fxMesaSelectCurrentBoard(0);
+       if ((hw == GR_SSTTYPE_VOODOO) || (hw == GR_SSTTYPE_Voodoo2)) {
          b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
          if ((v->undithered_pf!=PF_Index) && (b->backimage)) {
           b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE;
-          if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')
-            b->FXwindowHack = b->FXctx ? GL_TRUE : GL_FALSE;
-          else
+          if (b->FXctx && (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')) {
+            b->FXwindowHack = GL_TRUE;
+            FX_grSstControl(GR_CONTROL_DEACTIVATE);
+          }
+           else {
             b->FXwindowHack = GL_FALSE;
+          }
          }
        }
        else {
@@ -2210,6 +2229,10 @@ GLboolean XMesaSetFXmode( GLint mode )
          return GL_FALSE;
       }
       if (ctx) {
+         /* [dBorca] Hack alert: 
+         * oh, this is sooo wrong: ctx above is
+         * really an fxMesaContext, not an XMesaContext
+         */
          XMesaContext xmesa = XMESA_CONTEXT(ctx);
          if (mode == XMESA_FX_WINDOW) {
            if (xmesa->xm_draw_buffer->FXisHackUsable) {
@@ -2269,10 +2292,7 @@ static void FXgetImage( XMesaBuffer b )
       xmesa_alloc_back_buffer( b );
    }
 
-   /* [dBorca]
-    * not needed for Voodoo2 anymore.
-    * should we test fxMesa->bgrOrder?
-    */
+   /* [dBorca] we're always in the right GR_COLORFORMAT... aren't we? */
    /* grLfbWriteColorFormat(GR_COLORFORMAT_ARGB); */
    if (b->xm_visual->undithered_pf==PF_5R6G5B) {
       /* Special case: 16bpp RGB */
@@ -2597,8 +2617,6 @@ unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
    GLint b = (GLint) (blue  * 255.0F);
    GLint a = (GLint) (alpha * 255.0F);
 
-   (void) DitherValues; /* silence warning */
-
    switch (xmesa->pixelformat) {
       case PF_Index:
          return 0;