xlib: remove empty GLX_MESA_agp_offset stubs
[mesa.git] / src / mesa / drivers / x11 / xm_api.c
index 5a3a206270d84d554a48e82e9e59e2b392a5cd5b..ec2a73cb369f79714d8d5a7476e611504980baaf 100644 (file)
@@ -62,6 +62,7 @@
 #undef __WIN32__
 #endif
 
+#include <stdio.h>
 #include "glxheader.h"
 #include "xmesaP.h"
 #include "main/api_exec.h"
@@ -195,7 +196,7 @@ bits_per_pixel( XMesaVisual xmv )
  * Do this by calling XGetWindowAttributes() for the window and
  * checking if we catch an X error.
  * Input:  dpy - the display
- *         win - the window to check for existance
+ *         win - the window to check for existence
  * Return:  GL_TRUE - window exists
  *          GL_FALSE - window doesn't exist
  */
@@ -285,7 +286,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
 {
    XMesaBuffer b;
 
-   ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER);
+   assert(type == WINDOW || type == PIXMAP || type == PBUFFER);
 
    b = (XMesaBuffer) CALLOC_STRUCT(xmesa_buffer);
    if (!b)
@@ -310,8 +311,8 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
    b->frontxrb->Parent = b;
    b->frontxrb->drawable = d;
    b->frontxrb->pixmap = (XMesaPixmap) d;
-   _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_FRONT_LEFT,
-                          &b->frontxrb->Base.Base);
+   _mesa_attach_and_own_rb(&b->mesa_buffer, BUFFER_FRONT_LEFT,
+                           &b->frontxrb->Base.Base);
 
    /*
     * Back renderbuffer
@@ -327,8 +328,8 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
       /* determine back buffer implementation */
       b->db_mode = vis->ximage_flag ? BACK_XIMAGE : BACK_PIXMAP;
       
-      _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_BACK_LEFT,
-                             &b->backxrb->Base.Base);
+      _mesa_attach_and_own_rb(&b->mesa_buffer, BUFFER_BACK_LEFT,
+                              &b->backxrb->Base.Base);
    }
 
    /*
@@ -564,7 +565,7 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
    const int xclass = v->visualType;
 
 
-   ASSERT(!b || b->xm_visual == v);
+   assert(!b || b->xm_visual == v);
 
    /* Save true bits/pixel */
    v->BitsPerPixel = bits_per_pixel(v);
@@ -582,7 +583,7 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
    }
    v->mesa_visual.indexBits = 0;
 
-   if (_mesa_getenv("MESA_NO_DITHER")) {
+   if (getenv("MESA_NO_DITHER")) {
       v->dithered_pf = v->undithered_pf;
    }
 
@@ -592,7 +593,7 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
     * which can help Brian figure out what's going on when a user
     * reports bugs.
     */
-   if (_mesa_getenv("MESA_INFO")) {
+   if (getenv("MESA_INFO")) {
       printf("X/Mesa visual = %p\n", (void *) v);
       printf("X/Mesa dithered pf = %u\n", v->dithered_pf);
       printf("X/Mesa undithered pf = %u\n", v->undithered_pf);
@@ -605,8 +606,8 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
       /* Do window-specific initializations */
 
       /* these should have been set in create_xmesa_buffer */
-      ASSERT(b->frontxrb->drawable == window);
-      ASSERT(b->frontxrb->pixmap == (XMesaPixmap) window);
+      assert(b->frontxrb->drawable == window);
+      assert(b->frontxrb->pixmap == (XMesaPixmap) window);
 
       /* Setup for single/double buffering */
       if (v->mesa_visual.doubleBufferMode) {
@@ -760,7 +761,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
    GLint red_bits, green_bits, blue_bits, alpha_bits;
 
    /* For debugging only */
-   if (_mesa_getenv("MESA_XSYNC")) {
+   if (getenv("MESA_XSYNC")) {
       /* This makes debugging X easier.
        * In your debugger, set a breakpoint on _XError to stop when an
        * X protocol error is generated.
@@ -783,7 +784,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
     * the struct but we may need some of the information contained in it
     * at a later time.
     */
-   v->visinfo = (XVisualInfo *) malloc(sizeof(*visinfo));
+   v->visinfo = malloc(sizeof(*visinfo));
    if(!v->visinfo) {
       free(v);
       return NULL;
@@ -791,7 +792,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
    memcpy(v->visinfo, visinfo, sizeof(*visinfo));
 
    /* check for MESA_GAMMA environment variable */
-   gamma = _mesa_getenv("MESA_GAMMA");
+   gamma = getenv("MESA_GAMMA");
    if (gamma) {
       v->RedGamma = v->GreenGamma = v->BlueGamma = 0.0;
       sscanf( gamma, "%f %f %f", &v->RedGamma, &v->GreenGamma, &v->BlueGamma );
@@ -855,7 +856,8 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
                                 accum_red_size, accum_green_size,
                                 accum_blue_size, accum_alpha_size,
                                 0)) {
-      FREE(v);
+      free(v->visinfo);
+      free(v);
       return NULL;
    }
 
@@ -928,6 +930,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
 
 
    /* finish up xmesa context initializations */
+   c->direct = GL_TRUE;
    c->swapbytes = CHECK_BYTE_ORDER(v) ? GL_FALSE : GL_TRUE;
    c->xm_visual = v;
    c->xm_buffer = NULL;   /* set later by XMesaMakeCurrent */
@@ -954,6 +957,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
 
    _mesa_meta_init(mesaCtx);
 
+   _mesa_override_extensions(mesaCtx);
    _mesa_compute_version(mesaCtx);
 
     /* Exec table initialization requires the version to be computed */
@@ -1301,6 +1305,14 @@ XMesaBuffer XMesaGetCurrentReadBuffer( void )
 }
 
 
+Display *XMesaGetCurrentDisplay(void)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   XMesaContext xmctx = XMESA_CONTEXT(ctx);
+   return xmctx ? xmctx->display : NULL;
+}
+
+
 
 GLboolean XMesaSetFXmode( GLint mode )
 {