-/* $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.
*
* 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
# ifdef GLX_DIRECT_RENDERING
# include "dri_mesa.h"
# endif
-# ifdef SHM
+# ifdef USE_XSHM
# include <X11/extensions/XShm.h>
# endif
#endif
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? */
/* 0 = not available */
/* 1 = XImage support available */
/* 2 = Pixmap support available too */
-#ifdef SHM
+#ifdef USE_XSHM
XShmSegmentInfo shminfo;
#endif
#endif
-/* $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.
*
{
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" );
}
*/
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);
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;
}
/* 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;
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;
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 );
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];
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++;
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];
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);
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);
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 );
}
/* 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;
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;
row[i+2] = b;
row[i+3] = a;
}
- row += 4 * ctx->Buffer->Width;
+ row += 4 * ctx->DrawBuffer->Width;
}
}
else {
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);
-/* $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.
*
}
/* 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);
-/* $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
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) {
* Set the current context, binding the given frame buffer to the context.
*/
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);
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
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.
*/
(*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) {
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;
}
/* 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;
}
}
-/* $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
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);
-/* $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
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;
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) );
}
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;
{
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;
}
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--;
/* 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;
-/* $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
* 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))
-/* $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
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;
*/
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;
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 {
-/* $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
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;
}
-/* $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
-/*
- * 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 )
{
+/*
+ * 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
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) );
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) );
*/
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" );
*/
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;
}
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
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
-/* $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
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;
}
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,