/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
#endif
-/*
- * Return the width and height of the given drawable.
- */
-static void get_drawable_size( XMesaDisplay *dpy, XMesaDrawable d,
- unsigned int *width, unsigned int *height)
-{
-#ifdef XFree86Server
- (void) dpy;
- *width = d->width;
- *height = d->height;
-#else
- Window root;
- int x, y;
- unsigned int bw, depth;
-
- _glthread_LOCK_MUTEX(_xmesa_lock);
- XGetGeometry( dpy, d, &root, &x, &y, width, height, &bw, &depth );
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
-#endif
-}
-
-
/*
* Apply gamma correction to an intensity value in [0..max]. Return the
* new intensity value.
GC gc;
int (*old_handler)( XMesaDisplay *, XErrorEvent * );
- b->backimage = XShmCreateImage( b->xm_visual->display,
- b->xm_visual->visinfo->visual,
- b->xm_visual->visinfo->depth,
- ZPixmap, NULL, &b->shminfo,
- b->width, b->height );
+ if (b->mesa_buffer.Width == 0 || b->mesa_buffer.Height == 0) {
+ /* this will be true the first time we're called on 'b' */
+ return GL_FALSE;
+ }
+
+ b->backimage = XShmCreateImage(b->xm_visual->display,
+ b->xm_visual->visinfo->visual,
+ b->xm_visual->visinfo->depth,
+ ZPixmap, NULL, &b->shminfo,
+ b->mesa_buffer.Width, b->mesa_buffer.Height);
if (b->backimage == NULL) {
_mesa_warning(NULL, "alloc_back_buffer: Shared memory error (XShmCreateImage), disabling.");
b->shm = 0;
{
/* Allocate a regular XImage for the back buffer. */
b->backimage = XMesaCreateImage(b->xm_visual->BitsPerPixel,
- b->width, b->height, NULL);
+ b->mesa_buffer.Width,
+ b->mesa_buffer.Height, NULL);
#else
if (b->shm==0 || alloc_shm_back_buffer(b)==GL_FALSE) {
/* Allocate a regular XImage for the back buffer. */
b->xm_visual->visinfo->visual,
GET_VISUAL_DEPTH(b->xm_visual),
ZPixmap, 0, /* format, offset */
- NULL, b->width, b->height,
+ NULL,
+ b->mesa_buffer.Width,
+ b->mesa_buffer.Height,
8, 0 ); /* pad, bytes_per_line */
#endif
if (!b->backimage) {
}
/* Allocate new back pixmap */
b->backpixmap = XMesaCreatePixmap( b->xm_visual->display, b->frontbuffer,
- b->width, b->height,
+ b->mesa_buffer.Width,
+ b->mesa_buffer.Height,
GET_VISUAL_DEPTH(b->xm_visual) );
b->backimage = NULL;
/* update other references to backpixmap */
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;
}
if (b && window) {
/* Do window-specific initializations */
- /* Window dimensions */
- unsigned int w, h;
- get_drawable_size( v->display, window, &w, &h );
- b->width = w;
- b->height = h;
-
b->frontbuffer = window;
/* Setup for single/double buffering */
32, /*bitmap_pad*/
0 /*bytes_per_line*/ );
#endif
+ if (!b->rowimage)
+ return GL_FALSE;
}
return GL_TRUE;
accum_blue_size, accum_alpha_size,
0 );
+ /* XXX minor hack */
v->mesa_visual.level = level;
return v;
}
_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;
/* 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);
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 )) {
/* [dBorca] we should take an envvar for `fxMesaSelectCurrentBoard'!!! */
hw = fxMesaSelectCurrentBoard(0);
+
+ /* if these fail, there's a new bug somewhere */
+ ASSERT(b->mesa_buffer.Width > 0);
+ ASSERT(b->mesa_buffer.Height > 0);
+
if ((hw == GR_SSTTYPE_VOODOO) || (hw == GR_SSTTYPE_Voodoo2)) {
- b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
+ b->FXctx = fxMesaCreateBestContext(0, b->mesa_buffer.Width,
+ b->mesa_buffer.Height, attribs);
if ((v->undithered_pf!=PF_Index) && (b->backimage)) {
b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE;
if (b->FXctx && (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')) {
b->FXctx = fxMesaCreateContext(w, GR_RESOLUTION_NONE,
GR_REFRESH_75Hz, attribs);
else
- b->FXctx = fxMesaCreateBestContext(0, b->width, b->height, attribs);
+ b->FXctx = fxMesaCreateBestContext(0, b->mesa_buffer.Width,
+ b->mesa_buffer.Height, attribs);
b->FXisHackUsable = GL_FALSE;
b->FXwindowHack = GL_FALSE;
}
&drawBuffer->mesa_buffer,
&readBuffer->mesa_buffer);
- if (c->mesa.Viewport.Width == 0) {
- /* initialize viewport to window size */
- _mesa_Viewport( 0, 0, drawBuffer->width, drawBuffer->height );
- c->mesa.Scissor.Width = drawBuffer->width;
- c->mesa.Scissor.Height = drawBuffer->height;
- }
-
if (c->xm_visual->mesa_visual.rgbMode) {
/*
* Must recompute and set these pixel values because colormap
XGetGeometry( b->xm_visual->display, b->frontbuffer,
&root, &xpos, &ypos, &width, &height, &bw, &depth);
#endif
- if (b->width != width || b->height != height) {
- b->width = MIN2((int)width, b->FXctx->width);
- b->height = MIN2((int)height, b->FXctx->height);
- if (b->width & 1)
+ if (b->mesa_buffer.Width != width || b->mesa_buffer.Height != height) {
+ b->mesa_buffer.Width = MIN2((int)width, b->FXctx->width);
+ b->mesa_buffer.Height = MIN2((int)height, b->FXctx->height);
+ if (b->mesa_buffer.Width & 1)
b->width--; /* prevent odd width */
xmesa_alloc_back_buffer( b );
}
if (b->xm_visual->undithered_pf==PF_5R6G5B) {
/* Special case: 16bpp RGB */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER, /* src buffer */
- 0, b->FXctx->height - b->height, /*pos*/
- b->width, b->height, /* size */
- b->width * sizeof(GLushort), /* stride */
+ 0, b->FXctx->height - b->mesa_buffer.Height, /*pos*/
+ b->mesa_buffer.Width, b->mesa_buffer.Height, /* size */
+ b->mesa_buffer.Width * sizeof(GLushort), /* stride */
b->backimage->data); /* dest buffer */
}
else if (b->xm_visual->dithered_pf==PF_Dither
&& GET_VISUAL_DEPTH(b->xm_visual)==8) {
/* Special case: 8bpp RGB */
- for (y=0;y<b->height;y++) {
+ for (y=0;y<b->mesa_buffer.Height;y++) {
GLubyte *ptr = (GLubyte*) b->backimage->data
+ b->backimage->bytes_per_line * y;
XDITHER_SETUP(y);
/* read row from 3Dfx frame buffer */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
- 0, b->FXctx->height-(b->height-y),
- b->width, 1,
+ 0, b->FXctx->height-(b->mesa_buffer.Height-y),
+ b->mesa_buffer.Width, 1,
0,
pixbuf );
/* write to XImage back buffer */
- for (x=0;x<b->width;x++) {
+ for (x=0;x<b->mesa_buffer.Width;x++) {
GLubyte r = (pixbuf[x] & 0xf800) >> 8;
GLubyte g = (pixbuf[x] & 0x07e0) >> 3;
GLubyte b = (pixbuf[x] & 0x001f) << 3;
}
else {
/* General case: slow! */
- for (y=0;y<b->height;y++) {
+ for (y=0;y<b->mesa_buffer.Height;y++) {
/* read row from 3Dfx frame buffer */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
- 0, b->FXctx->height-(b->height-y),
- b->width, 1,
+ 0, b->FXctx->height-(b->mesa_buffer.Height-y),
+ b->mesa_buffer.Width, 1,
0,
pixbuf );
/* write to XImage back buffer */
- for (x=0;x<b->width;x++) {
+ for (x=0;x<b->mesa_buffer.Width;x++) {
XMesaPutPixel(b->backimage,x,y,
xmesa_color_to_pixel(xmesa,
(pixbuf[x] & 0xf800) >> 8,
XShmPutImage( b->xm_visual->display, b->frontbuffer,
b->swapgc,
b->backimage, 0, 0,
- 0, 0, b->width, b->height, False );
+ 0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
+ False );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
else
XMesaPutImage( b->xm_visual->display, b->frontbuffer,
b->swapgc,
b->backimage, 0, 0,
- 0, 0, b->width, b->height );
+ 0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height );
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
}
}
b->backpixmap, /* source drawable */
b->frontbuffer, /* dest. drawable */
b->swapgc,
- 0, 0, b->width, b->height, /* source region */
+ 0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
0, 0 /* dest region */
);
/*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
_mesa_notifySwapBuffers(ctx);
if (b->db_state) {
- int yTop = b->height - y - height;
+ int yTop = b->mesa_buffer.Height - y - height;
#ifdef FX
if (b->FXctx) {
fxMesaSwapBuffers();
GLint b = (GLint) (blue * 255.0F);
GLint a = (GLint) (alpha * 255.0F);
- (void) DitherValues; /* silence warning */
-
switch (xmesa->pixelformat) {
case PF_Index:
return 0;