summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/x11/xmesaP.h12
-rw-r--r--src/mesa/main/accum.c82
-rw-r--r--src/mesa/main/blend.c6
-rw-r--r--src/mesa/main/context.c67
-rw-r--r--src/mesa/main/context.h5
-rw-r--r--src/mesa/main/depth.c34
-rw-r--r--src/mesa/main/depth.h4
-rw-r--r--src/mesa/main/drawpix.c56
-rw-r--r--src/mesa/main/matrix.c6
-rw-r--r--src/mesa/main/stencil.c47
-rw-r--r--src/mesa/main/teximage.c7
11 files changed, 176 insertions, 150 deletions
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 4dc8425c102..491e2fdc987 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -1,8 +1,8 @@
-/* $Id: xmesaP.h,v 1.2 1999/10/08 09:27:12 keithw Exp $ */
+/* $Id: xmesaP.h,v 1.3 1999/11/24 18:49:44 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.1
+ * Version: 3.3
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -23,9 +23,6 @@
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/X/xmesaP.h,v 1.5 1999/07/06 14:51:28 dawes Exp $ */
-
-
#ifndef XMESAP_H
@@ -39,7 +36,7 @@
# ifdef GLX_DIRECT_RENDERING
# include "dri_mesa.h"
# endif
-# ifdef SHM
+# ifdef USE_XSHM
# include <X11/extensions/XShm.h>
# endif
#endif
@@ -127,6 +124,7 @@ struct xmesa_context {
GLcontext *gl_ctx; /* the core library context */
XMesaVisual xm_visual; /* Describes the buffers */
XMesaBuffer xm_buffer; /* current framebuffer */
+ XMesaBuffer xm_read_buffer; /* current framebuffer */
XMesaDisplay *display; /* == xm_visual->display */
GLboolean swapbytes; /* Host byte order != display byte order? */
@@ -179,7 +177,7 @@ struct xmesa_buffer {
/* 0 = not available */
/* 1 = XImage support available */
/* 2 = Pixmap support available too */
-#ifdef SHM
+#ifdef USE_XSHM
XShmSegmentInfo shminfo;
#endif
#endif
diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index 1e8cce0ec34..8e6f3cae0ff 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -1,8 +1,8 @@
-/* $Id: accum.c,v 1.11 1999/11/11 01:22:25 brianp Exp $ */
+/* $Id: accum.c,v 1.12 1999/11/24 18:48:30 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.1
+ * Version: 3.3
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -70,15 +70,15 @@ void gl_alloc_accum_buffer( GLcontext *ctx )
{
GLint n;
- if (ctx->Buffer->Accum) {
- FREE( ctx->Buffer->Accum );
- ctx->Buffer->Accum = NULL;
+ if (ctx->DrawBuffer->Accum) {
+ FREE( ctx->DrawBuffer->Accum );
+ ctx->DrawBuffer->Accum = NULL;
}
/* allocate accumulation buffer if not already present */
- n = ctx->Buffer->Width * ctx->Buffer->Height * 4 * sizeof(GLaccum);
- ctx->Buffer->Accum = (GLaccum *) MALLOC( n );
- if (!ctx->Buffer->Accum) {
+ n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4 * sizeof(GLaccum);
+ ctx->DrawBuffer->Accum = (GLaccum *) MALLOC( n );
+ if (!ctx->DrawBuffer->Accum) {
/* unable to setup accumulation buffer */
gl_error( ctx, GL_OUT_OF_MEMORY, "glAccum" );
}
@@ -113,10 +113,10 @@ _mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
*/
static void rescale_accum( GLcontext *ctx )
{
- const GLuint n = ctx->Buffer->Width * ctx->Buffer->Height * 4;
+ const GLuint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * 4;
const GLfloat fChanMax = (1 << (sizeof(GLchan) * 8)) - 1;
const GLfloat s = ctx->IntegerAccumScaler * (32767.0 / fChanMax);
- GLaccum *accum = ctx->Buffer->Accum;
+ GLaccum *accum = ctx->DrawBuffer->Accum;
GLuint i;
assert(ctx->IntegerAccumMode);
@@ -143,9 +143,13 @@ _mesa_Accum( GLenum op, GLfloat value )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glAccum");
- if (ctx->Visual->AccumBits==0 || !ctx->Buffer->Accum) {
- /* No accumulation buffer! */
- gl_warning(ctx, "Calling glAccum() without an accumulation buffer");
+ if (ctx->Visual->AccumBits == 0 || ctx->DrawBuffer != ctx->ReadBuffer) {
+ gl_error(ctx, GL_INVALID_OPERATION, "glAccum");
+ return;
+ }
+
+ if (!ctx->DrawBuffer->Accum) {
+ gl_warning(ctx, "Calling glAccum() without an accumulation buffer (low memory?)");
return;
}
@@ -174,8 +178,8 @@ _mesa_Accum( GLenum op, GLfloat value )
/* whole window */
xpos = 0;
ypos = 0;
- width = ctx->Buffer->Width;
- height = ctx->Buffer->Height;
+ width = ctx->DrawBuffer->Width;
+ height = ctx->DrawBuffer->Height;
}
width4 = 4 * width;
@@ -189,7 +193,7 @@ _mesa_Accum( GLenum op, GLfloat value )
if (ctx->IntegerAccumMode)
rescale_accum(ctx);
for (j = 0; j < height; j++) {
- GLaccum * acc = ctx->Buffer->Accum + ypos * width4 + 4 * xpos;
+ GLaccum * acc = ctx->DrawBuffer->Accum + ypos * width4 + 4 * xpos;
GLuint i;
for (i = 0; i < width4; i++) {
acc[i] += intVal;
@@ -206,7 +210,7 @@ _mesa_Accum( GLenum op, GLfloat value )
if (ctx->IntegerAccumMode)
rescale_accum(ctx);
for (j = 0; j < height; j++) {
- GLaccum *acc = ctx->Buffer->Accum + ypos * width4 + 4 * xpos;
+ GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + 4 * xpos;
GLuint i;
for (i = 0; i < width4; i++) {
acc[i] = (GLaccum) ( (GLfloat) acc[i] * value );
@@ -228,13 +232,13 @@ _mesa_Accum( GLenum op, GLfloat value )
if (ctx->IntegerAccumMode) {
/* simply add integer color values into accum buffer */
GLuint j;
- GLaccum *acc = ctx->Buffer->Accum + ypos * width4 + xpos * 4;
+ GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
assert(ctx->IntegerAccumScaler > 0.0);
assert(ctx->IntegerAccumScaler <= 1.0);
for (j = 0; j < height; j++) {
GLuint i, i4;
- gl_read_rgba_span(ctx, width, xpos, ypos, rgba);
+ gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
for (i = i4 = 0; i < width; i++, i4+=4) {
acc[i4+0] += rgba[i][RCOMP];
acc[i4+1] += rgba[i][GCOMP];
@@ -253,9 +257,9 @@ _mesa_Accum( GLenum op, GLfloat value )
const GLfloat ascale = value * acc_scale / fChanMax;
GLuint j;
for (j=0;j<height;j++) {
- GLaccum *acc = ctx->Buffer->Accum + ypos * width4 + xpos * 4;
+ GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
GLuint i;
- gl_read_rgba_span(ctx, width, xpos, ypos, rgba);
+ gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
for (i=0;i<width;i++) {
*acc += (GLaccum) ( (GLfloat) rgba[i][RCOMP] * rscale ); acc++;
*acc += (GLaccum) ( (GLfloat) rgba[i][GCOMP] * gscale ); acc++;
@@ -288,12 +292,12 @@ _mesa_Accum( GLenum op, GLfloat value )
if (ctx->IntegerAccumMode) {
/* just copy values into accum buffer */
GLuint j;
- GLaccum *acc = ctx->Buffer->Accum + ypos * width4 + xpos * 4;
+ GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
assert(ctx->IntegerAccumScaler > 0.0);
assert(ctx->IntegerAccumScaler <= 1.0);
for (j = 0; j < height; j++) {
GLuint i, i4;
- gl_read_rgba_span(ctx, width, xpos, ypos, rgba);
+ gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
for (i = i4 = 0; i < width; i++, i4 += 4) {
acc[i4+0] = rgba[i][RCOMP];
acc[i4+1] = rgba[i][GCOMP];
@@ -313,8 +317,8 @@ _mesa_Accum( GLenum op, GLfloat value )
const GLfloat d = 3.0 / acc_scale;
GLuint i, j;
for (j = 0; j < height; j++) {
- GLaccum *acc = ctx->Buffer->Accum + ypos * width4 + xpos * 4;
- gl_read_rgba_span(ctx, width, xpos, ypos, rgba);
+ GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos * 4;
+ gl_read_rgba_span(ctx, ctx->DrawBuffer, width, xpos, ypos, rgba);
for (i=0;i<width;i++) {
*acc++ = (GLaccum) ((GLfloat) rgba[i][RCOMP] * rscale + d);
*acc++ = (GLaccum) ((GLfloat) rgba[i][GCOMP] * gscale + d);
@@ -349,7 +353,7 @@ _mesa_Accum( GLenum op, GLfloat value )
assert(ctx->IntegerAccumScaler > 0.0);
assert(ctx->IntegerAccumScaler <= 1.0);
for (j = 0; j < height; j++) {
- const GLaccum *acc = ctx->Buffer->Accum + ypos * width4 + xpos*4;
+ const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
GLuint i, i4;
for (i = i4 = 0; i < width; i++, i4 += 4) {
ASSERT(acc[i4+0] < max);
@@ -376,7 +380,7 @@ _mesa_Accum( GLenum op, GLfloat value )
const GLfloat ascale = value / acc_scale * fChanMax;
GLuint i, j;
for (j=0;j<height;j++) {
- const GLaccum *acc = ctx->Buffer->Accum + ypos * width4 + xpos*4;
+ const GLaccum *acc = ctx->DrawBuffer->Accum + ypos * width4 + xpos*4;
for (i=0;i<width;i++) {
GLint r, g, b, a;
r = (GLint) ( (GLfloat) (*acc++) * rscale + 0.5F );
@@ -430,15 +434,15 @@ void gl_clear_accum_buffer( GLcontext *ctx )
}
/* number of pixels */
- buffersize = ctx->Buffer->Width * ctx->Buffer->Height;
+ buffersize = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
- if (!ctx->Buffer->Accum) {
+ if (!ctx->DrawBuffer->Accum) {
/* try to alloc accumulation buffer */
- ctx->Buffer->Accum = (GLaccum *)
+ ctx->DrawBuffer->Accum = (GLaccum *)
MALLOC( buffersize * 4 * sizeof(GLaccum) );
}
- if (ctx->Buffer->Accum) {
+ if (ctx->DrawBuffer->Accum) {
if (ctx->Scissor.Enabled) {
/* Limit clear to scissor box */
GLaccum r, g, b, a;
@@ -450,12 +454,12 @@ void gl_clear_accum_buffer( GLcontext *ctx )
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
a = (GLaccum) (ctx->Accum.ClearColor[3] * acc_scale);
/* size of region to clear */
- width = 4 * (ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1);
- height = ctx->Buffer->Ymax - ctx->Buffer->Ymin + 1;
+ width = 4 * (ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin + 1);
+ height = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin + 1;
/* ptr to first element to clear */
- row = ctx->Buffer->Accum
- + 4 * (ctx->Buffer->Ymin * ctx->Buffer->Width
- + ctx->Buffer->Xmin);
+ row = ctx->DrawBuffer->Accum
+ + 4 * (ctx->DrawBuffer->Ymin * ctx->DrawBuffer->Width
+ + ctx->DrawBuffer->Xmin);
for (j=0;j<height;j++) {
for (i=0;i<width;i+=4) {
row[i+0] = r;
@@ -463,7 +467,7 @@ void gl_clear_accum_buffer( GLcontext *ctx )
row[i+2] = b;
row[i+3] = a;
}
- row += 4 * ctx->Buffer->Width;
+ row += 4 * ctx->DrawBuffer->Width;
}
}
else {
@@ -473,14 +477,14 @@ void gl_clear_accum_buffer( GLcontext *ctx )
ctx->Accum.ClearColor[2]==0.0 &&
ctx->Accum.ClearColor[3]==0.0) {
/* Black */
- MEMSET( ctx->Buffer->Accum, 0, buffersize * 4 * sizeof(GLaccum) );
+ MEMSET( ctx->DrawBuffer->Accum, 0, buffersize * 4 * sizeof(GLaccum) );
}
else {
/* Not black */
GLaccum *acc, r, g, b, a;
GLuint i;
- acc = ctx->Buffer->Accum;
+ acc = ctx->DrawBuffer->Accum;
r = (GLaccum) (ctx->Accum.ClearColor[0] * acc_scale);
g = (GLaccum) (ctx->Accum.ClearColor[1] * acc_scale);
b = (GLaccum) (ctx->Accum.ClearColor[2] * acc_scale);
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 0790d65256c..e042945d2c9 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -1,8 +1,8 @@
-/* $Id: blend.c,v 1.9 1999/11/12 04:56:55 kendallb Exp $ */
+/* $Id: blend.c,v 1.10 1999/11/24 18:48:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 3.1
+ * Version: 3.3
*
* Copyright (C) 1999 Brian Paul All Rights Reserved.
*
@@ -782,7 +782,7 @@ void gl_blend_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
}
/* Read span of current frame buffer pixels */
- gl_read_rgba_span( ctx, n, x, y, dest );
+ gl_read_rgba_span( ctx, ctx->DrawBuffer, n, x, y, dest );
if (!ctx->Color.BlendFunc)
set_blend_function(ctx);
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index a7fbddcbdb2..e41afe15cee 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.22 1999/11/19 22:51:29 brianp Exp $ */
+/* $Id: context.c,v 1.23 1999/11/24 18:48:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1204,7 +1204,8 @@ GLcontext *gl_create_context( GLvisual *visual,
ctx->DriverCtx = driver_ctx;
ctx->Visual = visual;
- ctx->Buffer = NULL;
+ ctx->DrawBuffer = NULL;
+ ctx->ReadBuffer = NULL;
ctx->VB = gl_vb_create_for_immediate( ctx );
if (!ctx->VB) {
@@ -1479,6 +1480,17 @@ void gl_destroy_framebuffer( GLframebuffer *buffer )
*/
void gl_make_current( GLcontext *newCtx, GLframebuffer *buffer )
{
+ gl_make_current2( newCtx, buffer, buffer );
+}
+
+
+/*
+ * Bind the given context to the given draw-buffer and read-buffer
+ * and make it the current context for this thread.
+ */
+void gl_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer )
+{
GET_CURRENT_CONTEXT(oldCtx);
/* Flush the old context
@@ -1487,9 +1499,12 @@ void gl_make_current( GLcontext *newCtx, GLframebuffer *buffer )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(oldCtx, "gl_make_current");
}
- if (oldCtx && oldCtx->Buffer) {
- /* unbind frame buffer from context */
- oldCtx->Buffer = NULL;
+ /* unbind frame buffers from context */
+ if (oldCtx && oldCtx->DrawBuffer) {
+ oldCtx->DrawBuffer = NULL;
+ }
+ if (oldCtx && oldCtx->ReadBuffer) {
+ oldCtx->ReadBuffer = NULL;
}
#ifdef THREADS
@@ -1509,15 +1524,17 @@ void gl_make_current( GLcontext *newCtx, GLframebuffer *buffer )
if (MESA_VERBOSE) fprintf(stderr, "gl_make_current()\n");
- if (newCtx && buffer) {
+ if (newCtx && drawBuffer && readBuffer) {
/* TODO: check if newCtx and buffer's visual match??? */
- newCtx->Buffer = buffer; /* Bind the frame buffer to the context */
+ newCtx->DrawBuffer = drawBuffer;
+ newCtx->ReadBuffer = readBuffer;
newCtx->NewState = NEW_ALL; /* just to be safe */
gl_update_state( newCtx );
}
}
+
/*
* Return current context handle for the calling thread.
*/
@@ -1648,15 +1665,15 @@ _mesa_ResizeBuffersMESA( void )
(*ctx->Driver.GetBufferSize)( ctx, &buf_width, &buf_height );
/* see if size of device driver's color buffer (window) has changed */
- if (ctx->Buffer->Width == (GLint) buf_width &&
- ctx->Buffer->Height == (GLint) buf_height)
+ if (ctx->DrawBuffer->Width == (GLint) buf_width &&
+ ctx->DrawBuffer->Height == (GLint) buf_height)
return;
ctx->NewState |= NEW_RASTER_OPS; /* to update scissor / window bounds */
/* save buffer size */
- ctx->Buffer->Width = buf_width;
- ctx->Buffer->Height = buf_height;
+ ctx->DrawBuffer->Width = buf_width;
+ ctx->DrawBuffer->Height = buf_height;
/* Reallocate other buffers if needed. */
if (ctx->Visual->DepthBits>0) {
@@ -1959,9 +1976,9 @@ static void update_rasterflags( GLcontext *ctx )
ctx->RasterMask |= ALPHABUF_BIT;
if ( ctx->Viewport.X<0
- || ctx->Viewport.X + ctx->Viewport.Width > ctx->Buffer->Width
+ || ctx->Viewport.X + ctx->Viewport.Width > ctx->DrawBuffer->Width
|| ctx->Viewport.Y<0
- || ctx->Viewport.Y + ctx->Viewport.Height > ctx->Buffer->Height) {
+ || ctx->Viewport.Y + ctx->Viewport.Height > ctx->DrawBuffer->Height) {
ctx->RasterMask |= WINCLIP_BIT;
}
@@ -2144,22 +2161,22 @@ void gl_update_state( GLcontext *ctx )
/* update scissor region */
- ctx->Buffer->Xmin = 0;
- ctx->Buffer->Ymin = 0;
- ctx->Buffer->Xmax = ctx->Buffer->Width-1;
- ctx->Buffer->Ymax = ctx->Buffer->Height-1;
+ ctx->DrawBuffer->Xmin = 0;
+ ctx->DrawBuffer->Ymin = 0;
+ ctx->DrawBuffer->Xmax = ctx->DrawBuffer->Width-1;
+ ctx->DrawBuffer->Ymax = ctx->DrawBuffer->Height-1;
if (ctx->Scissor.Enabled) {
- if (ctx->Scissor.X > ctx->Buffer->Xmin) {
- ctx->Buffer->Xmin = ctx->Scissor.X;
+ if (ctx->Scissor.X > ctx->DrawBuffer->Xmin) {
+ ctx->DrawBuffer->Xmin = ctx->Scissor.X;
}
- if (ctx->Scissor.Y > ctx->Buffer->Ymin) {
- ctx->Buffer->Ymin = ctx->Scissor.Y;
+ if (ctx->Scissor.Y > ctx->DrawBuffer->Ymin) {
+ ctx->DrawBuffer->Ymin = ctx->Scissor.Y;
}
- if (ctx->Scissor.X + ctx->Scissor.Width - 1 < ctx->Buffer->Xmax) {
- ctx->Buffer->Xmax = ctx->Scissor.X + ctx->Scissor.Width - 1;
+ if (ctx->Scissor.X + ctx->Scissor.Width - 1 < ctx->DrawBuffer->Xmax) {
+ ctx->DrawBuffer->Xmax = ctx->Scissor.X + ctx->Scissor.Width - 1;
}
- if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < ctx->Buffer->Ymax) {
- ctx->Buffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height - 1;
+ if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < ctx->DrawBuffer->Ymax) {
+ ctx->DrawBuffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height - 1;
}
}
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 6d391b89d3d..df510afb3f6 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -1,4 +1,4 @@
-/* $Id: context.h,v 1.3 1999/11/19 22:26:53 brianp Exp $ */
+/* $Id: context.h,v 1.4 1999/11/24 18:48:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -105,6 +105,9 @@ extern void gl_destroy_framebuffer( GLframebuffer *buffer );
extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer );
+extern void gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer );
+
extern GLcontext *gl_get_current_context(void);
diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c
index dcd84f58480..746b8188ba8 100644
--- a/src/mesa/main/depth.c
+++ b/src/mesa/main/depth.c
@@ -1,4 +1,4 @@
-/* $Id: depth.c,v 1.9 1999/11/11 01:22:26 brianp Exp $ */
+/* $Id: depth.c,v 1.10 1999/11/24 18:48:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -747,7 +747,7 @@ void gl_read_depth_span_float( GLcontext* ctx,
scale = 1.0F / DEPTH_SCALE;
- if (ctx->Buffer->Depth) {
+ if (ctx->DrawBuffer->Depth) {
zptr = Z_ADDRESS( ctx, x, y );
for (i=0;i<n;i++) {
depth[i] = (GLfloat) zptr[i] * scale;
@@ -772,7 +772,7 @@ void gl_read_depth_span_float( GLcontext* ctx,
void gl_read_depth_span_int( GLcontext* ctx,
GLuint n, GLint x, GLint y, GLdepth depth[] )
{
- if (ctx->Buffer->Depth) {
+ if (ctx->DrawBuffer->Depth) {
GLdepth *zptr = Z_ADDRESS( ctx, x, y );
MEMCPY( depth, zptr, n * sizeof(GLdepth) );
}
@@ -800,16 +800,16 @@ void gl_read_depth_span_int( GLcontext* ctx,
void gl_alloc_depth_buffer( GLcontext* ctx )
{
/* deallocate current depth buffer if present */
- if (ctx->Buffer->Depth) {
- FREE(ctx->Buffer->Depth);
- ctx->Buffer->Depth = NULL;
+ if (ctx->DrawBuffer->Depth) {
+ FREE(ctx->DrawBuffer->Depth);
+ ctx->DrawBuffer->Depth = NULL;
}
/* allocate new depth buffer, but don't initialize it */
- ctx->Buffer->Depth = (GLdepth *) MALLOC( ctx->Buffer->Width
- * ctx->Buffer->Height
+ ctx->DrawBuffer->Depth = (GLdepth *) MALLOC( ctx->DrawBuffer->Width
+ * ctx->DrawBuffer->Height
* sizeof(GLdepth) );
- if (!ctx->Buffer->Depth) {
+ if (!ctx->DrawBuffer->Depth) {
/* out of memory */
ctx->Depth.Test = GL_FALSE;
ctx->NewState |= NEW_RASTER_OPS;
@@ -829,7 +829,7 @@ void gl_clear_depth_buffer( GLcontext* ctx )
{
GLdepth clear_value = (GLdepth) (ctx->Depth.Clear * DEPTH_SCALE);
- if (ctx->Visual->DepthBits==0 || !ctx->Buffer->Depth || !ctx->Depth.Mask) {
+ if (ctx->Visual->DepthBits==0 || !ctx->DrawBuffer->Depth || !ctx->Depth.Mask) {
/* no depth buffer, or writing to it is disabled */
return;
}
@@ -841,9 +841,9 @@ void gl_clear_depth_buffer( GLcontext* ctx )
if (ctx->Scissor.Enabled) {
/* only clear scissor region */
GLint y;
- for (y=ctx->Buffer->Ymin; y<=ctx->Buffer->Ymax; y++) {
- GLdepth *d = Z_ADDRESS( ctx, ctx->Buffer->Xmin, y );
- GLint n = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1;
+ for (y=ctx->DrawBuffer->Ymin; y<=ctx->DrawBuffer->Ymax; y++) {
+ GLdepth *d = Z_ADDRESS( ctx, ctx->DrawBuffer->Xmin, y );
+ GLint n = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin + 1;
do {
*d++ = clear_value;
n--;
@@ -854,12 +854,12 @@ void gl_clear_depth_buffer( GLcontext* ctx )
/* clear whole buffer */
if (sizeof(GLdepth)==2 && (clear_value&0xff)==(clear_value>>8)) {
/* lower and upper bytes of clear_value are same, use MEMSET */
- MEMSET( ctx->Buffer->Depth, clear_value&0xff,
- 2*ctx->Buffer->Width*ctx->Buffer->Height);
+ MEMSET( ctx->DrawBuffer->Depth, clear_value&0xff,
+ 2*ctx->DrawBuffer->Width*ctx->DrawBuffer->Height);
}
else {
- GLdepth *d = ctx->Buffer->Depth;
- GLint n = ctx->Buffer->Width * ctx->Buffer->Height;
+ GLdepth *d = ctx->DrawBuffer->Depth;
+ GLint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
while (n>=16) {
d[0] = clear_value; d[1] = clear_value;
d[2] = clear_value; d[3] = clear_value;
diff --git a/src/mesa/main/depth.h b/src/mesa/main/depth.h
index 9749905d2c4..c579e3d9fb9 100644
--- a/src/mesa/main/depth.h
+++ b/src/mesa/main/depth.h
@@ -1,4 +1,4 @@
-/* $Id: depth.h,v 1.3 1999/11/11 01:22:26 brianp Exp $ */
+/* $Id: depth.h,v 1.4 1999/11/24 18:48:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -36,7 +36,7 @@
* Return the address of the Z-buffer value for window coordinate (x,y):
*/
#define Z_ADDRESS( CTX, X, Y ) \
- ((CTX)->Buffer->Depth + (CTX)->Buffer->Width * (Y) + (X))
+ ((CTX)->DrawBuffer->Depth + (CTX)->DrawBuffer->Width * (Y) + (X))
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index a3f13546441..60a30c25664 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.8 1999/11/22 22:21:38 brianp Exp $ */
+/* $Id: drawpix.c,v 1.9 1999/11/24 18:48:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -57,28 +57,30 @@ _mesa_clip_pixelrect(const GLcontext *ctx,
GLsizei *width, GLsizei *height,
GLint *skipPixels, GLint *skipRows)
{
+ const GLframebuffer *buffer = ctx->DrawBuffer;
+
/* left clipping */
- if (*destX < ctx->Buffer->Xmin) {
- *skipPixels += (ctx->Buffer->Xmin - *destX);
- *width -= (ctx->Buffer->Xmin - *destX);
- *destX = ctx->Buffer->Xmin;
+ if (*destX < buffer->Xmin) {
+ *skipPixels += (buffer->Xmin - *destX);
+ *width -= (buffer->Xmin - *destX);
+ *destX = buffer->Xmin;
}
/* right clipping */
- if (*destX + *width > ctx->Buffer->Xmax)
- *width -= (*destX + *width - ctx->Buffer->Xmax - 1);
+ if (*destX + *width > buffer->Xmax)
+ *width -= (*destX + *width - buffer->Xmax - 1);
if (*width <= 0)
return GL_FALSE;
/* bottom clipping */
- if (*destY < ctx->Buffer->Ymin) {
- *skipRows += (ctx->Buffer->Ymin - *destY);
- *height -= (ctx->Buffer->Ymin - *destY);
- *destY = ctx->Buffer->Ymin;
+ if (*destY < buffer->Ymin) {
+ *skipRows += (buffer->Ymin - *destY);
+ *height -= (buffer->Ymin - *destY);
+ *destY = buffer->Ymin;
}
/* top clipping */
- if (*destY + *height > ctx->Buffer->Ymax)
- *height -= (*destY + *height - ctx->Buffer->Ymax - 1);
+ if (*destY + *height > buffer->Ymax)
+ *height -= (*destY + *height - buffer->Ymax - 1);
if (*height <= 0)
return GL_TRUE;
@@ -153,24 +155,24 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
*/
if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
/* horizontal clipping */
- if (destX < ctx->Buffer->Xmin) {
- skipPixels += (ctx->Buffer->Xmin - destX);
- drawWidth -= (ctx->Buffer->Xmin - destX);
- destX = ctx->Buffer->Xmin;
+ if (destX < ctx->DrawBuffer->Xmin) {
+ skipPixels += (ctx->DrawBuffer->Xmin - destX);
+ drawWidth -= (ctx->DrawBuffer->Xmin - destX);
+ destX = ctx->DrawBuffer->Xmin;
}
- if (destX + drawWidth > ctx->Buffer->Xmax)
- drawWidth -= (destX + drawWidth - ctx->Buffer->Xmax - 1);
+ if (destX + drawWidth > ctx->DrawBuffer->Xmax)
+ drawWidth -= (destX + drawWidth - ctx->DrawBuffer->Xmax - 1);
if (drawWidth <= 0)
return GL_TRUE;
/* vertical clipping */
- if (destY < ctx->Buffer->Ymin) {
- skipRows += (ctx->Buffer->Ymin - destY);
- drawHeight -= (ctx->Buffer->Ymin - destY);
- destY = ctx->Buffer->Ymin;
+ if (destY < ctx->DrawBuffer->Ymin) {
+ skipRows += (ctx->DrawBuffer->Ymin - destY);
+ drawHeight -= (ctx->DrawBuffer->Ymin - destY);
+ destY = ctx->DrawBuffer->Ymin;
}
- if (destY + drawHeight > ctx->Buffer->Ymax)
- drawHeight -= (destY + drawHeight - ctx->Buffer->Ymax - 1);
+ if (destY + drawHeight > ctx->DrawBuffer->Ymax)
+ drawHeight -= (destY + drawHeight - ctx->DrawBuffer->Ymax - 1);
if (drawHeight <= 0)
return GL_TRUE;
@@ -633,8 +635,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
if (ctx->RasterMask == 0 && !zoom
&& x >= 0 && y >= 0
- && x + width <= ctx->Buffer->Width
- && y + height <= ctx->Buffer->Height) {
+ && x + width <= ctx->DrawBuffer->Width
+ && y + height <= ctx->DrawBuffer->Height) {
quickDraw = GL_TRUE;
}
else {
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index cdb8160ce58..afd33ed0150 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -1,4 +1,4 @@
-/* $Id: matrix.c,v 1.10 1999/11/12 18:10:47 brianp Exp $ */
+/* $Id: matrix.c,v 1.11 1999/11/24 18:48:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1397,9 +1397,9 @@ gl_Viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height )
ctx->RasterMask &= ~WINCLIP_BIT;
if ( ctx->Viewport.X<0
- || ctx->Viewport.X + ctx->Viewport.Width > ctx->Buffer->Width
+ || ctx->Viewport.X + ctx->Viewport.Width > ctx->DrawBuffer->Width
|| ctx->Viewport.Y<0
- || ctx->Viewport.Y + ctx->Viewport.Height > ctx->Buffer->Height) {
+ || ctx->Viewport.Y + ctx->Viewport.Height > ctx->DrawBuffer->Height) {
ctx->RasterMask |= WINCLIP_BIT;
}
diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c
index 0530700d827..df316267f67 100644
--- a/src/mesa/main/stencil.c
+++ b/src/mesa/main/stencil.c
@@ -1,4 +1,4 @@
-/* $Id: stencil.c,v 1.9 1999/11/11 01:22:27 brianp Exp $ */
+/* $Id: stencil.c,v 1.10 1999/11/24 18:48:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -48,12 +48,6 @@
-/*
- * Return the address of a stencil buffer value given the window coords:
- */
-#define STENCIL_ADDRESS(X,Y) (ctx->Buffer->Stencil + ctx->Buffer->Width * (Y) + (X))
-
-
void
_mesa_ClearStencil( GLint s )
{
@@ -197,6 +191,13 @@ ENDIF
+/*
+ * Return the address of a stencil buffer value given the window coords:
+ */
+#define STENCIL_ADDRESS(X,Y) \
+ (ctx->DrawBuffer->Stencil + ctx->DrawBuffer->Width * (Y) + (X))
+
+
/*
* Apply the given stencil operator for each pixel in the span whose
@@ -1006,7 +1007,7 @@ void gl_depth_stencil_pixels( GLcontext *ctx,
void gl_read_stencil_span( GLcontext *ctx,
GLuint n, GLint x, GLint y, GLstencil stencil[] )
{
- if (ctx->Buffer->Stencil) {
+ if (ctx->DrawBuffer->Stencil) {
const GLstencil *s = STENCIL_ADDRESS( x, y );
#if STENCIL_BITS == 8
MEMCPY( stencil, s, n * sizeof(GLstencil) );
@@ -1030,7 +1031,7 @@ void gl_write_stencil_span( GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLstencil stencil[] )
{
- if (ctx->Buffer->Stencil) {
+ if (ctx->DrawBuffer->Stencil) {
GLstencil *s = STENCIL_ADDRESS( x, y );
#if STENCIL_BITS == 8
MEMCPY( s, stencil, n * sizeof(GLstencil) );
@@ -1050,17 +1051,17 @@ void gl_write_stencil_span( GLcontext *ctx,
*/
void gl_alloc_stencil_buffer( GLcontext *ctx )
{
- GLuint buffersize = ctx->Buffer->Width * ctx->Buffer->Height;
+ GLuint buffersize = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
/* deallocate current stencil buffer if present */
- if (ctx->Buffer->Stencil) {
- FREE(ctx->Buffer->Stencil);
- ctx->Buffer->Stencil = NULL;
+ if (ctx->DrawBuffer->Stencil) {
+ FREE(ctx->DrawBuffer->Stencil);
+ ctx->DrawBuffer->Stencil = NULL;
}
/* allocate new stencil buffer */
- ctx->Buffer->Stencil = (GLstencil *) MALLOC(buffersize * sizeof(GLstencil));
- if (!ctx->Buffer->Stencil) {
+ ctx->DrawBuffer->Stencil = (GLstencil *) MALLOC(buffersize * sizeof(GLstencil));
+ if (!ctx->DrawBuffer->Stencil) {
/* out of memory */
_mesa_set_enable( ctx, GL_STENCIL_TEST, GL_FALSE );
gl_error( ctx, GL_OUT_OF_MEMORY, "gl_alloc_stencil_buffer" );
@@ -1076,7 +1077,7 @@ void gl_alloc_stencil_buffer( GLcontext *ctx )
*/
void gl_clear_stencil_buffer( GLcontext *ctx )
{
- if (ctx->Visual->StencilBits==0 || !ctx->Buffer->Stencil) {
+ if (ctx->Visual->StencilBits==0 || !ctx->DrawBuffer->Stencil) {
/* no stencil buffer */
return;
}
@@ -1084,9 +1085,9 @@ void gl_clear_stencil_buffer( GLcontext *ctx )
if (ctx->Scissor.Enabled) {
/* clear scissor region only */
GLint y;
- GLint width = ctx->Buffer->Xmax - ctx->Buffer->Xmin + 1;
- for (y=ctx->Buffer->Ymin; y<=ctx->Buffer->Ymax; y++) {
- GLstencil *ptr = STENCIL_ADDRESS( ctx->Buffer->Xmin, y );
+ GLint width = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin + 1;
+ for (y=ctx->DrawBuffer->Ymin; y<=ctx->DrawBuffer->Ymax; y++) {
+ GLstencil *ptr = STENCIL_ADDRESS( ctx->DrawBuffer->Xmin, y );
#if STENCIL_BITS==8
MEMSET( ptr, ctx->Stencil.Clear, width * sizeof(GLstencil) );
#else
@@ -1099,12 +1100,12 @@ void gl_clear_stencil_buffer( GLcontext *ctx )
else {
/* clear whole stencil buffer */
#if STENCIL_BITS==8
- MEMSET( ctx->Buffer->Stencil, ctx->Stencil.Clear,
- ctx->Buffer->Width * ctx->Buffer->Height * sizeof(GLstencil) );
+ MEMSET( ctx->DrawBuffer->Stencil, ctx->Stencil.Clear,
+ ctx->DrawBuffer->Width * ctx->DrawBuffer->Height * sizeof(GLstencil) );
#else
GLuint i;
- GLuint pixels = ctx->Buffer->Width * ctx->Buffer->Height;
- GLstencil *buffer = ctx->Buffer->Stencil;
+ GLuint pixels = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height;
+ GLstencil *buffer = ctx->DrawBuffer->Stencil;
for (i = 0; i < pixels; i++)
ptr[i] = ctx->Stencil.Clear;
#endif
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 42d1c90efbf..56955af6c86 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1,4 +1,4 @@
-/* $Id: teximage.c,v 1.12 1999/11/11 01:22:27 brianp Exp $ */
+/* $Id: teximage.c,v 1.13 1999/11/24 18:48:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1632,7 +1632,8 @@ read_color_image( GLcontext *ctx, GLint x, GLint y,
dst = image;
stride = width * 4 * sizeof(GLubyte);
for (i = 0; i < height; i++) {
- gl_read_rgba_span( ctx, width, x, y + i, (GLubyte (*)[4]) dst );
+ gl_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y + i,
+ (GLubyte (*)[4]) dst );
dst += stride;
}
@@ -1732,7 +1733,7 @@ copy_tex_sub_image( GLcontext *ctx, struct gl_texture_image *dest,
for (i = 0;i < height; i++) {
GLubyte rgba[MAX_WIDTH][4];
GLubyte *dst;
- gl_read_rgba_span( ctx, width, srcx, srcy + i, rgba );
+ gl_read_rgba_span( ctx, ctx->ReadBuffer, width, srcx, srcy + i, rgba );
dst = dest->Data + ( zoffset + (dsty+i) * texwidth + dstx) * components;
_mesa_unpack_ubyte_color_span(ctx, width, format, dst,
GL_RGBA, GL_UNSIGNED_BYTE, rgba,