indicates the read AND draw color buffer for all software rasterization.
Lots of related clean-ups. See RELNOTES-4.1 for details.
/*\r
* Set the current reading buffer.\r
*/\r
-static void set_read_buffer (GLcontext *ctx, GLframebuffer *buffer,\r
- GLenum mode)\r
+static void set_buffer (GLcontext *ctx, GLframebuffer *buffer, GLenum mode)\r
{\r
/*\r
DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
\r
\r
\r
-/*\r
- * Set the destination/draw buffer.\r
- */\r
-static void set_draw_buffer (GLcontext *ctx, GLenum mode)\r
-{\r
- /*\r
- XXX this has to be fixed\r
- */\r
-}\r
-\r
-\r
-\r
/*\r
* Return the width and height of the current buffer.\r
* If anything special has to been done when the buffer/window is\r
ctx->Driver.CopyPixels = _swrast_CopyPixels;\r
ctx->Driver.DrawPixels = _swrast_DrawPixels;\r
ctx->Driver.ReadPixels = _swrast_ReadPixels;\r
+ ctx->Driver.DrawBuffer = _swrast_DrawBuffer;\r
\r
/* Software texture functions:\r
*/\r
\r
/* Statechange callbacks:\r
*/\r
- ctx->Driver.SetDrawBuffer = set_draw_buffer;\r
ctx->Driver.ClearColor = clear_color;\r
\r
/* Initialize the TNL driver interface:\r
_ac_InvalidateState(ctx, new_state);\r
_tnl_InvalidateState(ctx, new_state);\r
\r
- swdd->SetReadBuffer = set_read_buffer;\r
+ swdd->SetBuffer = set_buffer;\r
\r
/* RGB(A) span/pixel functions */\r
swdd->WriteRGBASpan = write_rgba_span;\r
}
-/* Set the buffer used for drawing */
-static void gl_ggiSetDrawBuffer(GLcontext *ctx, GLenum mode)
-{
- ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
-
- printf("set draw %d\n", mode);
- GGIMESADPRINT_CORE("gl_ggiSetDrawBuffer() called\n");
-
- if (mode == GL_FRONT_LEFT)
- {
- ggiSetWriteFrame(ggi_ctx->ggi_visual,
- ggiGetDisplayFrame(ggi_ctx->ggi_visual));
- }
- else if (mode == GL_BACK_LEFT)
- {
- ggiSetWriteFrame(ggi_ctx->ggi_visual,
- ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1);
- }
- else
- {
- /* nothing since we don't have any point/line/triangle functions. */
- }
-}
-
/* Set the buffer used for reading */
/* XXX support for separate read/draw buffers hasn't been tested */
-static GLboolean gl_ggiSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer, GLenum mode)
+static GLboolean gl_ggiSetBuffer(GLcontext *ctx, GLframebuffer *buffer, GLenum mode)
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
printf("set read %d\n", mode);
- GGIMESADPRINT_CORE("gl_ggiSetReadBuffer() called\n");
+ GGIMESADPRINT_CORE("gl_ggiSetBuffer() called\n");
if (mode == GL_FRONT_LEFT)
{
ggiSetReadFrame(ggi_ctx->ggi_visual,
ggiGetDisplayFrame(ggi_ctx->ggi_visual));
+ ggiSetWriteFrame(ggi_ctx->ggi_visual,
+ ggiGetDisplayFrame(ggi_ctx->ggi_visual));
return GL_TRUE;
}
else if (mode == GL_BACK_LEFT)
{
ggiSetReadFrame(ggi_ctx->ggi_visual,
ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1);
+ ggiSetWriteFrame(ggi_ctx->ggi_visual,
+ ggiGetDisplayFrame(ggi_ctx->ggi_visual)?0 : 1);
return GL_TRUE;
}
else
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
/* Software texturing */
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
/* State change callbacks */
- ctx->Driver.SetDrawBuffer = gl_ggiSetDrawBuffer;
ctx->Driver.ClearIndex = gl_ggiSetClearIndex;
ctx->Driver.ClearColor = gl_ggiSetClearColor;
ctx->Driver.IndexMask = gl_ggiIndexMask;
-/* $Id: fxdd.c,v 1.88 2002/06/15 03:03:10 brianp Exp $ */
+/* $Id: fxdd.c,v 1.89 2002/07/09 01:22:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
/* we'll need a software fallback */
/* XXX not implemented */
}
+
+ /* update s/w fallback state */
+ _swrast_DrawBuffer(ctx, mode);
}
ctx->Driver.ClearIndex = NULL;
ctx->Driver.ClearColor = fxDDClearColor;
ctx->Driver.Clear = fxDDClear;
- ctx->Driver.SetDrawBuffer = fxDDSetDrawBuffer;
+ ctx->Driver.DrawBuffer = fxDDSetDrawBuffer;
ctx->Driver.GetBufferSize = fxDDBufferSize;
ctx->Driver.Accum = _swrast_Accum;
ctx->Driver.Bitmap = fxDDDrawBitmap;
-/* $Id: fxddspan.c,v 1.19 2001/09/23 16:50:01 brianp Exp $ */
+/* $Id: fxddspan.c,v 1.20 2002/07/09 01:22:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
/* Set the buffer used for reading */
/* XXX support for separate read/draw buffers hasn't been tested */
static void
-fxDDSetReadBuffer(GLcontext * ctx, GLframebuffer * buffer, GLenum mode)
+fxDDSetBuffer(GLcontext * ctx, GLframebuffer * buffer, GLenum mode)
{
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
(void) buffer;
{
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
- swdd->SetReadBuffer = fxDDSetReadBuffer;
+ swdd->SetBuffer = fxDDSetBuffer;
swdd->WriteRGBASpan = fxDDWriteRGBASpan;
swdd->WriteRGBSpan = fxDDWriteRGBSpan;
-/* $Id: osmesa.c,v 1.85 2002/06/30 16:07:18 brianp Exp $ */
+/* $Id: osmesa.c,v 1.86 2002/07/09 01:22:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
-static void set_draw_buffer( GLcontext *ctx, GLenum mode )
-{
- (void) ctx;
- (void) mode;
-}
-
-
-static void set_read_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode )
+static void set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode )
{
/* separate read buffer not supported */
ASSERT(buffer == ctx->DrawBuffer);
const SWvertex *v2 )
{
const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
-
#define INTERP_Z 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
FixedToChan(span->alpha)); \
zRow[i] = z; \
} \
- span->red += span->redStep; \
+ span->red += span->redStep; \
span->green += span->greenStep; \
span->blue += span->blueStep; \
span->alpha += span->alphaStep; \
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = osmesa_update_state;
- ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
+ swdd->SetBuffer = set_buffer;
+
/* RGB(A) span/pixel functions */
if (osmesa->format == OSMESA_RGB) {
swdd->WriteRGBASpan = write_rgba_span_RGB;
swdd->ReadCI32Span = read_index_span;
swdd->ReadCI32Pixels = read_index_pixels;
- swdd->SetReadBuffer = set_read_buffer;
-
tnl->Driver.RunPipeline = _tnl_run_pipeline;
_swrast_InvalidateState( ctx, new_state );
-/* $Id: svgamesa.c,v 1.19 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: svgamesa.c,v 1.20 2002/07/09 01:22:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
*height = SVGAMesa->height = vga_getydim();
}
-static void set_draw_buffer( GLcontext *ctx, GLenum buffer )
-{
- if (buffer == GL_FRONT_LEFT) {
- SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
-#if 0
- /* vga_waitretrace(); */
- void * tmpptr;
- copy_buffer(SVGABuffer.FrontBuffer);
- tmpptr=SVGABuffer.BackBuffer;
- SVGABuffer.BackBuffer=SVGABuffer.FrontBuffer;
- SVGABuffer.FrontBuffer=tmpptr;
-#endif
- }
- else if (buffer == GL_BACK_LEFT) {
- SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
-#if 0
- /* vga_waitretrace(); */
- copy_buffer(SVGABuffer.BackBuffer);
-#endif
- }
- else {
- /* nothing since we don't have any point/line/triangle functions. */
- }
-}
-
-static void set_read_buffer( GLcontext *ctx, GLframebuffer *colorBuffer,
- GLenum buffer )
+static void set_buffer( GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLenum buffer )
{
/* We can ignore colorBuffer since we don't support a MakeCurrentRead()
* function.
if (buffer == GL_FRONT_LEFT) {
SVGABuffer.ReadBuffer = SVGABuffer.FrontBuffer;
+ SVGABuffer.DrawBuffer = SVGABuffer.FrontBuffer;
#if 0
void * tmpptr;
/* vga_waitretrace(); */
}
else if (buffer == GL_BACK_LEFT) {
SVGABuffer.ReadBuffer = SVGABuffer.BackBuffer;
+ SVGABuffer.DrawBuffer = SVGABuffer.BackBuffer;
#if 0
/* vga_waitretrace(); */
copy_buffer(SVGABuffer.BackBuffer);
ctx->Driver.UpdateState = svgamesa_update_state;
ctx->Driver.GetBufferSize = get_buffer_size;
- ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
/* Software rasterizer pixel paths:
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
/* Fill in the swrast driver interface:
*/
- swdd->SetReadBuffer = set_read_buffer;
+ swdd->SetBuffer = set_buffer;
switch (SVGABuffer.Depth) {
case 8: ctx->Driver.ClearIndex = __clear_index8;
-/* $Id: wmesa.c,v 1.31 2002/06/15 03:03:10 brianp Exp $ */
+/* $Id: wmesa.c,v 1.32 2002/07/09 01:22:51 brianp Exp $ */
/*
* Windows (Win32) device driver for Mesa 3.4
}
}
-static void set_draw_buffer( GLcontext* ctx, GLenum mode )
-{
- /* XXX doing nothing for now */
- /* if front buffer, fine */
- /* if back buffer, fine */
- /* else, check swrast->_RasterMask & MULTI_DRAW_BIT, if true, */
- /* use a swrast fallback function */
-}
-static void set_read_buffer(GLcontext *ctx, GLframebuffer *colorBuffer,
- GLenum buffer )
+static void set_buffer(GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLenum buffer )
{
- /* XXX todo */
+ /* XXX todo - examine buffer and set read/write pointers */
return;
}
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = wmesa_update_state;
- ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
- swdd->SetReadBuffer = set_read_buffer;
+ swdd->SetBuffer = set_buffer;
/* Pixel/span writing functions: */
#if 0
ctx->Driver.GetString = get_string;
ctx->Driver.UpdateState = wmesa_update_state;
- ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.GetBufferSize = buffer_size;
ctx->Driver.BaseCompressedTexFormat = _mesa_base_compressed_texformat;
ctx->Driver.CompressedTextureSize = _mesa_compressed_texture_size;
ctx->Driver.GetCompressedTexImage = _mesa_get_compressed_teximage;
-
-
- swdd->SetReadBuffer = set_read_buffer;
-
+
+ swdd->SetBuffer = set_buffer;
/* Pixel/span writing functions: */
swdd->WriteRGBASpan = write_rgba_span;
-/* $Id: xm_api.c,v 1.39 2002/06/17 23:38:14 brianp Exp $ */
+/* $Id: xm_api.c,v 1.40 2002/07/09 01:22:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
}
c->xm_visual = v;
+ c->xm_draw_buffer = NULL; /* set later by XMesaMakeCurrent */
+ c->xm_read_buffer = NULL; /* set later by XMesaMakeCurrent */
c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */
c->display = v->display;
c->pixelformat = v->dithered_pf; /* Dithering is enabled by default */
void XMesaDestroyContext( XMesaContext c )
{
#ifdef FX
- if (c->xm_buffer && c->xm_buffer->FXctx)
- fxMesaDestroyContext(c->xm_buffer->FXctx);
+ if (c->xm_draw_buffer && c->xm_buffer->FXctx)
+ fxMesaDestroyContext(c->xm_draw_buffer->FXctx);
#endif
if (c->gl_ctx) {
_swsetup_DestroyContext( c->gl_ctx );
if (drawBuffer->FXctx) {
fxMesaMakeCurrent(drawBuffer->FXctx);
- c->xm_buffer = drawBuffer;
+ c->xm_draw_buffer = drawBuffer;
c->xm_read_buffer = readBuffer;
- c->use_read_buffer = (drawBuffer != readBuffer);
+ c->xm_buffer = drawBuffer;
return GL_TRUE;
}
#endif
if (c->gl_ctx == _mesa_get_current_context()
- && c->xm_buffer == drawBuffer
+ && c->xm_draw_buffer == drawBuffer
&& c->xm_read_buffer == readBuffer
- && c->xm_buffer->wasCurrent) {
+ && c->xm_draw_buffer->wasCurrent) {
/* same context and buffer, do nothing */
return GL_TRUE;
}
- c->xm_buffer = drawBuffer;
+ c->xm_draw_buffer = drawBuffer;
c->xm_read_buffer = readBuffer;
- c->use_read_buffer = (drawBuffer != readBuffer);
+ c->xm_buffer = drawBuffer;
_mesa_make_current2(c->gl_ctx,
&drawBuffer->mesa_buffer,
c->clearcolor[2],
c->clearcolor[3],
c->xm_visual->undithered_pf);
- XMesaSetForeground(c->display, c->xm_buffer->cleargc, c->clearpixel);
+ XMesaSetForeground(c->display, c->xm_draw_buffer->cleargc, c->clearpixel);
}
/* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */
- c->xm_buffer->wasCurrent = GL_TRUE;
+ c->xm_draw_buffer->wasCurrent = GL_TRUE;
}
else {
/* Detach */
GET_CURRENT_CONTEXT(ctx);
if (ctx) {
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- return xmesa->xm_buffer;
+ return xmesa->xm_draw_buffer;
}
else {
return 0;
GET_CURRENT_CONTEXT(ctx);
if (ctx) {
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- return xmesa->xm_buffer;
+ return xmesa->xm_read_buffer;
}
else {
return 0;
{
if (c) {
if (c->gl_ctx != _mesa_get_current_context()) {
- _mesa_make_current(c->gl_ctx, &c->xm_buffer->mesa_buffer);
+ _mesa_make_current(c->gl_ctx, &c->xm_draw_buffer->mesa_buffer);
}
}
else {
if (ctx) {
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
if (mode == XMESA_FX_WINDOW) {
- if (xmesa->xm_buffer->FXisHackUsable) {
+ if (xmesa->xm_draw_buffer->FXisHackUsable) {
FX_grSstControl(GR_CONTROL_DEACTIVATE);
- xmesa->xm_buffer->FXwindowHack = GL_TRUE;
+ xmesa->xm_draw_buffer->FXwindowHack = GL_TRUE;
return GL_TRUE;
}
}
else if (mode == XMESA_FX_FULLSCREEN) {
FX_grSstControl(GR_CONTROL_ACTIVATE);
- xmesa->xm_buffer->FXwindowHack = GL_FALSE;
+ xmesa->xm_draw_buffer->FXwindowHack = GL_FALSE;
return GL_TRUE;
}
else {
unsigned int bw, depth, width, height;
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- assert(xmesa->xm_buffer->FXctx);
+ assert(xmesa->xm_draw_buffer->FXctx);
#ifdef XFree86Server
x = b->frontbuffer->x;
&root, &xpos, &ypos, &width, &height, &bw, &depth);
#endif
if (b->width != width || b->height != height) {
- b->width = MIN2((int)width, xmesa->xm_buffer->FXctx->width);
- b->height = MIN2((int)height, xmesa->xm_buffer->FXctx->height);
+ b->width = MIN2((int)width, xmesa->xm_draw_buffer->FXctx->width);
+ b->height = MIN2((int)height, xmesa->xm_draw_buffer->FXctx->height);
if (b->width & 1)
b->width--; /* prevent odd width */
xmesa_alloc_back_buffer( b );
if (xmesa->xm_visual->undithered_pf==PF_5R6G5B) {
/* Special case: 16bpp RGB */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER, /* src buffer */
- 0, xmesa->xm_buffer->FXctx->height - b->height, /*pos*/
+ 0, xmesa->xm_draw_buffer->FXctx->height - b->height, /*pos*/
b->width, b->height, /* size */
b->width * sizeof(GLushort), /* stride */
b->backimage->data); /* dest buffer */
&& GET_VISUAL_DEPTH(xmesa->xm_visual)==8) {
/* Special case: 8bpp RGB */
for (y=0;y<b->height;y++) {
- GLubyte *ptr = (GLubyte*) xmesa->xm_buffer->backimage->data
- + xmesa->xm_buffer->backimage->bytes_per_line * y;
+ GLubyte *ptr = (GLubyte*) xmesa->xm_draw_buffer->backimage->data
+ + xmesa->xm_draw_buffer->backimage->bytes_per_line * y;
XDITHER_SETUP(y);
/* read row from 3Dfx frame buffer */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
- 0, xmesa->xm_buffer->FXctx->height-(b->height-y),
+ 0, xmesa->xm_draw_buffer->FXctx->height-(b->height-y),
b->width, 1,
0,
pixbuf );
for (y=0;y<b->height;y++) {
/* read row from 3Dfx frame buffer */
grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
- 0, xmesa->xm_buffer->FXctx->height-(b->height-y),
+ 0, xmesa->xm_draw_buffer->FXctx->height-(b->height-y),
b->width, 1,
0,
pixbuf );
-/* $Id: xm_dd.c,v 1.33 2002/06/19 21:49:37 brianp Exp $ */
+/* $Id: xm_dd.c,v 1.34 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
}
-static void
-set_draw_buffer( GLcontext *ctx, GLenum mode )
-{
- const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (mode == GL_FRONT_LEFT) {
- /* write to front buffer */
- xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
- xmesa_update_span_funcs(ctx);
- }
- else if (mode==GL_BACK_LEFT && xmesa->xm_buffer->db_state) {
- /* write to back buffer */
- if (xmesa->xm_buffer->backpixmap) {
- xmesa->xm_buffer->buffer =
- (XMesaDrawable)xmesa->xm_buffer->backpixmap;
- }
- else if (xmesa->xm_buffer->backimage) {
- xmesa->xm_buffer->buffer = None;
- }
- else {
- /* just in case there wasn't enough memory for back buffer */
- xmesa->xm_buffer->buffer = xmesa->xm_buffer->frontbuffer;
- }
- xmesa_update_span_funcs(ctx);
- }
- else {
- /* the swrast->_RasterMask MULTI_DRAW_BIT will be set and
- * we'll fall back to swrast to draw points/lines/triangles.
- */
- }
-}
-
-void
-xmesa_set_read_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode )
+/*
+ * This chooses the color buffer for reading and writing spans, points,
+ * lines, and triangles.
+ */
+static void
+set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode )
{
- XMesaBuffer target;
+ /* We can make this cast since the XMesaBuffer wraps GLframebuffer.
+ * GLframebuffer is the first member in a XMesaBuffer struct.
+ */
+ XMesaBuffer target = (XMesaBuffer) buffer;
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (buffer == ctx->DrawBuffer) {
- target = xmesa->xm_buffer;
- xmesa->use_read_buffer = GL_FALSE;
- }
- else {
- ASSERT(buffer == ctx->ReadBuffer);
- target = xmesa->xm_read_buffer;
- xmesa->use_read_buffer = GL_TRUE;
- }
+ /* This assignment tells the span/point/line/triangle functions
+ * which XMesaBuffer to use.
+ */
+ xmesa->xm_buffer = target;
+ /*
+ * Now determine front vs back color buffer.
+ */
if (mode == GL_FRONT_LEFT) {
target->buffer = target->frontbuffer;
- xmesa_update_span_funcs(ctx);
}
- else if (mode==GL_BACK_LEFT && xmesa->xm_read_buffer->db_state) {
+ else if (mode == GL_BACK_LEFT) {
+ ASSERT(target->db_state);
if (target->backpixmap) {
- target->buffer = (XMesaDrawable)xmesa->xm_buffer->backpixmap;
+ /* back buffer is a pixmape */
+ target->buffer = target->backpixmap;
}
else if (target->backimage) {
+ /* back buffer is an XImage */
target->buffer = None;
}
else {
- /* just in case there wasn't enough memory for back buffer */
+ /* No back buffer!!!! Must be out of memory, use front buffer */
target->buffer = target->frontbuffer;
}
- xmesa_update_span_funcs(ctx);
}
else {
- _mesa_problem(ctx, "invalid buffer in set_read_buffer() in xmesa2.c");
+ _mesa_problem(ctx, "invalid buffer in set_buffer() in xmesa2.c");
+ return;
}
+ xmesa_update_span_funcs(ctx);
}
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
xmesa->clearpixel = (unsigned long) index;
- XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc,
+ XMesaSetForeground( xmesa->display, xmesa->xm_draw_buffer->cleargc,
(unsigned long) index );
}
color[2], color[3],
xmesa->xm_visual->undithered_pf );
_glthread_LOCK_MUTEX(_xmesa_lock);
- XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc,
+ XMesaSetForeground( xmesa->display, xmesa->xm_draw_buffer->cleargc,
xmesa->clearpixel );
_glthread_UNLOCK_MUTEX(_xmesa_lock);
}
index_mask( GLcontext *ctx, GLuint mask )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- if (xmesa->xm_buffer->buffer != XIMAGE) {
+ if (xmesa->xm_draw_buffer->buffer != XIMAGE) {
unsigned long m;
if (mask==0xffffffff) {
m = ((unsigned long)~0L);
else {
m = (unsigned long) mask;
}
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m );
+ XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->cleargc, m );
}
}
if (gmask) m |= GET_GREENMASK(xmesa->xm_visual);
if (bmask) m |= GET_BLUEMASK(xmesa->xm_visual);
}
- XMesaSetPlaneMask( xmesa->display, xmesa->xm_buffer->cleargc, m );
+ XMesaSetPlaneMask( xmesa->display, xmesa->xm_draw_buffer->cleargc, m );
}
}
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
if (all) {
- XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->frontbuffer,
- xmesa->xm_buffer->cleargc,
+ XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->frontbuffer,
+ xmesa->xm_draw_buffer->cleargc,
0, 0,
- xmesa->xm_buffer->width+1,
- xmesa->xm_buffer->height+1 );
+ xmesa->xm_draw_buffer->width+1,
+ xmesa->xm_draw_buffer->height+1 );
}
else {
- XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->frontbuffer,
- xmesa->xm_buffer->cleargc,
- x, xmesa->xm_buffer->height - y - height,
+ XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->frontbuffer,
+ xmesa->xm_draw_buffer->cleargc,
+ x, xmesa->xm_draw_buffer->height - y - height,
width, height );
}
}
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
if (all) {
- XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->backpixmap,
- xmesa->xm_buffer->cleargc,
+ XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap,
+ xmesa->xm_draw_buffer->cleargc,
0, 0,
- xmesa->xm_buffer->width+1,
- xmesa->xm_buffer->height+1 );
+ xmesa->xm_draw_buffer->width+1,
+ xmesa->xm_draw_buffer->height+1 );
}
else {
- XMesaFillRectangle( xmesa->display, xmesa->xm_buffer->backpixmap,
- xmesa->xm_buffer->cleargc,
- x, xmesa->xm_buffer->height - y - height,
+ XMesaFillRectangle( xmesa->display, xmesa->xm_draw_buffer->backpixmap,
+ xmesa->xm_draw_buffer->cleargc,
+ x, xmesa->xm_draw_buffer->height - y - height,
width, height );
}
}
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
if (all) {
- size_t n = xmesa->xm_buffer->backimage->bytes_per_line
- * xmesa->xm_buffer->backimage->height;
- MEMSET( xmesa->xm_buffer->backimage->data, xmesa->clearpixel, n );
+ size_t n = xmesa->xm_draw_buffer->backimage->bytes_per_line
+ * xmesa->xm_draw_buffer->backimage->height;
+ MEMSET( xmesa->xm_draw_buffer->backimage->data, xmesa->clearpixel, n );
}
else {
GLint i;
for (i=0;i<height;i++) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, y+i );
+ GLubyte *ptr = PIXELADDR1( xmesa->xm_draw_buffer, x, y+i );
MEMSET( ptr, xmesa->clearpixel, width );
}
}
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
if (all) {
- GLint i, c16 = (xmesa->xm_buffer->backimage->bytes_per_line>>4)<<4;
- GLubyte *ptr = (GLubyte *)xmesa->xm_buffer->backimage->data;
- for (i=0; i<xmesa->xm_buffer->backimage->height; i++) {
+ GLint i, c16 = (xmesa->xm_draw_buffer->backimage->bytes_per_line>>4)<<4;
+ GLubyte *ptr = (GLubyte *)xmesa->xm_draw_buffer->backimage->data;
+ for (i=0; i<xmesa->xm_draw_buffer->backimage->height; i++) {
GLint j;
GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
if (i&1) {
ptr[15] = sptr[15];
ptr += 16;
}
- for (; j<xmesa->xm_buffer->backimage->bytes_per_line; j++) {
+ for (; j<xmesa->xm_draw_buffer->backimage->bytes_per_line; j++) {
*ptr = sptr[j&15];
ptr++;
}
else {
GLint i;
for (i=y; i<y+height; i++) {
- GLubyte *ptr = PIXELADDR1( xmesa->xm_buffer, x, i );
+ GLubyte *ptr = PIXELADDR1( xmesa->xm_draw_buffer, x, i );
int j;
GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
if (i&1) {
}
if (all) {
register GLuint n;
- register GLuint *ptr4 = (GLuint *) xmesa->xm_buffer->backimage->data;
+ register GLuint *ptr4 = (GLuint *) xmesa->xm_draw_buffer->backimage->data;
if ((pixel & 0xff) == ((pixel >> 8) & 0xff)) {
/* low and high bytes are equal so use memset() */
- n = xmesa->xm_buffer->backimage->bytes_per_line
- * xmesa->xm_buffer->height;
+ n = xmesa->xm_draw_buffer->backimage->bytes_per_line
+ * xmesa->xm_draw_buffer->height;
MEMSET( ptr4, pixel & 0xff, n );
}
else {
pixel = pixel | (pixel<<16);
- n = xmesa->xm_buffer->backimage->bytes_per_line
- * xmesa->xm_buffer->height / 4;
+ n = xmesa->xm_draw_buffer->backimage->bytes_per_line
+ * xmesa->xm_draw_buffer->height / 4;
do {
*ptr4++ = pixel;
n--;
} while (n!=0);
- if ((xmesa->xm_buffer->backimage->bytes_per_line *
- xmesa->xm_buffer->height) & 0x2)
+ if ((xmesa->xm_draw_buffer->backimage->bytes_per_line *
+ xmesa->xm_draw_buffer->height) & 0x2)
*(GLushort *)ptr4 = pixel & 0xffff;
}
}
else {
register int i, j;
for (j=0;j<height;j++) {
- register GLushort *ptr2 = PIXELADDR2( xmesa->xm_buffer, x, y+j );
+ register GLushort *ptr2 = PIXELADDR2( xmesa->xm_draw_buffer, x, y+j );
for (i=0;i<width;i++) {
*ptr2++ = pixel;
}
if (all) {
if (r==g && g==b) {
/* same value for all three components (gray) */
- const GLint w3 = xmesa->xm_buffer->width * 3;
- const GLint h = xmesa->xm_buffer->height;
+ const GLint w3 = xmesa->xm_draw_buffer->width * 3;
+ const GLint h = xmesa->xm_draw_buffer->height;
GLint i;
for (i = 0; i < h; i++) {
- bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i);
+ bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i);
MEMSET(ptr3, r, w3);
}
}
else {
/* the usual case */
- const GLint w = xmesa->xm_buffer->width;
- const GLint h = xmesa->xm_buffer->height;
+ const GLint w = xmesa->xm_draw_buffer->width;
+ const GLint h = xmesa->xm_draw_buffer->height;
GLint i, j;
for (i = 0; i < h; i++) {
- bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i);
+ bgr_t *ptr3 = PIXELADDR3(xmesa->xm_draw_buffer, 0, i);
for (j = 0; j < w; j++) {
ptr3->r = r;
ptr3->g = g;
/* same value for all three components (gray) */
GLint j;
for (j=0;j<height;j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j );
+ bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j );
MEMSET(ptr3, r, 3 * width);
}
}
/* non-gray clear color */
GLint i, j;
for (j = 0; j < height; j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j );
+ bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j );
for (i = 0; i < width; i++) {
ptr3->r = r;
ptr3->g = g;
pixel4[1] = (clearPixel << 16) | (clearPixel >> 8);
pixel4[2] = (clearPixel << 8) | (clearPixel >> 16);
for (j=0;j<height;j++) {
- bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j );
+ bgr_t *ptr3 = PIXELADDR3( xmesa->xm_draw_buffer, x, y+j );
register GLuint *ptr4 = (GLuint *)ptr3;
register GLuint *p, px;
GLuint w = width;
| ((pixel << 24) & 0xff000000);
}
if (all) {
- register GLint n = xmesa->xm_buffer->width * xmesa->xm_buffer->height;
- register GLuint *ptr4 = (GLuint *) xmesa->xm_buffer->backimage->data;
+ register GLint n = xmesa->xm_draw_buffer->width * xmesa->xm_draw_buffer->height;
+ register GLuint *ptr4 = (GLuint *) xmesa->xm_draw_buffer->backimage->data;
if (pixel==0) {
MEMSET( ptr4, pixel, 4*n );
}
else {
register int i, j;
for (j=0;j<height;j++) {
- register GLuint *ptr4 = PIXELADDR4( xmesa->xm_buffer, x, y+j );
+ register GLuint *ptr4 = PIXELADDR4( xmesa->xm_draw_buffer, x, y+j );
for (i=0;i<width;i++) {
*ptr4++ = pixel;
}
GLint x, GLint y, GLint width, GLint height )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaImage *img = xmesa->xm_buffer->backimage;
+ XMesaImage *img = xmesa->xm_draw_buffer->backimage;
if (all) {
register int i, j;
- width = xmesa->xm_buffer->width;
- height = xmesa->xm_buffer->height;
+ width = xmesa->xm_draw_buffer->width;
+ height = xmesa->xm_draw_buffer->height;
for (j=0;j<height;j++) {
for (i=0;i<width;i++) {
XMesaPutPixel( img, i, j, xmesa->clearpixel );
else {
/* TODO: optimize this */
register int i, j;
- y = FLIP(xmesa->xm_buffer, y);
+ y = FLIP(xmesa->xm_draw_buffer, y);
for (j=0;j<height;j++) {
for (i=0;i<width;i++) {
XMesaPutPixel( img, x+i, y-j, xmesa->clearpixel );
const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
if ((mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) &&
- xmesa->xm_buffer->mesa_buffer.UseSoftwareAlphaBuffers &&
+ xmesa->xm_draw_buffer->mesa_buffer.UseSoftwareAlphaBuffers &&
ctx->Color.ColorMask[ACOMP]) {
_mesa_clear_alpha_buffers(ctx);
}
/* we can't handle color or index masking */
if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
if (mask & DD_FRONT_LEFT_BIT) {
- ASSERT(xmesa->xm_buffer->front_clear_func);
- (*xmesa->xm_buffer->front_clear_func)( ctx, all, x, y, width, height );
+ ASSERT(xmesa->xm_draw_buffer->front_clear_func);
+ (*xmesa->xm_draw_buffer->front_clear_func)( ctx, all, x, y, width, height );
mask &= ~DD_FRONT_LEFT_BIT;
}
if (mask & DD_BACK_LEFT_BIT) {
- ASSERT(xmesa->xm_buffer->back_clear_func);
- (*xmesa->xm_buffer->back_clear_func)( ctx, all, x, y, width, height );
+ ASSERT(xmesa->xm_draw_buffer->back_clear_func);
+ (*xmesa->xm_draw_buffer->back_clear_func)( ctx, all, x, y, width, height );
mask &= ~DD_BACK_LEFT_BIT;
}
}
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
- XMesaDrawable buffer = xmesa->xm_buffer->buffer;
- XMesaGC gc = xmesa->xm_buffer->gc;
+ XMesaDrawable buffer = xmesa->xm_draw_buffer->buffer;
+ XMesaGC gc = xmesa->xm_draw_buffer->gc;
assert(dpy);
assert(buffer);
assert(gc);
ximage.red_mask = 0xff0000;
ximage.green_mask = 0x00ff00;
ximage.blue_mask = 0x0000ff;
- dstY = FLIP(xmesa->xm_buffer,dstY) - height + 1;
+ dstY = FLIP(xmesa->xm_draw_buffer,dstY) - height + 1;
XPutImage(dpy, buffer, gc, &ximage, srcX, srcY, dstX, dstY, w, h);
return GL_TRUE;
}
/* setup pointers to front and back buffer clear functions */
- xmesa->xm_buffer->front_clear_func = clear_front_pixmap;
- if (xmesa->xm_buffer->backpixmap != XIMAGE) {
- xmesa->xm_buffer->back_clear_func = clear_back_pixmap;
+ xmesa->xm_draw_buffer->front_clear_func = clear_front_pixmap;
+ if (xmesa->xm_draw_buffer->backpixmap != XIMAGE) {
+ xmesa->xm_draw_buffer->back_clear_func = clear_back_pixmap;
}
else if (sizeof(GLushort)!=2 || sizeof(GLuint)!=4) {
- xmesa->xm_buffer->back_clear_func = clear_nbit_ximage;
+ xmesa->xm_draw_buffer->back_clear_func = clear_nbit_ximage;
}
else switch (xmesa->xm_visual->BitsPerPixel) {
case 8:
if (xmesa->xm_visual->hpcr_clear_flag) {
- xmesa->xm_buffer->back_clear_func = clear_HPCR_ximage;
+ xmesa->xm_draw_buffer->back_clear_func = clear_HPCR_ximage;
}
else {
- xmesa->xm_buffer->back_clear_func = clear_8bit_ximage;
+ xmesa->xm_draw_buffer->back_clear_func = clear_8bit_ximage;
}
break;
case 16:
- xmesa->xm_buffer->back_clear_func = clear_16bit_ximage;
+ xmesa->xm_draw_buffer->back_clear_func = clear_16bit_ximage;
break;
case 24:
- xmesa->xm_buffer->back_clear_func = clear_24bit_ximage;
+ xmesa->xm_draw_buffer->back_clear_func = clear_24bit_ximage;
break;
case 32:
- xmesa->xm_buffer->back_clear_func = clear_32bit_ximage;
+ xmesa->xm_draw_buffer->back_clear_func = clear_32bit_ximage;
break;
default:
- xmesa->xm_buffer->back_clear_func = clear_nbit_ximage;
+ xmesa->xm_draw_buffer->back_clear_func = clear_nbit_ximage;
break;
}
void xmesa_init_pointers( GLcontext *ctx )
{
TNLcontext *tnl;
+ struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference( ctx );
ctx->Driver.GetString = get_string;
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.CopyPixels = _swrast_CopyPixels;
ctx->Driver.DrawPixels = _swrast_DrawPixels;
ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.DrawBuffer = _swrast_DrawBuffer;
/* Software texture functions:
*/
/* Statechange callbacks:
*/
- ctx->Driver.SetDrawBuffer = set_draw_buffer;
ctx->Driver.ClearIndex = clear_index;
ctx->Driver.ClearColor = clear_color;
ctx->Driver.IndexMask = index_mask;
tnl = TNL_CONTEXT(ctx);
tnl->Driver.RunPipeline = _tnl_run_pipeline;
+ dd->SetBuffer = set_buffer;
+
/* Install swsetup for tnl->Driver.Render.*:
*/
_swsetup_Wakeup(ctx);
-/* $Id: xm_span.c,v 1.14 2002/03/01 04:28:32 brianp Exp $ */
+/* $Id: xm_span.c,v 1.15 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLuint n, GLint x, GLint y, GLuint index[] )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaBuffer source;
+ XMesaBuffer source = xmesa->xm_buffer;
GLuint i;
- if (xmesa->use_read_buffer)
- source = xmesa->xm_read_buffer;
- else
- source = xmesa->xm_buffer;
-
y = FLIP(source, y);
if (source->buffer) {
GLubyte rgba[][4] )
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
- XMesaBuffer source;
-
- if (xmesa->use_read_buffer)
- source = xmesa->xm_read_buffer;
- else
- source = xmesa->xm_buffer;
+ XMesaBuffer source = xmesa->xm_buffer;
if (source->buffer) {
/* Read from Pixmap or Window */
{
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
register GLuint i;
- XMesaBuffer source;
-
- if (xmesa->use_read_buffer)
- source = xmesa->xm_read_buffer;
- else
- source = xmesa->xm_buffer;
+ XMesaBuffer source = xmesa->xm_buffer;
if (source->buffer) {
for (i=0;i<n;i++) {
const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaDisplay *dpy = xmesa->xm_visual->display;
register GLuint i;
- XMesaBuffer source;
- XMesaDrawable buffer;
-
- if (xmesa->use_read_buffer)
- source = xmesa->xm_read_buffer;
- else
- source = xmesa->xm_buffer;
-
- buffer = source->buffer; /* the X drawable */
+ XMesaBuffer source = xmesa->xm_buffer;
+ XMesaDrawable buffer = source->buffer; /* the X drawable */
if (source->buffer) {
switch (xmesa->pixelformat) {
dd->ReadRGBASpan = read_color_span;
dd->ReadCI32Pixels = read_index_pixels;
dd->ReadRGBAPixels = read_color_pixels;
-
- dd->SetReadBuffer = xmesa_set_read_buffer;
}
-/* $Id: xmesaP.h,v 1.28 2002/05/27 17:06:59 brianp Exp $ */
+/* $Id: xmesaP.h,v 1.29 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
struct xmesa_context {
GLcontext *gl_ctx; /* the core library context */
XMesaVisual xm_visual; /* Describes the buffers */
- XMesaBuffer xm_buffer; /* current draw framebuffer */
+ XMesaBuffer xm_draw_buffer; /* current draw framebuffer */
XMesaBuffer xm_read_buffer; /* current read framebuffer */
- GLboolean use_read_buffer; /* read from the xm_read_buffer/ */
+ XMesaBuffer xm_buffer; /* current span/point/line/triangle buffer */
XMesaDisplay *display; /* == xm_visual->display */
GLboolean swapbytes; /* Host byte order != display byte order? */
*/
struct xmesa_buffer {
GLframebuffer mesa_buffer; /* depth, stencil, accum, etc buffers */
+ /* This MUST BE FIRST! */
GLboolean wasCurrent; /* was ever the current buffer? */
XMesaVisual xm_visual; /* the X/Mesa visual */
extern GLboolean XMesaLoseCurrent(XMesaContext c);
extern void XMesaReset( void );
-extern void xmesa_set_read_buffer( GLcontext *ctx,
- GLframebuffer *buffer, GLenum mode );
-
extern void xmesa_resize_buffers( GLframebuffer *buffer );
#endif
-/* $Id: buffers.c,v 1.36 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: buffers.c,v 1.37 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
/* don't clear depth buffer if depth writing disabled */
if (!ctx->Depth.Mask)
- CLEAR_BITS(mask, GL_DEPTH_BUFFER_BIT);
+ mask &= ~GL_DEPTH_BUFFER_BIT;
/* Build bitmask to send to driver Clear function */
ddMask = mask & (GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT |
GL_ACCUM_BUFFER_BIT);
if (mask & GL_COLOR_BUFFER_BIT) {
- ddMask |= ctx->Color.DrawDestMask;
+ ddMask |= ctx->Color._DrawDestMask;
}
ASSERT(ctx->Driver.Clear);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(mode));
+ /*
+ * Do error checking and compute the _DrawDestMask bitfield.
+ */
switch (mode) {
case GL_AUX0:
case GL_AUX1:
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
return;}
if (ctx->Visual.doubleBufferMode)
- ctx->Color.DrawDestMask = FRONT_RIGHT_BIT | BACK_RIGHT_BIT;
+ ctx->Color._DrawDestMask = FRONT_RIGHT_BIT | BACK_RIGHT_BIT;
else
- ctx->Color.DrawDestMask = FRONT_RIGHT_BIT;
+ ctx->Color._DrawDestMask = FRONT_RIGHT_BIT;
break;
case GL_FRONT_RIGHT:
if (!ctx->Visual.stereoMode) {
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
return;
}
- ctx->Color.DrawDestMask = FRONT_RIGHT_BIT;
+ ctx->Color._DrawDestMask = FRONT_RIGHT_BIT;
break;
case GL_BACK_RIGHT:
if (!ctx->Visual.stereoMode) {
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
return;
}
- ctx->Color.DrawDestMask = BACK_RIGHT_BIT;
+ ctx->Color._DrawDestMask = BACK_RIGHT_BIT;
break;
case GL_BACK_LEFT:
if (!ctx->Visual.doubleBufferMode) {
_mesa_error( ctx, GL_INVALID_OPERATION, "glDrawBuffer" );
return;
}
- ctx->Color.DrawDestMask = BACK_LEFT_BIT;
+ ctx->Color._DrawDestMask = BACK_LEFT_BIT;
break;
case GL_FRONT_AND_BACK:
if (!ctx->Visual.doubleBufferMode) {
return;
}
if (ctx->Visual.stereoMode)
- ctx->Color.DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT
+ ctx->Color._DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT
| FRONT_RIGHT_BIT | BACK_RIGHT_BIT;
else
- ctx->Color.DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT;
+ ctx->Color._DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT;
break;
case GL_BACK:
if (!ctx->Visual.doubleBufferMode) {
return;
}
if (ctx->Visual.stereoMode)
- ctx->Color.DrawDestMask = BACK_LEFT_BIT | BACK_RIGHT_BIT;
+ ctx->Color._DrawDestMask = BACK_LEFT_BIT | BACK_RIGHT_BIT;
else
- ctx->Color.DrawDestMask = BACK_LEFT_BIT;
+ ctx->Color._DrawDestMask = BACK_LEFT_BIT;
break;
case GL_LEFT:
/* never an error */
if (ctx->Visual.doubleBufferMode)
- ctx->Color.DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT;
+ ctx->Color._DrawDestMask = FRONT_LEFT_BIT | BACK_LEFT_BIT;
else
- ctx->Color.DrawDestMask = FRONT_LEFT_BIT;
+ ctx->Color._DrawDestMask = FRONT_LEFT_BIT;
break;
case GL_FRONT_LEFT:
/* never an error */
- ctx->Color.DrawDestMask = FRONT_LEFT_BIT;
+ ctx->Color._DrawDestMask = FRONT_LEFT_BIT;
break;
case GL_FRONT:
/* never an error */
if (ctx->Visual.stereoMode)
- ctx->Color.DrawDestMask = FRONT_LEFT_BIT | FRONT_RIGHT_BIT;
+ ctx->Color._DrawDestMask = FRONT_LEFT_BIT | FRONT_RIGHT_BIT;
else
- ctx->Color.DrawDestMask = FRONT_LEFT_BIT;
+ ctx->Color._DrawDestMask = FRONT_LEFT_BIT;
break;
case GL_NONE:
/* never an error */
- ctx->Color.DrawDestMask = 0;
+ ctx->Color._DrawDestMask = 0;
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glDrawBuffer" );
return;
}
- /*
- * Make the dest buffer mode more precise if possible
- */
- if (mode == GL_LEFT && !ctx->Visual.doubleBufferMode)
- ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT;
- else if (mode == GL_RIGHT && !ctx->Visual.doubleBufferMode)
- ctx->Color.DriverDrawBuffer = GL_FRONT_RIGHT;
- else if (mode == GL_FRONT && !ctx->Visual.stereoMode)
- ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT;
- else if (mode == GL_BACK && !ctx->Visual.stereoMode)
- ctx->Color.DriverDrawBuffer = GL_BACK_LEFT;
- else
- ctx->Color.DriverDrawBuffer = mode;
-
- /*
- * Set current alpha buffer pointer
- */
- if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) {
- if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT)
- ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontLeftAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT)
- ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackLeftAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_FRONT_RIGHT)
- ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontRightAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_BACK_RIGHT)
- ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackRightAlpha;
- }
+ ctx->Color.DrawBuffer = mode;
+ ctx->NewState |= _NEW_COLOR;
/*
- * If we get here there can't have been an error. Now tell the
- * device driver about it.
+ * Call device driver function.
*/
- ASSERT(ctx->Driver.SetDrawBuffer);
- (*ctx->Driver.SetDrawBuffer)(ctx, ctx->Color.DriverDrawBuffer);
-
- ctx->Color.DrawBuffer = mode;
- ctx->NewState |= _NEW_COLOR;
+ if (ctx->Driver.DrawBuffer)
+ (*ctx->Driver.DrawBuffer)(ctx, mode);
}
case GL_FRONT:
case GL_FRONT_LEFT:
/* Front-Left buffer, always exists */
- ctx->Pixel.DriverReadBuffer = GL_FRONT_LEFT;
+ ctx->Pixel._DriverReadBuffer = GL_FRONT_LEFT;
break;
case GL_BACK:
case GL_BACK_LEFT:
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" );
return;
}
- ctx->Pixel.DriverReadBuffer = GL_BACK_LEFT;
+ ctx->Pixel._DriverReadBuffer = GL_BACK_LEFT;
break;
case GL_FRONT_RIGHT:
case GL_RIGHT:
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" );
return;
}
- ctx->Pixel.DriverReadBuffer = GL_FRONT_RIGHT;
+ ctx->Pixel._DriverReadBuffer = GL_FRONT_RIGHT;
break;
case GL_BACK_RIGHT:
if (!ctx->Visual.stereoMode || !ctx->Visual.doubleBufferMode) {
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadBuffer" );
return;
}
- ctx->Pixel.DriverReadBuffer = GL_BACK_RIGHT;
+ ctx->Pixel._DriverReadBuffer = GL_BACK_RIGHT;
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glReadBuffer" );
ctx->Pixel.ReadBuffer = mode;
ctx->NewState |= _NEW_PIXEL;
+
+ /*
+ * Call device driver function.
+ */
+ if (ctx->Driver.ReadBuffer)
+ (*ctx->Driver.ReadBuffer)(ctx, mode);
}
-/* $Id: colortab.c,v 1.44 2002/06/29 19:48:15 brianp Exp $ */
+/* $Id: colortab.c,v 1.45 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "mem.h"
#include "mmath.h"
#include "state.h"
-#include "swrast/s_span.h" /* XXX SWRAST hack */
#endif
-/* $Id: context.c,v 1.174 2002/06/29 19:48:15 brianp Exp $ */
+/* $Id: context.c,v 1.175 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
ctx->Color.ColorLogicOpEnabled = GL_FALSE;
ctx->Color.LogicOp = GL_COPY;
ctx->Color.DitherFlag = GL_TRUE;
- ctx->Color.MultiDrawBuffer = GL_FALSE;
/* Current group */
ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_WEIGHT], 0.0, 0.0, 0.0, 0.0 );
if (visual->doubleBufferMode) {
ctx->Color.DrawBuffer = GL_BACK;
- ctx->Color.DriverDrawBuffer = GL_BACK_LEFT;
- ctx->Color.DrawDestMask = BACK_LEFT_BIT;
+ ctx->Color._DriverDrawBuffer = GL_BACK_LEFT;
+ ctx->Color._DrawDestMask = BACK_LEFT_BIT;
ctx->Pixel.ReadBuffer = GL_BACK;
- ctx->Pixel.DriverReadBuffer = GL_BACK_LEFT;
+ ctx->Pixel._DriverReadBuffer = GL_BACK_LEFT;
}
else {
ctx->Color.DrawBuffer = GL_FRONT;
- ctx->Color.DriverDrawBuffer = GL_FRONT_LEFT;
- ctx->Color.DrawDestMask = FRONT_LEFT_BIT;
+ ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT;
+ ctx->Color._DrawDestMask = FRONT_LEFT_BIT;
ctx->Pixel.ReadBuffer = GL_FRONT;
- ctx->Pixel.DriverReadBuffer = GL_FRONT_LEFT;
+ ctx->Pixel._DriverReadBuffer = GL_FRONT_LEFT;
}
if (!alloc_proxy_textures(ctx)) {
_glapi_add_entrypoint("glCompressedTexSubImage2DARB", 558);
_glapi_add_entrypoint("glCompressedTexSubImage1DARB", 559);
_glapi_add_entrypoint("glGetCompressedTexImageARB", 560);
+ /* XXX we should add a bunch of new functions here */
+
/* Find the larger of Mesa's dispatch table and libGL's dispatch table.
* In practice, this'll be the same for stand-alone Mesa. But for DRI
-/* $Id: convolve.c,v 1.26 2002/03/19 15:22:50 brianp Exp $ */
+/* $Id: convolve.c,v 1.27 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "image.h"
#include "mtypes.h"
#include "state.h"
-#include "swrast/s_span.h" /* XXX SWRAST hack */
#endif
-/* $Id: dd.h,v 1.69 2002/06/15 02:38:15 brianp Exp $ */
+/* $Id: dd.h,v 1.70 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
*/
struct dd_function_table {
- /**********************************************************************
- *** Mandatory functions: these functions must be implemented by ***
- *** every device driver. ***
- **********************************************************************/
-
const GLubyte * (*GetString)( GLcontext *ctx, GLenum name );
/* Return a string as needed by glGetString().
* Only the GL_RENDERER token must be implemented. Otherwise,
* If 'all' is true then the clear the whole buffer, else clear only the
* region defined by (x,y,width,height).
* This function must obey the glColorMask, glIndexMask and glStencilMask
- * settings! Software Mesa can do masked clears if the device driver can't.
+ * settings!
+ * Software Mesa can do masked clears if the device driver can't.
*/
- void (*SetDrawBuffer)( GLcontext *ctx, GLenum buffer );
+ void (*DrawBuffer)( GLcontext *ctx, GLenum buffer );
/*
- * Specifies the current buffer for writing.
- * The following values must be accepted when applicable:
- * GL_FRONT_LEFT - this buffer always exists
- * GL_BACK_LEFT - when double buffering
- * GL_FRONT_RIGHT - when using stereo
- * GL_BACK_RIGHT - when using stereo and double buffering
- * GL_FRONT - write to front left and front right if it exists
- * GL_BACK - write to back left and back right if it exists
- * GL_LEFT - write to front left and back left if it exists
- * GL_RIGHT - write to right left and back right if they exist
- * GL_FRONT_AND_BACK - write to all four buffers if they exist
- * GL_NONE - disable buffer write in device driver.
- *
+ * Specifies the current buffer for writing. Called via glDrawBuffer().
* Note the driver must organize fallbacks (eg with swrast) if it
* cannot implement the requested mode.
*/
+
+ void (*ReadBuffer)( GLcontext *ctx, GLenum buffer );
+ /*
+ * Specifies the current buffer for reading. Called via glReadBuffer().
+ */
+
void (*GetBufferSize)( GLframebuffer *buffer,
GLuint *width, GLuint *height );
/*
void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat);
void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
-
/***
*** Vertex array functions
***
GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result);
GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result);
-
-
/***
*** Support for multiple t&l engines
***/
-/* $Id: get.c,v 1.86 2002/06/29 20:04:57 brianp Exp $ */
+/* $Id: get.c,v 1.87 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
static const char *renderer = "Mesa";
static const char *version_1_2 = "1.2 Mesa 4.1 beta";
static const char *version_1_3 = "1.3 Mesa 4.1 beta";
- static const char *version_1_4 = "1.4 Mesa 4.1 beta";
+ static const char *version_1_4 = "1.3 Mesa 4.1 beta"; /* change to 1.4 */
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
-/* $Id: macros.h,v 1.28 2002/06/12 00:52:50 brianp Exp $ */
+/* $Id: macros.h,v 1.29 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
#endif
-
-/*
- * Bitmask helpers
- */
-#define SET_BITS(WORD, BITS) (WORD) |= (BITS)
-#define CLEAR_BITS(WORD, BITS) (WORD) &= ~(BITS)
-#define TEST_BITS(WORD, BITS) ((WORD) & (BITS))
-
-
/* Stepping a GLfloat pointer by a byte stride
*/
#define STRIDE_F(p, i) (p = (GLfloat *)((GLubyte *)p + i))
-/* $Id: mtypes.h,v 1.83 2002/06/29 20:03:14 brianp Exp $ */
+/* $Id: mtypes.h,v 1.84 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLubyte ColorMask[4]; /* Each flag is 0xff or 0x0 */
GLenum DrawBuffer; /* Which buffer to draw into */
- GLenum DriverDrawBuffer; /* Current device driver dest buffer */
- GLboolean MultiDrawBuffer; /* Drawing to multiple buffers? */
- GLubyte DrawDestMask; /* bitwise-OR of bitflags above */
+ GLenum _DriverDrawBuffer; /* Single src/dst buffer for drivers */
+ GLubyte _DrawDestMask; /* bitwise-OR of bitflags above */
/* alpha testing */
GLboolean AlphaEnabled; /* Alpha test enabled flag */
struct gl_pixel_attrib {
GLenum ReadBuffer; /* src buffer for glRead/CopyPixels */
- GLenum DriverReadBuffer; /* Driver's current source buffer */
+ GLenum _DriverReadBuffer; /* Driver's current source buffer */
GLfloat RedBias, RedScale;
GLfloat GreenBias, GreenScale;
GLfloat BlueBias, BlueScale;
GLchan *BackLeftAlpha; /* array [Width*Height] of GLubyte */
GLchan *FrontRightAlpha; /* array [Width*Height] of GLubyte */
GLchan *BackRightAlpha; /* array [Width*Height] of GLubyte */
- GLchan *Alpha; /* Points to current alpha buffer */
/* Drawing bounds: intersection of window size and scissor box */
GLint _Xmin, _Ymin; /* inclusive */
};
-/* XXX just an idea */
+/*
+ * A stack of matrices (projection, modelview, color, texture, etc).
+ */
struct matrix_stack
{
GLmatrix *Top; /* points into Stack */
#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
+
/* A bunch of flags that we think might be useful to drivers.
+ * Set in the ctx->_TriangleCaps bitfield.
*/
#define DD_FLATSHADE 0x1
#define DD_SEPARATE_SPECULAR 0x2
#define DD_POINT_SIZE 0x1000
#define DD_POINT_ATTEN 0x2000
+
/* Define the state changes under which each of these bits might change
*/
#define _DD_NEW_FLATSHADE _NEW_LIGHT
-/* $Id: state.c,v 1.88 2002/06/30 15:47:01 brianp Exp $ */
+/* $Id: state.c,v 1.89 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
ASSERT(ctx->Driver.GetString);
ASSERT(ctx->Driver.UpdateState);
ASSERT(ctx->Driver.Clear);
- ASSERT(ctx->Driver.SetDrawBuffer);
ASSERT(ctx->Driver.GetBufferSize);
if (ctx->Visual.accumRedBits > 0) {
ASSERT(ctx->Driver.Accum);
-/* $Id: texformat.c,v 1.13 2002/06/29 19:48:16 brianp Exp $ */
+/* $Id: texformat.c,v 1.14 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "texformat.h"
#include "teximage.h"
#include "texstate.h"
-#include "swrast/s_span.h"
#endif
-/* $Id: teximage.c,v 1.110 2002/06/29 19:48:16 brianp Exp $ */
+/* $Id: teximage.c,v 1.111 2002/07/09 01:22:50 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "texstate.h"
#include "texstore.h"
#include "mtypes.h"
-#include "swrast/s_span.h" /* XXX SWRAST hack */
#endif
-/* $Id: s_accum.c,v 1.17 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: s_accum.c,v 1.18 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
if (value == 0.0F)
return;
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
+ _swrast_use_read_buffer(ctx);
/* May have to leave optimized accum buffer mode */
if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
}
}
/* restore read buffer = draw buffer (the default) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
+ _swrast_use_draw_buffer(ctx);
+
RENDER_FINISH(swrast,ctx);
break;
case GL_LOAD:
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
+ _swrast_use_read_buffer(ctx);
/* This is a change to go into optimized accum buffer mode */
if (value > 0.0 && value <= 1.0) {
}
/* restore read buffer = draw buffer (the default) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
+ _swrast_use_draw_buffer(ctx);
+
RENDER_FINISH(swrast,ctx);
break;
-/* $Id: s_alphabuf.c,v 1.10 2002/03/19 16:47:05 brianp Exp $ */
+/* $Id: s_alphabuf.c,v 1.11 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
#include "s_alphabuf.h"
-#define ALPHA_DRAW_ADDR(X,Y) \
- (ctx->DrawBuffer->Alpha + (Y) * ctx->DrawBuffer->Width + (X))
-
-#define ALPHA_READ_ADDR(X,Y) \
- (ctx->ReadBuffer->Alpha + (Y) * ctx->ReadBuffer->Width + (X))
-
-
/*
* Allocate a new front and back alpha buffer.
*/
void
_mesa_alloc_alpha_buffers( GLframebuffer *buffer )
{
- GET_CURRENT_CONTEXT(ctx);
const GLint bytes = buffer->Width * buffer->Height * sizeof(GLchan);
ASSERT(buffer->UseSoftwareAlphaBuffers);
}
}
}
-
- if (ctx) {
- if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT)
- buffer->Alpha = buffer->FrontLeftAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_BACK_LEFT)
- buffer->Alpha = buffer->BackLeftAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_FRONT_RIGHT)
- buffer->Alpha = buffer->FrontRightAlpha;
- else if (ctx->Color.DriverDrawBuffer == GL_BACK_RIGHT)
- buffer->Alpha = buffer->BackRightAlpha;
- }
}
/* loop over four possible alpha buffers */
for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) {
- if (bufferBit & ctx->Color.DrawDestMask) {
+ if (bufferBit & ctx->Color._DrawDestMask) {
GLchan *buffer;
if (bufferBit == FRONT_LEFT_BIT) {
buffer = ctx->DrawBuffer->FrontLeftAlpha;
+static INLINE
+GLchan *get_alpha_buffer( GLcontext *ctx )
+{
+ switch (ctx->Color._DriverDrawBuffer) {
+ case GL_FRONT_LEFT:
+ return ctx->DrawBuffer->FrontLeftAlpha;
+ break;
+ case GL_BACK_LEFT:
+ return ctx->DrawBuffer->BackLeftAlpha;
+ break;
+ case GL_FRONT_RIGHT:
+ return ctx->DrawBuffer->FrontRightAlpha;
+ break;
+ case GL_BACK_RIGHT:
+ return ctx->DrawBuffer->BackRightAlpha;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad DriverDrawBuffer in _mesa_write_alpha_span()");
+ return ctx->DrawBuffer->FrontLeftAlpha; /* aribitrary */
+ }
+}
+
+
void
_mesa_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
CONST GLchan rgba[][4], const GLubyte mask[] )
{
- GLchan *aptr = ALPHA_DRAW_ADDR( x, y );
+ GLchan *buffer, *aptr;
GLuint i;
+ buffer = get_alpha_buffer(ctx);
+ aptr = buffer + y * ctx->DrawBuffer->Width + x;
+
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
_mesa_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLchan alpha, const GLubyte mask[] )
{
- GLchan *aptr = ALPHA_DRAW_ADDR( x, y );
+ GLchan *buffer, *aptr;
GLuint i;
+ buffer = get_alpha_buffer(ctx);
+ aptr = buffer + y * ctx->DrawBuffer->Width + x;
+
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
GLuint n, const GLint x[], const GLint y[],
CONST GLchan rgba[][4], const GLubyte mask[] )
{
+ GLchan *buffer;
GLuint i;
+ buffer = get_alpha_buffer(ctx);
+
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
- GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] );
+ GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
*aptr = rgba[i][ACOMP];
}
}
}
else {
for (i=0;i<n;i++) {
- GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] );
+ GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
*aptr = rgba[i][ACOMP];
}
}
GLuint n, const GLint x[], const GLint y[],
GLchan alpha, const GLubyte mask[] )
{
+ GLchan *buffer;
GLuint i;
+ buffer = get_alpha_buffer(ctx);
+
if (mask) {
for (i=0;i<n;i++) {
if (mask[i]) {
- GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] );
+ GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
*aptr = alpha;
}
}
}
else {
for (i=0;i<n;i++) {
- GLchan *aptr = ALPHA_DRAW_ADDR( x[i], y[i] );
+ GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
*aptr = alpha;
}
}
_mesa_read_alpha_span( GLcontext *ctx,
GLuint n, GLint x, GLint y, GLchan rgba[][4] )
{
- GLchan *aptr = ALPHA_READ_ADDR( x, y );
+ const GLchan *buffer, *aptr;
GLuint i;
- for (i=0;i<n;i++) {
+
+ buffer = get_alpha_buffer(ctx);
+ aptr = buffer + y * ctx->DrawBuffer->Width + x;
+
+ for (i = 0; i < n; i++)
rgba[i][ACOMP] = *aptr++;
- }
}
GLuint n, const GLint x[], const GLint y[],
GLchan rgba[][4], const GLubyte mask[] )
{
+ const GLchan *buffer;
GLuint i;
- for (i=0;i<n;i++) {
+
+ buffer = get_alpha_buffer(ctx);
+
+ for (i = 0; i < n; i++) {
if (mask[i]) {
- GLchan *aptr = ALPHA_READ_ADDR( x[i], y[i] );
+ const GLchan *aptr = buffer + y[i] * ctx->DrawBuffer->Width + x[i];
rgba[i][ACOMP] = *aptr;
}
}
-/* $Id: s_buffers.c,v 1.11 2002/06/15 02:38:17 brianp Exp $ */
+/* $Id: s_buffers.c,v 1.12 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
/* loop over four possible dest color buffers */
for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) {
- if (bufferBit & ctx->Color.DrawDestMask) {
+ if (bufferBit & ctx->Color._DrawDestMask) {
if (bufferBit == FRONT_LEFT_BIT) {
- (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
}
else if (bufferBit == FRONT_RIGHT_BIT) {
- (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
}
else if (bufferBit == BACK_LEFT_BIT) {
- (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_LEFT);
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_LEFT);
}
else {
- (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
}
if (colorMask != 0xffffffff) {
}
}
- /* restore default read/draw buffers */
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer );
- (void) (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer );
+ /* restore default read/draw buffer */
+ _swrast_use_draw_buffer(ctx);
}
/* do software clearing here */
if (mask) {
- if (mask & ctx->Color.DrawDestMask) clear_color_buffers(ctx);
+ if (mask & ctx->Color._DrawDestMask) clear_color_buffers(ctx);
if (mask & GL_DEPTH_BUFFER_BIT) _mesa_clear_depth_buffer(ctx);
if (mask & GL_ACCUM_BUFFER_BIT) _mesa_clear_accum_buffer(ctx);
if (mask & GL_STENCIL_BUFFER_BIT) _mesa_clear_stencil_buffer(ctx);
_mesa_alloc_alpha_buffers( buffer );
}
}
+
+
+/*
+ * Fallback for ctx->Driver.DrawBuffer()
+ */
+void
+_swrast_DrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ _swrast_use_draw_buffer(ctx);
+}
+
+
+/*
+ * Setup things so that we read/write spans from the user-designated
+ * read buffer (set via glReadPixels). We usually just have to call
+ * this for glReadPixels, glCopyPixels, etc.
+ */
+void
+_swrast_use_read_buffer( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ /* Do this so the software-emulated alpha plane span functions work! */
+ ctx->Color._DriverDrawBuffer = ctx->Pixel._DriverReadBuffer;
+ /* Tell the device driver where to read/write spans */
+ (*swrast->Driver.SetBuffer)( ctx, ctx->ReadBuffer,
+ ctx->Pixel._DriverReadBuffer );
+}
+
+
+/*
+ * Setup things so that we read/write spans from the default draw buffer.
+ * This is the usual mode that Mesa's software rasterizer operates in.
+ */
+void
+_swrast_use_draw_buffer( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ /* The user can specify rendering to zero, one, two, or four color
+ * buffers simultaneously with glDrawBuffer()!
+ * We don't expect the span/point/line/triangle functions to deal with
+ * that mess so we'll iterate over the multiple buffers as needed.
+ * But usually we only render to one color buffer at a time.
+ * We set ctx->Color._DriverDrawBuffer to that buffer and tell the
+ * device driver to use that buffer.
+ * Look in s_span.c's multi_write_rgba_span() function to see how
+ * we loop over multiple color buffers when needed.
+ */
+
+ if (ctx->Color._DrawDestMask & FRONT_LEFT_BIT)
+ ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT;
+ else if (ctx->Color._DrawDestMask & BACK_LEFT_BIT)
+ ctx->Color._DriverDrawBuffer = GL_BACK_LEFT;
+ else if (ctx->Color._DrawDestMask & FRONT_RIGHT_BIT)
+ ctx->Color._DriverDrawBuffer = GL_FRONT_RIGHT;
+ else if (ctx->Color._DrawDestMask & BACK_RIGHT_BIT)
+ ctx->Color._DriverDrawBuffer = GL_BACK_RIGHT;
+ else
+ /* glDrawBuffer(GL_NONE) */
+ ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT; /* always have this */
+
+ (*swrast->Driver.SetBuffer)( ctx, ctx->DrawBuffer,
+ ctx->Color._DriverDrawBuffer );
+}
-/* $Id: s_context.c,v 1.35 2002/06/15 03:03:11 brianp Exp $ */
+/* $Id: s_context.c,v 1.36 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
* MULTI_DRAW_BIT flag. Also set it if we're drawing to no
* buffers or the RGBA or CI mask disables all writes.
*/
- if (ctx->Color.DrawBuffer == GL_FRONT_AND_BACK ||
- ctx->Color.DrawBuffer == GL_NONE) {
+ if (ctx->Color._DrawDestMask != FRONT_LEFT_BIT &&
+ ctx->Color._DrawDestMask != BACK_LEFT_BIT &&
+ ctx->Color._DrawDestMask != FRONT_RIGHT_BIT &&
+ ctx->Color._DrawDestMask != BACK_RIGHT_BIT) {
+ /* more than one color buffer designated for writing (or zero buffers) */
RasterMask |= MULTI_DRAW_BIT;
}
else if (ctx->Visual.rgbMode && *((GLuint *) ctx->Color.ColorMask) == 0) {
-/* $Id: s_copypix.c,v 1.38 2002/06/15 03:03:11 brianp Exp $ */
+/* $Id: s_copypix.c,v 1.39 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLboolean quick_draw;
GLint row;
GLboolean changeBuffer;
- GLchan *saveReadAlpha;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
const GLuint transferOps = ctx->_ImageTransferState;
GLfloat *dest, *tmpImage, *convImage;
}
/* If read and draw buffer are different we must do buffer switching */
- saveReadAlpha = ctx->ReadBuffer->Alpha;
changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer
|| ctx->DrawBuffer != ctx->ReadBuffer;
dest = tmpImage;
if (changeBuffer) {
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
- if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT)
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontLeftAlpha;
- else if (ctx->Pixel.DriverReadBuffer == GL_BACK_LEFT)
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackLeftAlpha;
- else if (ctx->Pixel.DriverReadBuffer == GL_FRONT_RIGHT)
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontRightAlpha;
- else
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackRightAlpha;
+ /* choose the read buffer */
+ _swrast_use_read_buffer(ctx);
}
/* read source image */
}
}
- /* read from the draw buffer again (in case of blending) */
if (changeBuffer) {
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
- ctx->ReadBuffer->Alpha = saveReadAlpha;
+ /* restore default src/dst buffer */
+ _swrast_use_draw_buffer(ctx);
}
/* do image transfer ops up until convolution */
GLboolean quick_draw;
GLint sy, dy, stepy, j;
GLboolean changeBuffer;
- GLchan *saveReadAlpha;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
GLint overlapping;
const GLuint transferOps = ctx->_ImageTransferState;
}
/* If read and draw buffer are different we must do buffer switching */
- saveReadAlpha = ctx->ReadBuffer->Alpha;
changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer
|| ctx->DrawBuffer != ctx->ReadBuffer;
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
-
if (overlapping) {
GLint ssy = sy;
tmpImage = (GLchan *) MALLOC(width * height * sizeof(GLchan) * 4);
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
return;
}
+ /* setup source */
+ if (changeBuffer)
+ _swrast_use_read_buffer(ctx);
+ /* read the source image */
p = tmpImage;
- if (changeBuffer) {
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
- if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT)
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontLeftAlpha;
- else if (ctx->Pixel.DriverReadBuffer == GL_BACK_LEFT)
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackLeftAlpha;
- else if (ctx->Pixel.DriverReadBuffer == GL_FRONT_RIGHT)
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontRightAlpha;
- else
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackRightAlpha;
- }
for (j = 0; j < height; j++, ssy += stepy) {
_mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, ssy,
(GLchan (*)[4]) p );
p += width * 4;
}
p = tmpImage;
+ /* restore dest */
+ if (changeBuffer) {
+ _swrast_use_draw_buffer(ctx);
+ changeBuffer = GL_FALSE;
+ }
}
else {
tmpImage = NULL; /* silence compiler warnings */
}
else {
/* get from framebuffer */
- if (changeBuffer) {
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
- if (ctx->Pixel.DriverReadBuffer == GL_FRONT_LEFT) {
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontLeftAlpha;
- }
- else if (ctx->Pixel.DriverReadBuffer == GL_BACK_LEFT) {
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackLeftAlpha;
- }
- else if (ctx->Pixel.DriverReadBuffer == GL_FRONT_RIGHT) {
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->FrontRightAlpha;
- }
- else {
- ctx->ReadBuffer->Alpha = ctx->ReadBuffer->BackRightAlpha;
- }
- }
- _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, sy, span->color.rgba );
- }
-
- if (changeBuffer) {
- /* read from the draw buffer again (in case of blending) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
- ctx->ReadBuffer->Alpha = saveReadAlpha;
+ if (changeBuffer)
+ _swrast_use_read_buffer(ctx);
+ _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, sy,
+ span->color.rgba );
+ if (changeBuffer)
+ _swrast_use_draw_buffer(ctx);
}
if (transferOps) {
}
}
- /* Restore pixel source to be the draw buffer (for blending, etc) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
-
if (overlapping)
FREE(tmpImage);
}
changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer
|| ctx->DrawBuffer != ctx->ReadBuffer;
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
-
if (overlapping) {
GLint ssy = sy;
tmpImage = (GLuint *) MALLOC(width * height * sizeof(GLuint));
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
return;
}
+ /* setup source */
+ if (changeBuffer)
+ _swrast_use_read_buffer(ctx);
+ /* read the image */
p = tmpImage;
- if (changeBuffer) {
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
- }
for (j = 0; j < height; j++, ssy += stepy) {
_mesa_read_index_span( ctx, ctx->ReadBuffer, width, srcx, ssy, p );
p += width;
}
p = tmpImage;
+ /* restore to draw buffer */
+ if (changeBuffer) {
+ _swrast_use_draw_buffer(ctx);
+ changeBuffer = GL_FALSE;
+ }
}
else {
tmpImage = NULL; /* silence compiler warning */
p += width;
}
else {
- if (changeBuffer) {
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
- }
+ if (changeBuffer)
+ _swrast_use_read_buffer(ctx);
_mesa_read_index_span( ctx, ctx->ReadBuffer, width, srcx, sy,
span->color.index );
- }
-
- if (changeBuffer) {
- /* set read buffer back to draw buffer (in case of logicops) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
+ if (changeBuffer)
+ _swrast_use_draw_buffer(ctx);
}
if (shift_or_offset) {
_mesa_write_index_span(ctx, span);
}
- /* Restore pixel source to be the draw buffer (for blending, etc) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
-
if (overlapping)
FREE(tmpImage);
}
-/* $Id: s_imaging.c,v 1.5 2002/04/04 16:53:00 brianp Exp $ */
+/* $Id: s_imaging.c,v 1.6 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLenum target, GLenum internalformat,
GLint x, GLint y, GLsizei width)
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan data[MAX_WIDTH][4];
/* Select buffer to read from */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
+ _swrast_use_read_buffer(ctx);
if (width > MAX_WIDTH)
width = MAX_WIDTH;
_mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
/* Restore reading from draw buffer (the default) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
+ _swrast_use_draw_buffer(ctx);
glColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data);
}
_swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
GLint x, GLint y, GLsizei width)
{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan data[MAX_WIDTH][4];
/* Select buffer to read from */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
+ _swrast_use_read_buffer(ctx);
if (width > MAX_WIDTH)
width = MAX_WIDTH;
_mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
/* Restore reading from draw buffer (the default) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
+ _swrast_use_draw_buffer(ctx);
glColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data);
}
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan rgba[MAX_CONVOLUTION_WIDTH][4];
+ /* Select buffer to read from */
+ _swrast_use_read_buffer(ctx);
+
RENDER_START( swrast, ctx );
/* read the data from framebuffer */
RENDER_FINISH( swrast, ctx );
+ /* Restore reading from draw buffer (the default) */
+ _swrast_use_draw_buffer(ctx);
+
/* store as convolution filter */
glConvolutionFilter1D(target, internalFormat, width,
GL_RGBA, CHAN_TYPE, rgba);
GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4];
GLint i;
+ /* Select buffer to read from */
+ _swrast_use_read_buffer(ctx);
+
RENDER_START(swrast,ctx);
/* read pixels from framebuffer */
RENDER_FINISH(swrast,ctx);
+ /* Restore reading from draw buffer (the default) */
+ _swrast_use_draw_buffer(ctx);
+
/*
* HACK: save & restore context state so we can store this as a
* convolution filter via the GL api. Doesn't call any callbacks
-/* $Id: s_readpix.c,v 1.14 2002/04/19 00:38:27 brianp Exp $ */
+/* $Id: s_readpix.c,v 1.15 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
return;
}
- ASSERT(swrast->Driver.SetReadBuffer);
- (*swrast->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer);
+ _swrast_use_read_buffer(ctx);
readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
&ctx->Pack, ctx->_ImageTransferState);
}
- (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer);
+ _swrast_use_draw_buffer(ctx);
}
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLint readWidth;
- (*swrast->Driver.SetReadBuffer)(ctx, ctx->ReadBuffer, ctx->Pixel.DriverReadBuffer);
+ _swrast_use_read_buffer(ctx);
/* Try optimized path first */
if (read_fast_rgba_pixels( ctx, x, y, width, height,
format, type, pixels, packing )) {
- (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
+ _swrast_use_draw_buffer(ctx);
return; /* done! */
}
}
}
- (*swrast->Driver.SetReadBuffer)(ctx, ctx->DrawBuffer, ctx->Color.DriverDrawBuffer);
+ _swrast_use_draw_buffer(ctx);
}
-/* $Id: s_span.c,v 1.44 2002/06/15 03:03:11 brianp Exp $ */
+/* $Id: s_span.c,v 1.45 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLuint bufferBit;
/* loop over four possible dest color buffers */
- for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) {
- if (bufferBit & ctx->Color.DrawDestMask) {
+ for (bufferBit = 1; bufferBit <= 8; bufferBit <<= 1) {
+ if (bufferBit & ctx->Color._DrawDestMask) {
GLuint indexTmp[MAX_WIDTH];
ASSERT(span->end < MAX_WIDTH);
if (bufferBit == FRONT_LEFT_BIT)
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
else if (bufferBit == FRONT_RIGHT_BIT)
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
else if (bufferBit == BACK_LEFT_BIT)
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_LEFT);
else
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
/* make copy of incoming indexes */
MEMCPY( indexTmp, span->color.index, span->end * sizeof(GLuint) );
}
/* restore default dest buffer */
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer);
+ _swrast_use_draw_buffer(ctx);
}
return;
/* loop over four possible dest color buffers */
- for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) {
- if (bufferBit & ctx->Color.DrawDestMask) {
+ for (bufferBit = 1; bufferBit <= 8; bufferBit <<= 1) {
+ if (bufferBit & ctx->Color._DrawDestMask) {
GLchan rgbaTmp[MAX_WIDTH][4];
ASSERT(span->end < MAX_WIDTH);
if (bufferBit == FRONT_LEFT_BIT) {
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_LEFT);
- ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontLeftAlpha;
+ ctx->Color._DriverDrawBuffer = GL_FRONT_LEFT;
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_LEFT);
}
else if (bufferBit == FRONT_RIGHT_BIT) {
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_FRONT_RIGHT);
- ctx->DrawBuffer->Alpha = ctx->DrawBuffer->FrontRightAlpha;
+ ctx->Color._DriverDrawBuffer = GL_FRONT_RIGHT;
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_FRONT_RIGHT);
}
else if (bufferBit == BACK_LEFT_BIT) {
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_LEFT);
- ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackLeftAlpha;
+ ctx->Color._DriverDrawBuffer = GL_BACK_LEFT;
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_LEFT);
}
else {
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, GL_BACK_RIGHT);
- ctx->DrawBuffer->Alpha = ctx->DrawBuffer->BackRightAlpha;
+ ctx->Color._DriverDrawBuffer = GL_BACK_RIGHT;
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, GL_BACK_RIGHT);
}
/* make copy of incoming colors */
}
/* restore default dest buffer */
- (void) (*ctx->Driver.SetDrawBuffer)( ctx, ctx->Color.DriverDrawBuffer );
+ _swrast_use_draw_buffer(ctx);
}
-/* $Id: s_texstore.c,v 1.5 2001/05/21 16:41:04 brianp Exp $ */
+/* $Id: s_texstore.c,v 1.6 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
return NULL;
/* Select buffer to read from */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
+ _swrast_use_read_buffer(ctx);
RENDER_START(swrast,ctx);
RENDER_FINISH(swrast,ctx);
/* Read from draw buffer (the default) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
+ _swrast_use_draw_buffer(ctx);
return image;
}
-/* $Id: s_triangle.c,v 1.59 2002/06/15 03:03:12 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.60 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
span->intTex[1] += span->intTexStep[1]; \
} \
(*swrast->Driver.WriteRGBSpan)(ctx, span->end, span->x, span->y, \
- (CONST GLchan (*)[3]) span->color.rgb, \
+ (CONST GLchan (*)[3]) span->color.rgb,\
NULL );
#include "s_tritemp.h"
span->z += span->zStep; \
} \
(*swrast->Driver.WriteRGBSpan)(ctx, span->end, span->x, span->y, \
- (CONST GLchan (*)[3]) span->color.rgb, \
+ (CONST GLchan (*)[3]) span->color.rgb,\
span->mask );
#include "s_tritemp.h"
info.format = obj->Image[b]->Format; \
info.filter = obj->MinFilter; \
info.envmode = unit->EnvMode; \
- span->arrayMask |= SPAN_RGBA; \
+ span->arrayMask |= SPAN_RGBA; \
\
if (info.envmode == GL_BLEND) { \
/* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \
#define RENDER_SPAN( span ) \
span->interpMask &= ~SPAN_RGBA; \
- span->arrayMask |= SPAN_RGBA; \
+ span->arrayMask |= SPAN_RGBA; \
fast_persp_span(ctx, span, &info);
#include "s_tritemp.h"
#define RENDER_SPAN( span ) \
GLuint i; \
for (i = 0; i < span->end; i++) { \
- GLdepth z = FixedToDepth(span->z); \
+ GLdepth z = FixedToDepth(span->z); \
if (z < zRow[i]) { \
ctx->OcclusionResult = GL_TRUE; \
return; \
-/* $Id: swrast.h,v 1.24 2002/04/19 14:05:50 brianp Exp $ */
+/* $Id: swrast.h,v 1.25 2002/07/09 01:22:52 brianp Exp $ */
/*
* Mesa 3-D graphics library
extern void
_swrast_alloc_buffers( GLframebuffer *buffer );
+extern void
+_swrast_use_read_buffer( GLcontext *ctx );
+
+extern void
+_swrast_use_draw_buffer( GLcontext *ctx );
+
extern GLboolean
_swrast_CreateContext( GLcontext *ctx );
GLint width, GLint height );
+extern void
+_swrast_DrawBuffer( GLcontext *ctx, GLenum mode );
+
+
/* Reset the stipple counter
*/
extern void
*/
struct swrast_device_driver {
- void (*SetReadBuffer)( GLcontext *ctx, GLframebuffer *colorBuffer,
- GLenum buffer );
+ void (*SetBuffer)( GLcontext *ctx, GLframebuffer *buffer,
+ GLenum colorBuffer );
/*
- * Specifies the current buffer for span/pixel reading.
- * colorBuffer will be one of:
+ * Specifies the current buffer for span/pixel writing/reading.
+ * buffer indicates which window to write to / read from. Normally,
+ * this'll be the buffer currently bound to the context, but it doesn't
+ * have to be!
+ * colorBuffer indicates which color buffer, one of:
* GL_FRONT_LEFT - this buffer always exists
* GL_BACK_LEFT - when double buffering
* GL_FRONT_RIGHT - when using stereo